arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AudioKissFFT Class Reference

AudioFFT using FFTReal. The only specific functionality is the access to the dataArray. More...

#include <AudioKissFFT.h>

Inheritance diagram for AudioKissFFT:
AudioFFTBase AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

Public Member Functions

 AudioKissFFT ()
 
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 ()
 
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.
 
AudioFFTConfigconfig ()
 Provides the actual configuration.
 
kiss_fft_cpxdataArray ()
 Provides the complex array returned by the FFT

 
AudioFFTConfig defaultConfig (RxTxMode mode=TX_MODE)
 Provides the default configuration.
 
FFTDriverdriver ()
 
FFTDriverKissFFTdriverEx ()
 
void end () override
 Release the allocated memory.
 
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.
 
bool getBin (int pos, FFTBin &bin)
 gets the value of a bin
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
int length ()
 The number of samples.
 
float magnitude (int bin)
 
float magnitudeFast (int bin)
 
floatmagnitudes ()
 
floatmagnitudesFast ()
 
 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.
 
template<typename T >
Treference ()
 Provides the reference pointer.
 
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
 
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 setWriteBufferSize (int size)
 
int size ()
 The number of bins used by the FFT which are relevant for the result.
 
floattoMEL (int n_bins, float min_freq=0.0f, float max_freq=0.0f)
 Convert the FFT result to MEL spectrum.
 
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)
 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="")
 
void notifyAudioChange (AudioInfo info)
 
template<typename T >
void processSamples (const void *data, size_t count)
 
void refillReadBuffer ()
 
void rfft ()
 reverse fft
 
void rfftWriteData (BaseBuffer< uint8_t > &data)
 write reverse fft result to buffer to make it available for readBytes
 
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)
 

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< floatl_magnitudes {0}
 
Vector< floatmel_bins {0}
 
Vector< AudioInfoSupport * > notify_vector
 
FFTDriverp_driver = nullptr
 
FFTInverseOverlapAdder rfft_add {0}
 
RingBuffer< uint8_trfft_data {0}
 
Vector< floatstep_data {0}
 
SingleBuffer< uint8_tstride_buffer {0}
 
unsigned long timestamp = 0l
 
unsigned long timestamp_begin = 0l
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

AudioFFT using FFTReal. The only specific functionality is the access to the dataArray.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ AudioKissFFT()

AudioKissFFT ( )
inline

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

int available ( )
inlineoverridevirtualinherited

Data available for reverse fft.

Reimplemented from BaseStream.

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtualinherited

We try to fill the buffer at once.

Reimplemented from BaseStream.

◆ begin() [1/2]

bool begin ( )
inlineoverridevirtualinherited

starts the processing

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( AudioFFTConfig  info)
inlineinherited

starts the processing

◆ bytesPerSample()

int bytesPerSample ( )
inlineprotectedinherited

◆ clearBins()

void clearBins ( )
inlineinherited

clears the fft data

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ config()

AudioFFTConfig & config ( )
inlineinherited

Provides the actual configuration.

◆ dataArray()

kiss_fft_cpx * dataArray ( )
inline

Provides the complex array returned by the FFT

◆ defaultConfig()

AudioFFTConfig defaultConfig ( RxTxMode  mode = TX_MODE)
inlineinherited

Provides the default configuration.

◆ driver()

FFTDriver * driver ( )
inlineinherited

provides access to the FFTDriver which implements the basic FFT functionality

◆ driverEx()

FFTDriverKissFFT * driverEx ( )
inline

◆ end()

void end ( )
inlineoverridevirtualinherited

Release the allocated memory.

Reimplemented from BaseStream.

◆ fft()

template<typename T >
void fft ( )
inlineprotectedinherited

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ frequency()

float frequency ( int  bin)
inlineinherited

Determines the frequency of the indicated bin.

◆ frequencyToBin()

int frequencyToBin ( int  freq)
inlineinherited

Determine the bin number from the frequency.

◆ fromMEL()

bool fromMEL ( float values,
int  n_bins,
float  min_freq = 0.0f,
float  max_freq = 0.0f 
)
inlineinherited

Convert MEL spectrum back to linear frequency spectrum.

Parameters
valuesPointer to MEL spectrum values
n_binsNumber of MEL bins
Returns
bool Success status

◆ getBin()

bool getBin ( int  pos,
FFTBin bin 
)
inlineinherited

gets the value of a bin

◆ insertSorted()

template<int N>
void insertSorted ( AudioFFTResult(&)  result[N],
AudioFFTResult  tmp 
)
inlineprotectedinherited

make sure that we do not reuse already found results

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isPowerOfTwo()

