arduino-audio-tools
|
Executes FFT using audio data. The Driver which is passed in the constructor selects a specifc FFT implementation. More...
#include <AudioFFT.h>
Public Member Functions | |
AudioFFTBase (FFTDriver *driver) | |
Default Constructor. The len needs to be of the power of 2 (e.g. 512, 1024, 2048, 4096, 8192) | |
virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
Adds target to be notified about audio changes. | |
virtual AudioInfo | audioInfo () override |
provides the actual input AudioInfo | |
virtual AudioInfo | audioInfoOut () |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream | |
int | availableForWrite () override |
We try to fill the buffer at once. | |
bool | begin () override |
starts the processing | |
bool | begin (AudioFFTConfig info) |
starts the processing | |
virtual bool | begin (AudioInfo info) |
virtual void | clearNotifyAudioChange () |
Deletes all change notify subscriptions. | |
AudioFFTConfig & | config () |
Provides the actual configuration. | |
AudioFFTConfig | defaultConfig () |
Provides the default configuration. | |
FFTDriver * | driver () |
provides access to the FFTDriver which implements the basic FFT functionality | |
void | end () override |
Release the allocated memory. | |
virtual void | flush () |
float | frequency (int bin) |
Determines the frequency of the indicated bin. | |
bool | getBin (int pos, FFTBin &bin) |
gets the value of a bin | |
virtual bool | isDeletable () |
If true we need to release the related memory in the destructor. | |
bool | isInverseFFT () |
Returns true if we need to calculate the inverse FFT. | |
bool | isNotifyActive () |
Checks if the automatic AudioInfo update is active. | |
int | length () |
The number of samples. | |
float | magnitude (int bin) |
Calculates the magnitude of the fft result to determine the max value (bin is 0 to size()) | |
float | magnitudeFast (int bin) |
float * | magnitudes () |
Provides the magnitudes as array of size size(). Please note that this method is allocating additinal memory! | |
float * | magnitudesFast () |
Provides the magnitudes w/o calling the square root function as array of size size(). Please note that this method is allocating additinal memory! | |
operator bool () | |
virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
Removes a target in order not to be notified about audio changes. | |
void | reset () |
Just resets the current_pos e.g. to start a new cycle. | |
AudioFFTResult | result () |
Determines the result values in the max magnitude bin. | |
template<int N> | |
void | resultArray (AudioFFTResult(&result)[N]) |
Determines the N biggest result values. | |
unsigned long | resultTime () |
time after the fft: time when the last result was provided - you can poll this to check if we have a new result | |
unsigned long | resultTimeBegin () |
time before the fft | |
void | setAudioInfo (AudioInfo info) override |
Notify change of audio information. | |
bool | setBin (int idx, float real, float img) |
sets the value of a bin | |
bool | setBin (int pos, FFTBin &bin) |
sets the value of a bin | |
void | setNotifyActive (bool flag) |
Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
void | setOutput (Print &out) |
Define final output for reverse ffft. | |
int | size () |
The number of bins used by the FFT which are relevant for the result. | |
size_t | write (const uint8_t *data, size_t len) override |
Provide the audio data as FFT input. | |
virtual size_t | write (uint8_t ch) override |
virtual void | writeSilence (size_t len) |
Protected Member Functions | |
int | bytesPerSample () |
template<typename T > | |
void | fft () |
template<int N> | |
void | insertSorted (AudioFFTResult(&result)[N], AudioFFTResult tmp) |
make sure that we do not reuse already found results | |
bool | isPowerOfTwo (uint16_t x) |
void | notifyAudioChange (AudioInfo info) |
template<typename T > | |
void | processSamples (const void *data, size_t samples) |
void | rfft () |
reverse fft if necessary | |
template<typename T > | |
T | windowedSample (T sample) |
void | writeStrideBuffer (uint8_t *buffer, size_t len) |
Protected Attributes | |
int | _timeout = 10 |
int | bins = 0 |
AudioFFTConfig | cfg |
int | current_pos = 0 |
bool | is_active = false |
bool | is_notify_active = true |
Vector< AudioInfoSupport * > | notify_vector |
FFTDriver * | p_driver =nullptr |
float * | p_magnitudes = nullptr |
Print * | p_out = nullptr |
float | rfft_max = 0 |
RingBuffer< uint8_t > | stride_buffer {0} |
unsigned long | timestamp =0l |
unsigned long | timestamp_begin =0l |
SingleBuffer< uint8_t > | tmp {MAX_SINGLE_CHARS} |
int | tmpPos = 0 |
Executes FFT using audio data. The Driver which is passed in the constructor selects a specifc FFT implementation.
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, MP3DecoderMAD, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, MP3DecoderHelix, OggContainerDecoder, Pipeline, and Pipeline::ModifyingStreamAdapter.
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in AdapterPrintToAudioOutput, and AdapterAudioStreamToAudioOutput.
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in PureDataStream, PWMAudioOutput, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, and ResampleStream.
|
inlineoverridevirtual |
We try to fill the buffer at once.
Reimplemented from AudioOutput.
|
inlineoverridevirtual |
starts the processing
Reimplemented from AudioOutput.
Reimplemented in AudioESP32ULP, CsvOutput< T >, and EncodedAudioOutput.
|
inlineoverridevirtual |
Release the allocated memory.
Reimplemented from AudioOutput.
If true we need to release the related memory in the destructor.
Reimplemented in AdapterPrintToAudioOutput, and AdapterAudioStreamToAudioOutput.
Reimplemented from AudioOutput.
Notify change of audio information.
Reimplemented from AudioOutput.
Provide the audio data as FFT input.
Implements AudioOutput.
Reimplemented in OversamplingDAC.
Writes n 0 values (= silence)
len |