Performs a fast fourier transform.
This is only a simple low-footprint implementation and isn't tuned for speed - it may be useful for simple applications where one of the more complex FFT libraries would be overkill. (But in the future it may end up becoming optimised of course...)
The FFT class itself contains lookup tables, so there's some overhead in creating one, you should create and cache an FFT object for each size/direction of transform that you need, and re-use them to perform the actual operation.
void dsp::FFT::performRealOnlyForwardTransform |
( |
float * |
inputOutputData, |
|
|
bool |
onlyCalculateNonNegativeFrequencies = false |
|
) |
| const |
|
noexcept |
Performs an in-place forward transform on a block of real data.
As the coefficients of the negative frequencies (frequencies higher than N/2 or pi) are the complex conjugate of their positive counterparts, it may not be necessary to calculate them for your particular application. You can use onlyCalculateNonNegativeFrequencies to let the FFT engine know that you do not plan on using them. Note that this is only a hint: some FFT engines (currently only the Fallback engine), will still calculate the negative frequencies even if onlyCalculateNonNegativeFrequencies is true.
The size of the array passed in must be 2 * getSize(), and the first half should contain your raw input sample data. On return, if onlyCalculateNonNegativeFrequencies is false, the array will contain size complex real + imaginary parts data interleaved. If onlyCalculateNonNegativeFrequencies is true, the array will contain at least (size / 2) + 1 complex numbers. Both outputs can be passed to performRealOnlyInverseTransform() in order to convert it back to reals.
void dsp::FFT::performFrequencyOnlyForwardTransform |
( |
float * |
inputOutputData, |
|
|
bool |
onlyCalculateNonNegativeFrequencies = false |
|
) |
| const |
|
noexcept |
Takes an array and simply transforms it to the magnitude frequency response spectrum.
This may be handy for things like frequency displays or analysis. The size of the array passed in must be 2 * getSize().
On return, if onlyCalculateNonNegativeFrequencies is false, the array will contain size magnitude values. If onlyCalculateNonNegativeFrequencies is true, the array will contain at least size / 2 + 1 magnitude values.