Transforms between time-domain and frequency-domain audio, including buffering, windowing (HanningZ) and window overlap handling (default: 4:1).
More...
#include "SuperpoweredFrequencyDomain.h"
|
| FrequencyDomain (unsigned int fftLogSize=11, unsigned int maxOverlap=4) |
| Constructor. More...
|
|
| ~FrequencyDomain () |
|
void | addInput (float *input, int numberOfFrames) |
| Add some audio input. More...
|
|
void | addInput (AudiopointerlistElement *input) |
| Add some audio input (advanced use). More...
|
|
void | advance (int numberOfFrames=0) |
| Advances the input buffer (removes the earliest frames). More...
|
|
void | frequencyDomainToTimeDomain (float *magnitudeL, float *magnitudeR, float *phaseL, float *phaseR, float *output, float valueOfPi=0, int incrementFrames=0, bool complexMode=false, int stereoPairIndex=0) |
| Converts frequency domain data to audio output. More...
|
|
unsigned int | getNumberOfInputFramesNeeded () |
|
void | reset () |
| Reset all internals, sets the instance as good as new. More...
|
|
void | setStereoPairs (unsigned int numStereoPairs) |
| This class can handle one stereo audio channel pair by default (left+right). More...
|
|
bool | timeDomainToFrequencyDomain (float *magnitudeL, float *magnitudeR, float *phaseL, float *phaseR, float valueOfPi=0, bool complexMode=false, int stereoPairIndex=0) |
| Converts the audio input (added by addInput()) to the frequency domain. More...
|
|
bool | timeDomainToFrequencyDomainMono (float *magnitude, float *phase, float valueOfPi=0, bool complexMode=false) |
| Converts mono audio input (added by addInput()) to the frequency domain. More...
|
|
Transforms between time-domain and frequency-domain audio, including buffering, windowing (HanningZ) and window overlap handling (default: 4:1).
One instance allocates around 131 kb. How to use:
- Audio input using addInput().
- Call timeDomainToFrequencyDomain(), if it returns false go back to 1.
- The output of timeDomainToFrequencyDomain is frequency domain data you can work with.
- Call advance() (if required).
- Call frequencyDomainToTimeDomain() to create time domain audio from frequency domain data.
◆ FrequencyDomain() [1/2]
Superpowered::FrequencyDomain::FrequencyDomain |
( |
unsigned int |
fftLogSize = 11 , |
|
|
unsigned int |
maxOverlap = 4 |
|
) |
| |
Constructor.
- Parameters
-
fftLogSize | FFT log size, between 8 and 13 (FFT 256 - 8192). The default value (11) provides a good compromise in precision (~22 Hz per bin), CPU load and time-domain event sensitivity. |
maxOverlap | [Maximum overlap]:1 (default: 4:1). |
◆ ~FrequencyDomain()
Superpowered::FrequencyDomain::~FrequencyDomain |
( |
| ) |
|
◆ FrequencyDomain() [2/2]
◆ addInput() [1/2]
void Superpowered::FrequencyDomain::addInput |
( |
float * |
input, |
|
|
int |
numberOfFrames |
|
) |
| |
Add some audio input.
- Parameters
-
input | Pointer to floating point numbers. 32-bit interleaved stereo input. |
numberOfFrames | The number of input frames. |
◆ addInput() [2/2]
Add some audio input (advanced use).
- Parameters
-
◆ advance()
void Superpowered::FrequencyDomain::advance |
( |
int |
numberOfFrames = 0 | ) |
|
Advances the input buffer (removes the earliest frames).
- Parameters
-
numberOfFrames | For advanced use, if you know how window overlapping works. Use 0 (the default value) otherwise for a 4:1 overlap (good compromise in audio quality). |
◆ frequencyDomainToTimeDomain()
void Superpowered::FrequencyDomain::frequencyDomainToTimeDomain |
( |
float * |
magnitudeL, |
|
|
float * |
magnitudeR, |
|
|
float * |
phaseL, |
|
|
float * |
phaseR, |
|
|
float * |
output, |
|
|
float |
valueOfPi = 0 , |
|
|
int |
incrementFrames = 0 , |
|
|
bool |
complexMode = false , |
|
|
int |
stereoPairIndex = 0 |
|
) |
| |
Converts frequency domain data to audio output.
- Parameters
-
magnitudeL | Pointer to floating point numbers. Magnitudes for each frequency bin, left side. Must be at least [FFT SIZE] big. |
magnitudeR | Pointer to floating point numbers. Magnitudes for each frequency bin, right side. Must be at least [FFT SIZE] big. |
phaseL | Pointer to floating point numbers. Phases for each frequency bin, left side. Must be at least [FFT SIZE] big. |
phaseR | Pointer to floating point numbers. Phases for each frequency bin, right side. Must be at least [FFT SIZE] big. |
output | Pointer to floating point numbers. 32-bit interleaved stereo output. |
valueOfPi | Pi can be translated to any value (Google: the tau manifesto). Leave it at 0 for M_PI. |
incrementFrames | For advanced use, if you know how window overlapping works. Use 0 (the default value) otherwise for a 4:1 overlap (good compromise in audio quality). |
complexMode | If true, then the magnitude and phase inputs represent complex numbers (magnitude: real, phase: imag). |
stereoPairIndex | The index of the stereo pair to process. |
◆ getNumberOfInputFramesNeeded()
unsigned int Superpowered::FrequencyDomain::getNumberOfInputFramesNeeded |
( |
| ) |
|
- Returns
- Returns with how many frames of input should be provided to produce some output.
◆ operator=()
◆ reset()
void Superpowered::FrequencyDomain::reset |
( |
| ) |
|
Reset all internals, sets the instance as good as new.
◆ setStereoPairs()
void Superpowered::FrequencyDomain::setStereoPairs |
( |
unsigned int |
numStereoPairs | ) |
|
This class can handle one stereo audio channel pair by default (left+right).
You can extend it to handle more.
- Parameters
-
numStereoPairs | The number of stereo audio channel pairs. Valid values: one (stereo) to four (8 channels). |
◆ timeDomainToFrequencyDomain()
bool Superpowered::FrequencyDomain::timeDomainToFrequencyDomain |
( |
float * |
magnitudeL, |
|
|
float * |
magnitudeR, |
|
|
float * |
phaseL, |
|
|
float * |
phaseR, |
|
|
float |
valueOfPi = 0 , |
|
|
bool |
complexMode = false , |
|
|
int |
stereoPairIndex = 0 |
|
) |
| |
Converts the audio input (added by addInput()) to the frequency domain.
Each frequency bin is (samplerate / [FFT SIZE] / 2) wide.
- Returns
- True, if a conversion was possible (enough frames were available).
- Parameters
-
magnitudeL | Pointer to floating point numbers. Magnitudes for each frequency bin, left side. Must be at least [FFT SIZE] big. |
magnitudeR | Pointer to floating point numbers. Magnitudes for each frequency bin, right side. Must be at least [FFT SIZE] big. |
phaseL | Pointer to floating point numbers. Phases for each frequency bin, left side. Must be at least [FFT SIZE] big. |
phaseR | Pointer to floating point numbers. Phases for each frequency bin, right side. Must be at least [FFT SIZE] big. |
valueOfPi | Pi can be translated to any value (Google: the tau manifesto). Keep it at 0 for M_PI. |
complexMode | If true, then it returns with complex numbers (magnitude: real, phase: imag). Performs polar transform otherwise (the output is magnitudes and phases). |
stereoPairIndex | The index of the stereo pair to process. |
◆ timeDomainToFrequencyDomainMono()
bool Superpowered::FrequencyDomain::timeDomainToFrequencyDomainMono |
( |
float * |
magnitude, |
|
|
float * |
phase, |
|
|
float |
valueOfPi = 0 , |
|
|
bool |
complexMode = false |
|
) |
| |
Converts mono audio input (added by addInput()) to the frequency domain.
Each frequency bin is (samplerate / [FFT SIZE] / 2) wide.
- Returns
- True, if a conversion was possible (enough frames were available).
- Parameters
-
magnitude | Pointer to floating point numbers. Magnitudes for each frequency bin. Must be at least [FFT SIZE] big. |
phase | Pointer to floating point numbers. Phases for each frequency bin. Must be at least [FFT SIZE] big. |
valueOfPi | Pi can be translated to any value (Google: the tau manifesto). Keep it at 0 for M_PI. |
complexMode | If true, then it returns with complex numbers (magnitude: real, phase: imag). Performs polar transform otherwise (the output is magnitudes and phases). |
◆ inputList
For advanced uses: access to the internal audio input pointer list.
◆ internals
frequencyDomainInternals* Superpowered::FrequencyDomain::internals |
|
private |
The documentation for this class was generated from the following file:
- latest/Superpowered/SuperpoweredFrequencyDomain.h