svcore  1.9
FFTMemoryCache Class Reference

In-memory FFT cache. More...

#include <FFTMemoryCache.h>

Inheritance diagram for FFTMemoryCache:
Collaboration diagram for FFTMemoryCache:

Public Member Functions

 FFTMemoryCache (FFTCache::StorageType storageType, int width, int height)
 
 ~FFTMemoryCache ()
 
int getWidth () const
 
int getHeight () const
 
float getMagnitudeAt (int x, int y) const
 
float getNormalizedMagnitudeAt (int x, int y) const
 
float getMaximumMagnitudeAt (int x) const
 
float getPhaseAt (int x, int y) const
 
void getValuesAt (int x, int y, float &real, float &imag) const
 
void getMagnitudesAt (int x, float *values, int minbin, int count, int step) const
 
bool haveSetColumnAt (int x) const
 
void setColumnAt (int x, float *mags, float *phases, float factor)
 
void setColumnAt (int x, float *reals, float *imags)
 
void allColumnsWritten ()
 
FFTCache::StorageType getStorageType () const
 

Static Public Member Functions

static int getCacheSize (int width, int height, FFTCache::StorageType type)
 

Private Member Functions

void initialise ()
 
void setNormalizationFactor (int x, float factor)
 
void setMagnitudeAt (int x, int y, float mag)
 
void setNormalizedMagnitudeAt (int x, int y, float norm)
 
void setPhaseAt (int x, int y, float phase)
 
void initialise (uint16_t **&)
 
void initialise (float **&)
 

Private Attributes

int m_width
 
int m_height
 
uint16_t ** m_magnitude
 
uint16_t ** m_phase
 
float ** m_fmagnitude
 
float ** m_fphase
 
float ** m_freal
 
float ** m_fimag
 
float * m_factor
 
FFTCache::StorageType m_storageType
 
ResizeableBitset m_colset
 
QReadWriteLock m_colsetLock
 

Detailed Description

In-memory FFT cache.

For this we want to cache magnitude with enough resolution to have gain applied afterwards and determine whether something is a peak or not, and also cache phase rather than only phase-adjusted frequency so that we don't have to recalculate if switching between phase and magnitude displays. At the same time, we don't want to take up too much memory. It's not expected to be accurate enough to be used as input for DSP or resynthesis code.

This implies probably 16 bits for a normalized magnitude and at most 16 bits for phase.

Each column's magnitudes are expected to be stored normalized to [0,1] with respect to the column, so the normalization factor should be calculated before all values in a column, and set appropriately.

Definition at line 46 of file FFTMemoryCache.h.

Constructor & Destructor Documentation

◆ FFTMemoryCache()

FFTMemoryCache::FFTMemoryCache ( FFTCache::StorageType  storageType,
int  width,
int  height 
)

Definition at line 24 of file FFTMemoryCache.cpp.

References initialise(), m_height, m_storageType, and m_width.

◆ ~FFTMemoryCache()

FFTMemoryCache::~FFTMemoryCache ( )

Definition at line 45 of file FFTMemoryCache.cpp.

References m_factor, m_fimag, m_fmagnitude, m_fphase, m_freal, m_magnitude, m_phase, and m_width.

Member Function Documentation

◆ getWidth()

int FFTMemoryCache::getWidth ( ) const
inlinevirtual

Implements FFTCacheReader.

Definition at line 53 of file FFTMemoryCache.h.

References m_width.

◆ getHeight()

int FFTMemoryCache::getHeight ( ) const
inlinevirtual

Implements FFTCacheReader.

Definition at line 54 of file FFTMemoryCache.h.

References m_height.

◆ getMagnitudeAt()

float FFTMemoryCache::getMagnitudeAt ( int  x,
int  y 
) const
inlinevirtual

◆ getNormalizedMagnitudeAt()

float FFTMemoryCache::getNormalizedMagnitudeAt ( int  x,
int  y 
) const
inlinevirtual

◆ getMaximumMagnitudeAt()

float FFTMemoryCache::getMaximumMagnitudeAt ( int  x) const
inlinevirtual

Implements FFTCacheReader.

Definition at line 72 of file FFTMemoryCache.h.

References m_factor.

◆ getPhaseAt()

float FFTMemoryCache::getPhaseAt ( int  x,
int  y 
) const
inlinevirtual

Implements FFTCacheReader.

Definition at line 76 of file FFTMemoryCache.h.

References m_fimag, m_fphase, m_freal, m_phase, m_storageType, FFTCache::Polar, and FFTCache::Rectangular.

Referenced by getValuesAt().

◆ getValuesAt()

void FFTMemoryCache::getValuesAt ( int  x,
int  y,
float &  real,
float &  imag 
) const
inlinevirtual

