Short-time Fourier transform. More...
#include <DFT.h>
Public Member Functions | |
STFT (uint32_t winSize=1024, uint32_t hopSize=256, uint32_t padSize=0, WindowType winType=RECTANGLE, SpectralType specType=COMPLEX, uint32_t numAux=0) | |
bool | operator() (float input) |
Input next time-domain sample. | |
void | forward (const float *src) |
Perform forward transform of an array of samples. | |
virtual void | inverse (float *dst) |
Get inverse transform using current spectral frame. | |
void | resize (uint32_t winSize, uint32_t padSize) |
Set window and zero-padding size, in samples. | |
STFT & | inverseWindowing (bool v) |
Whether to apply a triangular window to inverse transform samples. | |
STFT & | rotateForward (bool v) |
Whether to rotate input samples by half. | |
STFT & | sizeHop (uint32_t size) |
Set hop size, in samples. | |
STFT & | windowType (WindowType type) |
Set window type. | |
float * | phases () |
Returns array of phases if the sample data type is MAG_FREQ. | |
DFT & | spectrumType (SpectralType v) |
Set format of spectrum data. | |
DFT & | precise (bool whether) |
Set whether to use precise (but slower) for converting to polar. | |
float | freqRes () const |
Get frequency resolution of analysis. | |
float | overlap () const |
Get transform overlap factor. | |
bool | overlapping () const |
Whether the transform is overlapping. | |
uint32_t | sizeHop () const |
Get size of hop. | |
uint32_t | sizePad () const |
Get size of zero-padding. | |
uint32_t | sizeWin () const |
Get size of window. | |
Sync & | syncHop () |
Hop rate synchronizer. | |
float | operator() () |
Returns next sample from inverse transform. | |
bool | inverseOnNext () |
Returns true if next call to inverse() will perform the inverse transform. | |
void | zero () |
Zeroes internal frequency bins. | |
void | zeroEnds () |
Zeroes DC and Nyquist bins. | |
virtual void | onResync (double r) |
Called by my Sync reference after it changes its value. | |
float * | aux (uint32_t num) |
Get pointer to an auxiliary buffer. | |
Complex< float > * | bins () const |
Get pointer to bin data. | |
Complex< float > & | bin (uint32_t k) |
Get reference to bin value. | |
const Complex< float > & | bin (uint32_t k) const |
Get read-only reference to bin value. | |
double | binFreq () const |
Get width of frequency bins. | |
uint32_t | numBins () const |
Get number of frequency bins. | |
uint32_t | sizeDFT () const |
Get size of forward transform. | |
Sync & | syncFreq () |
Get frequency domain synchronizer. | |
void | numAux (uint32_t num) |
Sets number of auxilliary buffers, each of size numBins() | |
double | scaleSPU () const |
Returns ratio of my SPU to my Sync's SPU. | |
void | scaleSPU (double v) |
Scales samples/unit by factor. | |
double | spu () const |
Returns local samples/unit. | |
void | spu (double v) |
Set local samples/unit. | |
double | ups () const |
Returns local units/sample. | |
void | ups (double v) |
Set local units/sample. | |
const Sync * | sync () const |
Returns reference to my Sync. | |
void | sync (Sync &src) |
Set absolute Sync source. | |
void | scaleUPS (double v) |
Scales units/sample by factor. | |
void | nodeInsertL (Synced &node) |
Insert myself to left of node. | |
void | nodeInsertR (Synced &node) |
Insert myself to right of node. | |
void | nodeRemove () |
Remove myself from linked list. | |
Public Attributes | |
Synced * | nodeL |
Pointer to left node. | |
Synced * | nodeR |
Pointer to right node. | |
Protected Member Functions | |
void | initSynced () |
To be called from the constructor(s) of derived classes. |
Short-time Fourier transform.
The short-time Fourier transform uses a sliding window during analysis to obtain better time resolution between successive spectral frames. The resolution within each individual spectral frame is still determined by the window size.
STFT | ( | uint32_t | winSize = 1024 , |
uint32_t | hopSize = 256 , |
||
uint32_t | padSize = 0 , |
||
WindowType | winType = RECTANGLE , |
||
SpectralType | specType = COMPLEX , |
||
uint32_t | numAux = 0 |
||
) |
[in] | winSize | Number of samples to window |
[in] | hopSize | Number of samples between successive windows |
[in] | padSize | Number of zeros to append to window |
[in] | winType | Type of forward transform window |
[in] | specType | Format of spectrum data |
[in] | numAux | Number of auxiliary buffers to create |
bool inverseOnNext | ( | ) | [inherited] |
Returns true if next call to inverse() will perform the inverse transform.
This method is used for doing inverse-only transforms. Basically, it tells you when you should set the frequency samples.
void onResync | ( | double | ratioSPU | ) | [virtual, inherited] |
Called by my Sync reference after it changes its value.
Any instance state that depends on the sampling length should be updated here.
Reimplemented from DFTBase< float >.
float operator() | ( | ) | [inherited] |
Returns next sample from inverse transform.
The inverse transform is performed every sizeWin() samples.
bool operator() | ( | float | input | ) |
Input next time-domain sample.
Reimplemented from DFT.