|
arduino-audio-tools
|
AudioFFT using RealFFT. More...
#include <AudioRealFFT.h>
Public Member Functions | |
| AudioRealFFT () | |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| virtual AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| virtual AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| virtual AudioInfo | audioInfoOut () |
| virtual AudioInfo | audioInfoOut () |
| int | available () override |
| Data available for reverse fft. | |
| int | availableForWrite () override |
| We try to fill the buffer at once. | |
| bool | begin () override |
| starts the processing | |
| bool | begin (AudioFFTConfig info) |
| starts the processing | |
| void | clearBins () |
| clears the fft data | |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| AudioFFTConfig & | config () |
| Provides the actual configuration. | |
| AudioFFTConfig | defaultConfig (RxTxMode mode=TX_MODE) |
| Provides the default configuration. | |
| FFTDriver * | driver () |
| FFTDriverRealFFT * | driverEx () |
| void | end () override |
| Release the allocated memory. | |
| virtual void | flush () override |
| virtual void | flush () override |
| float | frequency (int bin) |
| Determines the frequency of the indicated bin. | |
| int | frequencyToBin (int freq) |
| Determine the bin number from the frequency. | |
| bool | fromMEL (float *values, int n_bins, float min_freq=0.0f, float max_freq=0.0f) |
| Convert MEL spectrum back to linear frequency spectrum, using the same (cached) filterbank as toMEL(). | |
| bool | getBin (int pos, FFTBin &bin) |
| gets the value of a bin | |
| float * | imgArray () |
| Provides the complex array returned by the FFT. | |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| int | length () |
| The number of samples. | |
| float | magnitude (int bin) |
| float | magnitudeFast (int bin) |
| float * | magnitudes () |
| float * | magnitudesFast () |
| operator bool () override | |
| float | phase (int bin) |
| calculates the phase | |
| size_t | readBytes (uint8_t *data, size_t len) override |
| Provides the result of a reverse FFT. | |
| virtual size_t | readSilence (uint8_t *buffer, size_t length) |
| Source to generate silence: just sets the buffer to 0. | |
| virtual size_t | readSilence (uint8_t *buffer, size_t length) |
| Source to generate silence: just sets the buffer to 0. | |
| float * | realArray () |
| Provides the real array returned by the FFT. | |
| template<typename T> | |
| T & | reference () |
| Provides the reference pointer. | |
| virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
| Removes a target in order not to be notified about audio changes. | |
| 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 () |
| unsigned long | resultTimeBegin () |
| time before the fft | |
| virtual void | setAudioInfo (AudioInfo newInfo) override |
| Defines the input AudioInfo. | |
| 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 | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active). | |
| void | setWriteBufferSize (int size) |
| void | setWriteBufferSize (int size) |
| int | size () |
| The number of bins used by the FFT which are relevant for the result. | |
| float * | toMEL (int n_bins, float min_freq=0.0f, float max_freq=0.0f, bool power=false) |
| virtual size_t | write (uint8_t ch) override |
| size_t | write (const uint8_t *data, size_t len) override |
| Provide the audio data as FFT input. | |
| virtual void | writeSilence (size_t len) |
| Writes len bytes of silence (=0). | |
| virtual void | writeSilence (size_t len) |
| Writes len bytes of silence (=0). | |
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) |
| virtual int | not_supported (int out, const char *msg="") |
| virtual int | not_supported (int out, const char *msg="") |
| void | notifyAudioChange (AudioInfo info) |
| void | notifyAudioChange (AudioInfo info) |
| template<typename T> | |
| void | processSamples (const void *data, size_t count) |
| template<typename T> | |
| void | processStrideBuffer () |
| FFT of the full stride buffer, then drop stride samples. | |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read(). | |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read(). | |
| void | rfft () |
| reverse fft | |
| void | rfftWriteData (BaseBuffer< uint8_t > &data) |
| write reverse fft result to buffer to make it available for readBytes | |
| bool | updateMelFilterbank (int n_bins, float min_freq, float max_freq) |
| (Re)builds the cached sparse filterbank if any parameter changed | |
| template<typename T> | |
| T | windowedSample (T sample, int pos) |
| template<typename T> | |
| void | writeIFFT (float *data, int len) |
| bool | writeStrideBuffer (uint8_t *buffer, size_t len) |
Static Protected Member Functions | |
| static float | hzToMel (float hz) |
| static float | melToHz (float mel) |
Protected Attributes | |
| int | _timeout = 10 |
| int | bins = 0 |
| AudioFFTConfig | cfg |
| int | current_pos = 0 |
| bool | has_rfft_data = false |
| AudioInfo | info |
| bool | is_notify_active = true |
| Vector< float > | l_magnitudes {0} |
| Vector< float > | mel_bins {0} |
| Vector< MelFilter > | mel_filters {0} |
| int | mel_length = 0 |
| float | mel_max_freq = -1.0f |
| float | mel_min_freq = -1.0f |
| int | mel_n_bins = 0 |
| int | mel_sample_rate = 0 |
| Vector< float > | mel_weights {0} |
| Vector< AudioInfoSupport * > | notify_vector |
| FFTDriver * | p_driver = nullptr |
| FFTInverseOverlapAdder | rfft_add {0} |
| RingBuffer< uint8_t > | rfft_data {0} |
| Vector< float > | step_data {0} |
| SingleBuffer< uint8_t > | stride_buffer {0} |
| unsigned long | timestamp = 0l |
| unsigned long | timestamp_begin = 0l |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| int | write_buffer_size = 8 |
AudioFFT using RealFFT.
|
inline |
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in AdapterAudioOutputToAudioStream, AdapterAudioOutputToAudioStream, EncodedAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMerge< T >, InputMerge< T >, TimerCallbackAudioStream, TimerCallbackAudioStream, EncodedAudioStream, GeneratedSoundStream< T >, InputMerge< T >, JupyterAudioT< T >, JupyterAudioT< int16_t >, MozziStream, PureDataStream, and TimerCallbackAudioStream.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in AdapterAudioOutputToAudioStream, AdapterAudioOutputToAudioStream, EncodedAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMerge< T >, InputMerge< T >, TimerCallbackAudioStream, TimerCallbackAudioStream, EncodedAudioStream, GeneratedSoundStream< T >, InputMerge< T >, JupyterAudioT< T >, JupyterAudioT< int16_t >, MozziStream, PureDataStream, and TimerCallbackAudioStream.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in ChannelFormatConverterStream, ChannelFormatConverterStreamT< T >, FormatConverterStream, MP3EncoderShine, NumberFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, Pipeline, PureDataStream, PWMAudioOutput< PWMDriverT >, ResampleStream, ResampleStreamT< TInterpolator >, and SupportedRatesStream.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in ChannelFormatConverterStream, ChannelFormatConverterStreamT< T >, FormatConverterStream, MP3EncoderShine, NumberFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, Pipeline, PureDataStream, PWMAudioOutput< PWMDriverT >, ResampleStream, ResampleStreamT< TInterpolator >, and SupportedRatesStream.
|
inlineoverridevirtualinherited |
Data available for reverse fft.
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
We try to fill the buffer at once.
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
starts the processing
Reimplemented from BaseStream.
|
inlineinherited |
starts the processing
|
inlineprotectedinherited |
bytes per sample in the audio data: 24 bit samples use the int24_t representation (4 bytes unless USE_3BYTE_INT24 is defined)
|
inlineinherited |
clears the fft data
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >, RTSPClient< EthernetClient, EthernetUDP >, and RTSPClient< WiFiClient, WiFiUDP >.
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >, RTSPClient< EthernetClient, EthernetUDP >, and RTSPClient< WiFiClient, WiFiUDP >.
|
inlineinherited |
Provides the actual configuration.
|
inlineinherited |
Provides the default configuration.
|
inlineinherited |
provides access to the FFTDriver which implements the basic FFT functionality
|
inline |
|
inlineoverridevirtualinherited |
Release the allocated memory.
Reimplemented from BaseStream.
|
inlineprotectedinherited |
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in AudioStreamWrapper, AudioStreamWrapper, BufferedStream, BufferedStream, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, MemoryStream, MemoryStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, ReformatBaseStream, RingBufferStream, RingBufferStream, TimedStream, AudioEffectStream, AudioEffectStreamT< T >, AudioStreamWrapper, AutomaticGainControlStream, BufferedStream, BufferedTaskStream, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, FadeStream, FilteredStream< T, TF >, GeneratedSoundStream< T >, I2SStream, MeasuringStream, MemoryStream, Pipeline::ModifyingStreamAdapter, PureDataStream, QualityAnalysisStream, QueueStream< T >, ReformatBaseStream, ResampleStream, RingBufferStream, SupportedRatesStream, TimedStream, URLStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, URLStreamBufferedT< ICYStreamESP32 >, URLStreamBufferedT< URLStream >, URLStreamBufferedT< URLStreamESP32 >, and VolumeStream.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in AudioStreamWrapper, AudioStreamWrapper, BufferedStream, BufferedStream, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, MemoryStream, MemoryStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, ReformatBaseStream, RingBufferStream, RingBufferStream, TimedStream, AudioEffectStream, AudioEffectStreamT< T >, AudioStreamWrapper, AutomaticGainControlStream, BufferedStream, BufferedTaskStream, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, FadeStream, FilteredStream< T, TF >, GeneratedSoundStream< T >, I2SStream, MeasuringStream, MemoryStream, Pipeline::ModifyingStreamAdapter, PureDataStream, QualityAnalysisStream, QueueStream< T >, ReformatBaseStream, ResampleStream, RingBufferStream, SupportedRatesStream, TimedStream, URLStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, URLStreamBufferedT< ICYStreamESP32 >, URLStreamBufferedT< URLStream >, URLStreamBufferedT< URLStreamESP32 >, and VolumeStream.
|
inlineinherited |
Determines the frequency of the indicated bin.
|
inlineinherited |
Determine the bin number from the frequency.
|
inlineinherited |
Convert MEL spectrum back to linear frequency spectrum, using the same (cached) filterbank as toMEL().
| values | Pointer to MEL spectrum values |
| n_bins | Number of MEL bins |
|
inlineinherited |
gets the value of a bin
|
inlinestaticprotectedinherited |
|
inline |
Provides the complex array returned by the FFT.
|
inlineprotectedinherited |
make sure that we do not reuse already found results
|
inlineinherited |
Checks if the automatic AudioInfo update is active.
|
inlineinherited |
Checks if the automatic AudioInfo update is active.
|
inlineprotectedinherited |
|
inlineinherited |
The number of samples.
|
inlineinherited |
Calculates the magnitude of the fft result to determine the max value (bin is 0 to size())
|
inlineinherited |
|
inlineinherited |
Provides the magnitudes as array of size size(). Please note that this method is allocating additinal memory!
|
inlineinherited |
Provides the magnitudes w/o calling the square root function as array of size size(). Please note that this method is allocating additinal memory!
|
inlinestaticprotectedinherited |
|
inlineprotectedvirtualinherited |
|
inlineprotectedvirtualinherited |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlineoverridevirtualinherited |
Reimplemented from AudioStream.
|
inlineinherited |
calculates the phase
|
inlineprotectedinherited |
|
inlineprotectedinherited |
FFT of the full stride buffer, then drop stride samples.
|
inlineoverridevirtualinherited |
Provides the result of a reverse FFT.
Reimplemented from AudioStream.
|
inlinevirtualinherited |
Source to generate silence: just sets the buffer to 0.
|
inlinevirtualinherited |
Source to generate silence: just sets the buffer to 0.
|
inline |
Provides the real array returned by the FFT.
|
inlineinherited |
Provides the reference pointer.
|
inlineprotectedinherited |
Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().
|
inlineprotectedinherited |
Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read().
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
|
inlineinherited |
Just resets the current_pos e.g. to start a new cycle.
|
inlineinherited |
Determines the result values in the max magnitude bin.
|
inlineinherited |
Determines the N biggest result values.
|
inlineinherited |
time after the fft: time when the last result was provided - you can poll this to check if we have a new result
|
inlineinherited |
time before the fft
|
inlineprotectedinherited |
reverse fft
|
inlineprotectedinherited |
write reverse fft result to buffer to make it available for readBytes
|
inlineoverridevirtualinherited |
Defines the input AudioInfo.
Implements AudioInfoSupport.
Reimplemented in AdapterAudioOutputToAudioStream, AudioInputMonitor, AudioInputMonitor, CallbackStream, CallbackStream, EncodedAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, ProgressStream, ProgressStream, TimedStream, TimerCallbackAudioStream, TimerCallbackAudioStream, VolumeMeter, and VolumeMeter.
|
inlineoverrideinherited |
Notify change of audio information.
|
inlineinherited |
sets the value of a bin
|
inlineinherited |
sets the value of a bin
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active).
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active).
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
The number of bins used by the FFT which are relevant for the result.
|
inlineinherited |
Convert the FFT result to MEL spectrum. The triangular filterbank uses fractional (HTK style) weights, so no filter collapses to zero width, and it is computed once and cached until the parameters change.
|
inlineprotectedinherited |
(Re)builds the cached sparse filterbank if any parameter changed
|
inlineprotectedinherited |
|
inlineoverridevirtualinherited |
|
inlineoverridevirtualinherited |
Provide the audio data as FFT input.
Reimplemented from AudioStream.
|
inlineprotectedinherited |
|
inlinevirtualinherited |
Writes len bytes of silence (=0).
|
inlinevirtualinherited |
Writes len bytes of silence (=0).
|
inlineprotectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |