svcore
1.9
|
In-memory FFT cache. More...
#include <FFTMemoryCache.h>
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 |
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.
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.
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.
int FFTMemoryCache::getWidth | ( | ) | const [inline, virtual] |
int FFTMemoryCache::getHeight | ( | ) | const [inline, virtual] |
float FFTMemoryCache::getMagnitudeAt | ( | int | x, |
int | y | ||
) | const [inline, virtual] |
Implements FFTCacheReader.
Definition at line 56 of file FFTMemoryCache.h.
References getNormalizedMagnitudeAt(), m_factor, m_fimag, m_freal, m_storageType, and FFTCache::Rectangular.
Referenced by getNormalizedMagnitudeAt(), and getValuesAt().
float FFTMemoryCache::getNormalizedMagnitudeAt | ( | int | x, |
int | y | ||
) | const [inline, virtual] |
Implements FFTCacheReader.
Definition at line 66 of file FFTMemoryCache.h.
References getMagnitudeAt(), m_factor, m_fmagnitude, m_magnitude, m_storageType, FFTCache::Polar, and FFTCache::Rectangular.
Referenced by getMagnitudeAt().
float FFTMemoryCache::getMaximumMagnitudeAt | ( | int | x | ) | const [inline, virtual] |
float FFTMemoryCache::getPhaseAt | ( | int | x, |
int | y | ||
) | const [inline, virtual] |
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().
void FFTMemoryCache::getValuesAt | ( | int | x, |
int | y, | ||
float & | real, | ||
float & | imag | ||
) | const [inline, virtual] |
Implements FFTCacheReader.
Definition at line 88 of file FFTMemoryCache.h.
References getMagnitudeAt(), getPhaseAt(), m_fimag, m_freal, m_storageType, and FFTCache::Rectangular.
void FFTMemoryCache::getMagnitudesAt | ( | int | x, |
float * | values, | ||
int | minbin, | ||
int | count, | ||
int | step | ||
) | const [inline, virtual] |
Implements FFTCacheReader.
Definition at line 101 of file FFTMemoryCache.h.
References m_factor, m_fimag, m_fmagnitude, m_freal, m_magnitude, m_storageType, FFTCache::Polar, and FFTCache::Rectangular.
bool FFTMemoryCache::haveSetColumnAt | ( | int | x | ) | const [inline, virtual] |
Implements FFTCacheReader.
Definition at line 122 of file FFTMemoryCache.h.
References ResizeableBitset::get(), m_colset, and m_colsetLock.
void FFTMemoryCache::setColumnAt | ( | int | x, |
float * | mags, | ||
float * | phases, | ||
float | factor | ||
) | [virtual] |
Implements FFTCacheWriter.
Definition at line 132 of file FFTMemoryCache.cpp.
References m_colset, m_colsetLock, m_fimag, m_freal, m_height, m_storageType, FFTCache::Rectangular, ResizeableBitset::set(), setMagnitudeAt(), setNormalizationFactor(), and setPhaseAt().
Referenced by setColumnAt().
void FFTMemoryCache::setColumnAt | ( | int | x, |
float * | reals, | ||
float * | imags | ||
) | [virtual] |
Implements FFTCacheWriter.
Definition at line 157 of file FFTMemoryCache.cpp.
References FFTCache::Compact, m_colset, m_colsetLock, m_factor, m_fimag, m_freal, m_height, m_storageType, FFTCache::Polar, FFTCache::Rectangular, ResizeableBitset::set(), and setColumnAt().
void FFTMemoryCache::allColumnsWritten | ( | ) | [inline, virtual] |
Implements FFTCacheWriter.
Definition at line 133 of file FFTMemoryCache.h.
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.
FFTCache::StorageType FFTMemoryCache::getStorageType | ( | ) | const [inline, virtual] |
Implements FFTCacheReader.
Definition at line 138 of file FFTMemoryCache.h.
References m_storageType.
void FFTMemoryCache::initialise | ( | ) | [private] |
Definition at line 70 of file FFTMemoryCache.cpp.
References FFTCache::Compact, m_colset, m_factor, m_fimag, m_fmagnitude, m_fphase, m_freal, m_height, m_magnitude, m_phase, m_storageType, m_width, FFTCache::Polar, and ResizeableBitset::resize().
Referenced by FFTMemoryCache().
void FFTMemoryCache::setNormalizationFactor | ( | int | x, |
float | factor | ||
) | [inline, private] |
Definition at line 156 of file FFTMemoryCache.h.
References m_factor, and m_width.
Referenced by setColumnAt().
void FFTMemoryCache::setMagnitudeAt | ( | int | x, |
int | y, | ||
float | mag | ||
) | [inline, private] |
Definition at line 160 of file FFTMemoryCache.h.
References m_factor, and setNormalizedMagnitudeAt().
Referenced by setColumnAt().
void FFTMemoryCache::setNormalizedMagnitudeAt | ( | int | x, |
int | y, | ||
float | norm | ||
) | [inline, private] |
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().
void FFTMemoryCache::setPhaseAt | ( | int | x, |
int | y, | ||
float | phase | ||
) | [inline, private] |
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().
void FFTMemoryCache::initialise | ( | uint16_t **& | array | ) | [private] |
Definition at line 104 of file FFTMemoryCache.cpp.
void FFTMemoryCache::initialise | ( | float **& | array | ) | [private] |
Definition at line 118 of file FFTMemoryCache.cpp.
int FFTMemoryCache::m_width [private] |
Definition at line 141 of file FFTMemoryCache.h.
Referenced by FFTMemoryCache(), getWidth(), initialise(), setNormalizationFactor(), setNormalizedMagnitudeAt(), setPhaseAt(), and ~FFTMemoryCache().
int FFTMemoryCache::m_height [private] |
Definition at line 142 of file FFTMemoryCache.h.
Referenced by FFTMemoryCache(), getHeight(), initialise(), setColumnAt(), setNormalizedMagnitudeAt(), and setPhaseAt().
uint16_t** FFTMemoryCache::m_magnitude [private] |
Definition at line 143 of file FFTMemoryCache.h.
Referenced by getMagnitudesAt(), getNormalizedMagnitudeAt(), initialise(), setNormalizedMagnitudeAt(), and ~FFTMemoryCache().
uint16_t** FFTMemoryCache::m_phase [private] |
Definition at line 144 of file FFTMemoryCache.h.
Referenced by getPhaseAt(), initialise(), setPhaseAt(), and ~FFTMemoryCache().
float** FFTMemoryCache::m_fmagnitude [private] |
Definition at line 145 of file FFTMemoryCache.h.
Referenced by getMagnitudesAt(), getNormalizedMagnitudeAt(), initialise(), setNormalizedMagnitudeAt(), and ~FFTMemoryCache().
float** FFTMemoryCache::m_fphase [private] |
Definition at line 146 of file FFTMemoryCache.h.
Referenced by getPhaseAt(), initialise(), setPhaseAt(), and ~FFTMemoryCache().
float** FFTMemoryCache::m_freal [private] |
Definition at line 147 of file FFTMemoryCache.h.
Referenced by getMagnitudeAt(), getMagnitudesAt(), getPhaseAt(), getValuesAt(), initialise(), setColumnAt(), and ~FFTMemoryCache().
float** FFTMemoryCache::m_fimag [private] |
Definition at line 148 of file FFTMemoryCache.h.
Referenced by getMagnitudeAt(), getMagnitudesAt(), getPhaseAt(), getValuesAt(), initialise(), setColumnAt(), and ~FFTMemoryCache().
float* FFTMemoryCache::m_factor [private] |
Definition at line 149 of file FFTMemoryCache.h.
Referenced by getMagnitudeAt(), getMagnitudesAt(), getMaximumMagnitudeAt(), getNormalizedMagnitudeAt(), initialise(), setColumnAt(), setMagnitudeAt(), setNormalizationFactor(), and ~FFTMemoryCache().
Definition at line 150 of file FFTMemoryCache.h.
Referenced by FFTMemoryCache(), getMagnitudeAt(), getMagnitudesAt(), getNormalizedMagnitudeAt(), getPhaseAt(), getStorageType(), getValuesAt(), initialise(), setColumnAt(), setNormalizedMagnitudeAt(), and setPhaseAt().
ResizeableBitset FFTMemoryCache::m_colset [private] |
Definition at line 151 of file FFTMemoryCache.h.
Referenced by haveSetColumnAt(), initialise(), and setColumnAt().
QReadWriteLock FFTMemoryCache::m_colsetLock [mutable, private] |
Definition at line 152 of file FFTMemoryCache.h.
Referenced by haveSetColumnAt(), and setColumnAt().