bool isPowerOfTwo ( uint16_t  x)
inlineprotectedinherited

◆ length()

int length ( )
inlineinherited

The number of samples.

◆ magnitude()

float magnitude ( int  bin)
inlineinherited

Calculates the magnitude of the fft result to determine the max value (bin is 0 to size())

◆ magnitudeFast()

float magnitudeFast ( int  bin)
inlineinherited

◆ magnitudes()

float * magnitudes ( )
inlineinherited

Provides the magnitudes as array of size size(). Please note that this method is allocating additinal memory!

◆ magnitudesFast()

float * magnitudesFast ( )
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!

◆ not_supported()

virtual int not_supported ( int  out,
const char msg = "" 
)
inlineprotectedvirtualinherited

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

operator bool ( )
inlineoverridevirtualinherited

Reimplemented from AudioStream.

◆ phase()

float phase ( int  bin)
inlineinherited

calculates the phase

◆ processSamples()

template<typename T >
void processSamples ( const void data,
size_t  count 
)
inlineprotectedinherited

◆ readBytes()

size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtualinherited

Provides the result of a reverse FFT.

Reimplemented from AudioStream.

◆ readSilence()

virtual size_t readSilence ( uint8_t buffer,
size_t  length 
)
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ reference()

template<typename T >
T & reference ( )
inlineinherited

Provides the reference pointer.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ reset()

void reset ( )
inlineinherited

Just resets the current_pos e.g. to start a new cycle.

◆ result()

AudioFFTResult result ( )
inlineinherited

Determines the result values in the max magnitude bin.

◆ resultArray()

template<int N>
void resultArray ( AudioFFTResult(&)  result[N])
inlineinherited

Determines the N biggest result values.

◆ resultTime()

unsigned long resultTime ( )
inlineinherited

time after the fft: time when the last result was provided - you can poll this to check if we have a new result

◆ resultTimeBegin()

unsigned long resultTimeBegin ( )
inlineinherited

time before the fft

◆ rfft()

void rfft ( )
inlineprotectedinherited

reverse fft

◆ rfftWriteData()

void rfftWriteData ( BaseBuffer< uint8_t > &  data)
inlineprotectedinherited

write reverse fft result to buffer to make it available for readBytes

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  info)
inlineoverridevirtualinherited

Notify change of audio information.

Reimplemented from AudioStream.

◆ setBin() [1/2]

bool setBin ( int  idx,
float  real,
float  img 
)
inlineinherited

sets the value of a bin

◆ setBin() [2/2]

bool setBin ( int  pos,
FFTBin bin 
)
inlineinherited

sets the value of a bin

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active)

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ size()

int size ( )
inlineinherited

The number of bins used by the FFT which are relevant for the result.

◆ toMEL()

float * toMEL ( int  n_bins,
float  min_freq = 0.0f,
float  max_freq = 0.0f 
)
inlineinherited

Convert the FFT result to MEL spectrum.

◆ windowedSample()

template<typename T >
T windowedSample ( T  sample,
int  pos 
)
inlineprotectedinherited

◆ write() [1/2]

size_t write ( const uint8_t data,
size_t  len 
)
inlineoverridevirtualinherited

Provide the audio data as FFT input.

Reimplemented from AudioStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

◆ writeIFFT()

template<typename T >
void writeIFFT ( float data,
int  len 
)
inlineprotectedinherited

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes len bytes of silence (=0).

◆ writeStrideBuffer()

bool writeStrideBuffer ( uint8_t buffer,
size_t  len 
)
inlineprotectedinherited

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ bins

int bins = 0
protectedinherited

◆ cfg

AudioFFTConfig cfg
protectedinherited

◆ current_pos

int current_pos = 0
protectedinherited

◆ has_rfft_data

bool has_rfft_data = false
protectedinherited

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ l_magnitudes

Vector<float> l_magnitudes {0}
protectedinherited

◆ mel_bins

Vector<float> mel_bins {0}
protectedinherited

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_driver

FFTDriver* p_driver = nullptr
protectedinherited

◆ rfft_add

FFTInverseOverlapAdder rfft_add {0}
protectedinherited

◆ rfft_data

RingBuffer<uint8_t> rfft_data {0}
protectedinherited

◆ step_data

Vector<float> step_data {0}
protectedinherited

◆ stride_buffer

SingleBuffer<uint8_t> stride_buffer {0}
protectedinherited

◆ timestamp

unsigned long timestamp = 0l
protectedinherited

◆ timestamp_begin

unsigned long timestamp_begin = 0l
protectedinherited

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

The documentation for this class was generated from the following file: