LMMS
Loading...
Searching...
No Matches
lmms::SaProcessor Class Reference

Receives audio data, runs FFT analysis and stores the result. More...

#include <SaProcessor.h>

Public Member Functions

 SaProcessor (const SaControls *controls)
virtual ~SaProcessor ()
void analyze (LocklessRingBuffer< SampleFrame > &ring_buffer)
void terminate ()
void setSpectrumActive (bool active)
void setWaterfallActive (bool active)
void flipRequest ()
void reallocateBuffers ()
void rebuildWindow ()
void clear ()
void clearHistory ()
const float * getSpectrumL () const
const float * getSpectrumR () const
const uchargetHistory () const
unsigned int inBlockSize () const
unsigned int binCount () const
 size of output (frequency domain) data block
bool spectrumNotEmpty ()
 check if result buffers contain any non-zero values
unsigned int waterfallWidth () const
 binCount value capped at 3840 (for display)
unsigned int waterfallHeight () const
bool waterfallNotEmpty () const
float binToFreq (unsigned int bin_index) const
float binBandwidth () const
float freqToXPixel (float frequency, unsigned int width) const
float xPixelToFreq (float x, unsigned int width) const
float ampToYPixel (float amplitude, unsigned int height) const
float yPixelToAmp (float y, unsigned int height) const
unsigned int getSampleRate () const
float getNyquistFreq () const
float getFreqRangeMin (bool linear=false) const
float getFreqRangeMax () const
float getAmpRangeMin (bool linear=false) const
float getAmpRangeMax () const

Public Attributes

QMutex m_reallocationAccess
QMutex m_dataAccess

Private Member Functions

QRgb makePixel (float left, float right) const

Private Attributes

const SaControlsm_controls
bool m_terminate
unsigned int m_zeroPadFactor = 2
 use n-steps bigger FFT for given block size
std::atomic< unsigned intm_inBlockSize
 size of input (time domain) data block
unsigned int m_fftBlockSize
 size of padded block for FFT processing
unsigned int m_sampleRate
unsigned int m_framesFilledUp
std::vector< float > m_bufferL
 time domain samples (left)
std::vector< float > m_bufferR
 time domain samples (right)
std::vector< float > m_fftWindow
 precomputed window function coefficients
std::vector< float > m_filteredBufferL
 time domain samples with window function applied (left)
std::vector< float > m_filteredBufferR
 time domain samples with window function applied (right)
fftwf_plan m_fftPlanL
fftwf_plan m_fftPlanR
fftwf_complex * m_spectrumL
 frequency domain samples (complex) (left)
fftwf_complex * m_spectrumR
 frequency domain samples (complex) (right)
std::vector< float > m_absSpectrumL
 frequency domain samples (absolute) (left)
std::vector< float > m_absSpectrumR
 frequency domain samples (absolute) (right)
std::vector< float > m_normSpectrumL
 frequency domain samples (normalized) (left)
std::vector< float > m_normSpectrumR
 frequency domain samples (normalized) (right)
std::vector< ucharm_history_work
 local history buffer for render
std::vector< ucharm_history
 public buffer for reading
bool m_flipRequest
 update public buffer only when requested
std::atomic< unsigned intm_waterfallHeight
 number of stored lines in history buffer
const unsigned int m_waterfallMaxWidth = 3840
bool m_spectrumActive
bool m_waterfallActive
std::atomic< unsigned intm_waterfallNotEmpty
 number of lines remaining visible on display
bool m_reallocating

Detailed Description

Receives audio data, runs FFT analysis and stores the result.

Constructor & Destructor Documentation

◆ SaProcessor()

lmms::SaProcessor::SaProcessor ( const SaControls * controls)
explicit

◆ ~SaProcessor()

lmms::SaProcessor::~SaProcessor ( )
virtual

Member Function Documentation

◆ ampToYPixel()

float lmms::SaProcessor::ampToYPixel ( float amplitude,
unsigned int height ) const

◆ analyze()

void lmms::SaProcessor::analyze ( LocklessRingBuffer< SampleFrame > & ring_buffer)

◆ binBandwidth()

float lmms::SaProcessor::binBandwidth ( ) const

◆ binCount()

unsigned int lmms::SaProcessor::binCount ( ) const

size of output (frequency domain) data block

◆ binToFreq()

float lmms::SaProcessor::binToFreq ( unsigned int bin_index) const

◆ clear()

void lmms::SaProcessor::clear ( )

◆ clearHistory()

void lmms::SaProcessor::clearHistory ( )

◆ flipRequest()

void lmms::SaProcessor::flipRequest ( )
inline

◆ freqToXPixel()

float lmms::SaProcessor::freqToXPixel ( float frequency,
unsigned int width ) const

◆ getAmpRangeMax()

float lmms::SaProcessor::getAmpRangeMax ( ) const

◆ getAmpRangeMin()

float lmms::SaProcessor::getAmpRangeMin ( bool linear = false) const

◆ getFreqRangeMax()

float lmms::SaProcessor::getFreqRangeMax ( ) const

◆ getFreqRangeMin()

float lmms::SaProcessor::getFreqRangeMin ( bool linear = false) const

◆ getHistory()

const uchar * lmms::SaProcessor::getHistory ( ) const
inline

◆ getNyquistFreq()

float lmms::SaProcessor::getNyquistFreq ( ) const

◆ getSampleRate()

unsigned int lmms::SaProcessor::getSampleRate ( ) const

