arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FFTDriverFixedFFT< CalcT > Class Template Reference

Driver for the fixedpoint-fft library (https://github.com/pschatzmann/fixedpoint-fft). CalcT selects the calculation type used by the underlying engine: int8_t/int16_t/int32_t for fixed point Qn math (smallest/fastest, ideal for plain AVR), or float/double on FPU-equipped targets (ESP32, Cortex-M4F/M7, desktop). Defaults to int16_t (Q15), which gives good precision at any FFT size without needing an FPU. The FFTDriver interface itself is always float, so values are rescaled into/out of CalcT's Qn range on the way in/out via fixedpoint_fft::fftConvertSample. More...

#include <AudioFixedFFT.h>

Inheritance diagram for FFTDriverFixedFFT< CalcT >:
FFTDriver

Public Member Functions

bool begin (int len) override
 
void end () override
 
fixedpoint_fft::FixedFFTEngineCore< CalcT > * engine ()
 Provides access to the underlying fixedpoint-fft engine.
 
void fft () override
 Perform FFT.
 
bool getBin (int pos, FFTBin &bin) override
 gets the value of a bin
 
float getValue (int idx) override
 get Real value
 
bool isReverseFFT () override
 Returns true if reverse FFT is supported.
 
bool isValid () override
 
float magnitude (int idx) override
 Calculate the magnitude (fft result) at index (sqr(i² + r²))
 
float magnitudeFast (int idx) override
 magnitude w/o sqrt
 
void rfft () override
 Inverse fft - convert fft result back to time domain (samples)
 
bool setBin (int pos, FFTBin &bin)
 sets the value of a bin
 
bool setBin (int pos, float real, float img) override
 sets the value of a bin
 
void setValue (int idx, float value) override
 Sets the real value.
 

Protected Member Functions

float imagAsFloat (int idx)
 
float realAsFloat (int idx)
 

Protected Attributes

fixedpoint_fft::FixedFFTEngineCore< CalcT > ffp_object
 
int len = 0
 
bool valid = false
 

Detailed Description

template<typename CalcT = int16_t>
class audio_tools::FFTDriverFixedFFT< CalcT >

Driver for the fixedpoint-fft library (https://github.com/pschatzmann/fixedpoint-fft). CalcT selects the calculation type used by the underlying engine: int8_t/int16_t/int32_t for fixed point Qn math (smallest/fastest, ideal for plain AVR), or float/double on FPU-equipped targets (ESP32, Cortex-M4F/M7, desktop). Defaults to int16_t (Q15), which gives good precision at any FFT size without needing an FPU. The FFTDriver interface itself is always float, so values are rescaled into/out of CalcT's Qn range on the way in/out via fixedpoint_fft::fftConvertSample.

Author
Phil Schatzmann

Member Function Documentation

◆ begin()

template<typename CalcT = int16_t>
bool begin ( int  len)
inlineoverridevirtual

Implements FFTDriver.

◆ end()

template<typename CalcT = int16_t>
void end ( )
inlineoverridevirtual

Implements FFTDriver.

◆ engine()

template<typename CalcT = int16_t>
fixedpoint_fft::FixedFFTEngineCore< CalcT > * engine ( )
inline

Provides access to the underlying fixedpoint-fft engine.

◆ fft()

template<typename CalcT = int16_t>
void fft ( )
inlineoverridevirtual

Perform FFT.

Implements FFTDriver.

◆ getBin()

template<typename CalcT = int16_t>
bool getBin ( int  pos,
FFTBin bin 
)
inlineoverridevirtual

gets the value of a bin

Reimplemented from FFTDriver.

◆ getValue()

template<typename CalcT = int16_t>
float getValue ( int  idx)
inlineoverridevirtual

get Real value

Implements FFTDriver.

◆ imagAsFloat()

template<typename CalcT = int16_t>
float imagAsFloat ( int  idx)
inlineprotected

◆ isReverseFFT()

template<typename CalcT = int16_t>
bool isReverseFFT ( )
inlineoverridevirtual

Returns true if reverse FFT is supported.

Reimplemented from FFTDriver.

◆ isValid()

template<typename CalcT = int16_t>
bool isValid ( )
inlineoverridevirtual

Implements FFTDriver.

◆ magnitude()

template<typename CalcT = int16_t>
float magnitude ( int  idx)
inlineoverridevirtual

Calculate the magnitude (fft result) at index (sqr(i² + r²))

Implements FFTDriver.

◆ magnitudeFast()

template<typename CalcT = int16_t>
float magnitudeFast ( int  idx)
inlineoverridevirtual

magnitude w/o sqrt

Implements FFTDriver.

◆ realAsFloat()

template<typename CalcT = int16_t>
float realAsFloat ( int  idx)
inlineprotected

◆ rfft()

template<typename CalcT = int16_t>
void rfft ( )
inlineoverridevirtual

Inverse fft - convert fft result back to time domain (samples)

Reimplemented from FFTDriver.

◆ setBin() [1/2]

bool setBin ( int  pos,
FFTBin bin 
)
inlineinherited

sets the value of a bin

◆ setBin() [2/2]

template<typename CalcT = int16_t>
bool setBin ( int  idx,
float  real,
float  img 
)
inlineoverridevirtual

sets the value of a bin

Reimplemented from FFTDriver.

◆ setValue()

template<typename CalcT = int16_t>
void setValue ( int  pos,
float  value 
)
inlineoverridevirtual

Sets the real value.

Implements FFTDriver.

Member Data Documentation

◆ ffp_object

template<typename CalcT = int16_t>
fixedpoint_fft::FixedFFTEngineCore<CalcT> ffp_object
protected

◆ len

template<typename CalcT = int16_t>
int len = 0
protected

◆ valid

template<typename CalcT = int16_t>
bool valid = false
protected

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