◆ getMagnitudesAt()

void FFTMemoryCache::getMagnitudesAt ( int  x,
float *  values,
int  minbin,
int  count,
int  step 
) const
inlinevirtual

◆ haveSetColumnAt()

bool FFTMemoryCache::haveSetColumnAt ( int  x) const
inlinevirtual

Implements FFTCacheReader.

Definition at line 122 of file FFTMemoryCache.h.

References ResizeableBitset::get(), m_colset, and m_colsetLock.

◆ setColumnAt() [1/2]

void FFTMemoryCache::setColumnAt ( int  x,
float *  mags,
float *  phases,
float  factor 
)
virtual

◆ setColumnAt() [2/2]

void FFTMemoryCache::setColumnAt ( int  x,
float *  reals,
float *  imags 
)
virtual

◆ allColumnsWritten()

void FFTMemoryCache::allColumnsWritten ( )
inlinevirtual

Implements FFTCacheWriter.

Definition at line 133 of file FFTMemoryCache.h.

◆ getCacheSize()

int FFTMemoryCache::getCacheSize ( int  width,
int  height,
FFTCache::StorageType  type 
)
static

Definition at line 200 of file FFTMemoryCache.cpp.

References FFTCache::Compact, FFTCache::Polar, and FFTCache::Rectangular.

◆ getStorageType()

FFTCache::StorageType FFTMemoryCache::getStorageType ( ) const
inlinevirtual

Implements FFTCacheReader.

Definition at line 138 of file FFTMemoryCache.h.

References m_storageType.

◆ initialise() [1/3]

void FFTMemoryCache::initialise ( )
private

◆ setNormalizationFactor()

void FFTMemoryCache::setNormalizationFactor ( int  x,
float  factor 
)
inlineprivate

Definition at line 156 of file FFTMemoryCache.h.

References m_factor, and m_width.

Referenced by setColumnAt().

◆ setMagnitudeAt()

void FFTMemoryCache::setMagnitudeAt ( int  x,
int  y,
float  mag 
)
inlineprivate

Definition at line 160 of file FFTMemoryCache.h.

References m_factor, and setNormalizedMagnitudeAt().

Referenced by setColumnAt().

◆ setNormalizedMagnitudeAt()

void FFTMemoryCache::setNormalizedMagnitudeAt ( int  x,
int  y,
float  norm 
)
inlineprivate

Definition at line 165 of file FFTMemoryCache.h.

References m_fmagnitude, m_height, m_magnitude, m_storageType, m_width, and FFTCache::Polar.

Referenced by setMagnitudeAt().

◆ setPhaseAt()

void FFTMemoryCache::setPhaseAt ( int  x,
int  y,
float  phase 
)
inlineprivate

Definition at line 172 of file FFTMemoryCache.h.

References m_fphase, m_height, m_phase, m_storageType, m_width, and FFTCache::Polar.

Referenced by setColumnAt().

◆ initialise() [2/3]

void FFTMemoryCache::initialise ( uint16_t **&  array)
private

Definition at line 104 of file FFTMemoryCache.cpp.

References m_height, m_width, and MUNLOCK.

◆ initialise() [3/3]

void FFTMemoryCache::initialise ( float **&  array)
private

Definition at line 118 of file FFTMemoryCache.cpp.

References m_height, m_width, and MUNLOCK.

Member Data Documentation

◆ m_width

int FFTMemoryCache::m_width
private

◆ m_height

int FFTMemoryCache::m_height
private

◆ m_magnitude

uint16_t** FFTMemoryCache::m_magnitude
private

◆ m_phase

uint16_t** FFTMemoryCache::m_phase
private

Definition at line 144 of file FFTMemoryCache.h.

Referenced by getPhaseAt(), initialise(), setPhaseAt(), and ~FFTMemoryCache().

◆ m_fmagnitude

float** FFTMemoryCache::m_fmagnitude
private

◆ m_fphase

float** FFTMemoryCache::m_fphase
private

Definition at line 146 of file FFTMemoryCache.h.

Referenced by getPhaseAt(), initialise(), setPhaseAt(), and ~FFTMemoryCache().

◆ m_freal

float** FFTMemoryCache::m_freal
private

◆ m_fimag

float** FFTMemoryCache::m_fimag
private

◆ m_factor

◆ m_storageType

◆ m_colset

ResizeableBitset FFTMemoryCache::m_colset
private

Definition at line 151 of file FFTMemoryCache.h.

Referenced by haveSetColumnAt(), initialise(), and setColumnAt().

◆ m_colsetLock

QReadWriteLock FFTMemoryCache::m_colsetLock
mutableprivate

Definition at line 152 of file FFTMemoryCache.h.

Referenced by haveSetColumnAt(), and setColumnAt().


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