◆ getSpectrumL()

const float * lmms::SaProcessor::getSpectrumL ( ) const
inline

◆ getSpectrumR()

const float * lmms::SaProcessor::getSpectrumR ( ) const
inline

◆ inBlockSize()

unsigned int lmms::SaProcessor::inBlockSize ( ) const
inline

◆ makePixel()

QRgb lmms::SaProcessor::makePixel ( float left,
float right ) const
private

◆ reallocateBuffers()

void lmms::SaProcessor::reallocateBuffers ( )

◆ rebuildWindow()

void lmms::SaProcessor::rebuildWindow ( )

◆ setSpectrumActive()

void lmms::SaProcessor::setSpectrumActive ( bool active)

◆ setWaterfallActive()

void lmms::SaProcessor::setWaterfallActive ( bool active)

◆ spectrumNotEmpty()

bool lmms::SaProcessor::spectrumNotEmpty ( )

check if result buffers contain any non-zero values

◆ terminate()

void lmms::SaProcessor::terminate ( )
inline

◆ waterfallHeight()

unsigned int lmms::SaProcessor::waterfallHeight ( ) const
inline

◆ waterfallNotEmpty()

bool lmms::SaProcessor::waterfallNotEmpty ( ) const
inline

◆ waterfallWidth()

unsigned int lmms::SaProcessor::waterfallWidth ( ) const

binCount value capped at 3840 (for display)

◆ xPixelToFreq()

float lmms::SaProcessor::xPixelToFreq ( float x,
unsigned int width ) const

◆ yPixelToAmp()

float lmms::SaProcessor::yPixelToAmp ( float y,
unsigned int height ) const

Member Data Documentation

◆ m_absSpectrumL

std::vector<float> lmms::SaProcessor::m_absSpectrumL
private

frequency domain samples (absolute) (left)

◆ m_absSpectrumR

std::vector<float> lmms::SaProcessor::m_absSpectrumR
private

frequency domain samples (absolute) (right)

◆ m_bufferL

std::vector<float> lmms::SaProcessor::m_bufferL
private

time domain samples (left)

◆ m_bufferR

std::vector<float> lmms::SaProcessor::m_bufferR
private

time domain samples (right)

◆ m_controls

const SaControls* lmms::SaProcessor::m_controls
private

◆ m_dataAccess

QMutex lmms::SaProcessor::m_dataAccess

◆ m_fftBlockSize

unsigned int lmms::SaProcessor::m_fftBlockSize
private

size of padded block for FFT processing

◆ m_fftPlanL

fftwf_plan lmms::SaProcessor::m_fftPlanL
private

◆ m_fftPlanR

fftwf_plan lmms::SaProcessor::m_fftPlanR
private

◆ m_fftWindow

std::vector<float> lmms::SaProcessor::m_fftWindow
private

precomputed window function coefficients

◆ m_filteredBufferL

std::vector<float> lmms::SaProcessor::m_filteredBufferL
private

time domain samples with window function applied (left)

◆ m_filteredBufferR

std::vector<float> lmms::SaProcessor::m_filteredBufferR
private

time domain samples with window function applied (right)

◆ m_flipRequest

bool lmms::SaProcessor::m_flipRequest
private

update public buffer only when requested

◆ m_framesFilledUp

unsigned int lmms::SaProcessor::m_framesFilledUp
private

◆ m_history

std::vector<uchar> lmms::SaProcessor::m_history
private

public buffer for reading

◆ m_history_work

std::vector<uchar> lmms::SaProcessor::m_history_work
private

local history buffer for render

◆ m_inBlockSize

std::atomic<unsigned int> lmms::SaProcessor::m_inBlockSize
private

size of input (time domain) data block

◆ m_normSpectrumL

std::vector<float> lmms::SaProcessor::m_normSpectrumL
private

frequency domain samples (normalized) (left)

◆ m_normSpectrumR

std::vector<float> lmms::SaProcessor::m_normSpectrumR
private

frequency domain samples (normalized) (right)

◆ m_reallocating

bool lmms::SaProcessor::m_reallocating
private

◆ m_reallocationAccess

QMutex lmms::SaProcessor::m_reallocationAccess

◆ m_sampleRate

unsigned int lmms::SaProcessor::m_sampleRate
private

◆ m_spectrumActive

bool lmms::SaProcessor::m_spectrumActive
private

◆ m_spectrumL

fftwf_complex* lmms::SaProcessor::m_spectrumL
private

frequency domain samples (complex) (left)

◆ m_spectrumR

fftwf_complex* lmms::SaProcessor::m_spectrumR
private

frequency domain samples (complex) (right)

◆ m_terminate

bool lmms::SaProcessor::m_terminate
private

◆ m_waterfallActive

bool lmms::SaProcessor::m_waterfallActive
private

◆ m_waterfallHeight

std::atomic<unsigned int> lmms::SaProcessor::m_waterfallHeight
private

number of stored lines in history buffer

◆ m_waterfallMaxWidth

const unsigned int lmms::SaProcessor::m_waterfallMaxWidth = 3840
private

◆ m_waterfallNotEmpty

std::atomic<unsigned int> lmms::SaProcessor::m_waterfallNotEmpty
private

number of lines remaining visible on display

◆ m_zeroPadFactor

unsigned int lmms::SaProcessor::m_zeroPadFactor = 2
private

use n-steps bigger FFT for given block size


The documentation for this class was generated from the following files: