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

Graphic Equalizer implemented as an FFT effect: boosts or cuts logarithmically spaced frequency bands (20Hz .. Nyquist) by scaling the magnitude of the bins that fall into each band while leaving their phase untouched. Since this operates directly on the frequency-domain bins rather than an FIR/IIR approximation, band edges are exact and there is no filter ripple. More...

#include <FFTEffects.h>

Inheritance diagram for FFTEqualizer:
FFTEffect AudioOutput Print AudioInfoSupport AudioInfoSource

Public Member Functions

 FFTEqualizer (AudioOutput &out)
 
 FFTEqualizer (AudioOutput &out, AudioFFTBase &fft)
 
 FFTEqualizer (AudioStream &out)
 
 FFTEqualizer (AudioStream &out, AudioFFTBase &fft)
 
 FFTEqualizer (Print &out)
 
 FFTEqualizer (Print &out, AudioFFTBase &fft)
 
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 ()
 
virtual int availableForWrite () override
 
bool begin () override
 
virtual bool begin (AudioInfo info)
 
bool begin (FFTEffectConfig info)
 
bool begin (FFTEqualizerConfig cfg)
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
FFTEqualizerConfig defaultConfig ()
 
virtual void end ()
 
virtual void flush ()
 
int getBandCount ()
 Number of active bands.
 
float getBandDB (int band)
 Gets the currently defined gain for a band in dB.
 
float getBandFrequency (int band)
 Gets the center frequency of a band in Hz (only valid after begin())
 
virtual bool isDeletable ()
 If true we need to release the related memory in the destructor.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
virtual void setAudioInfo (AudioInfo newInfo) override
 Defines the input AudioInfo.
 
void setBandCount (int bands)
 
bool setBandDB (int band, float gain_db)
 
bool setBandGain (int band, float volume)
 
bool setBandGains (float volume)
 Sets the same gain for all bands.
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
size_t write (const uint8_t *data, size_t len) override
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 

Protected Member Functions

void effect (AudioFFTBase &fft) override
 
void notifyAudioChange (AudioInfo info)
 
void processOutput ()
 
void setupBands ()
 

Static Protected Member Functions

static void effect_callback (AudioFFTBase &fft)
 

Protected Attributes

int _timeout = 10
 
Vector< int > band_bin_from
 
Vector< int > band_bin_to
 
Vector< float > band_center_freq
 
int band_count = 10
 
BufferedWindow buffered {&hann}
 
AudioInfo cfg
 
StreamCopy copier
 
AudioRealFFT default_fft
 
AudioFFTConfig fft_cfg {default_fft.defaultConfig(RXTX_MODE)}
 
Vector< float > gains_db
 
Vector< float > gains_linear
 
Hann hann
 
bool is_active = false
 
bool is_notify_active = true
 
Vector< AudioInfoSupport * > notify_vector
 
AudioFFTBasep_fft = nullptr
 
Printp_out = nullptr
 
SingleBuffer< uint8_t > tmp {MAX_SINGLE_CHARS}
 
int tmpPos = 0
 

Detailed Description

Graphic Equalizer implemented as an FFT effect: boosts or cuts logarithmically spaced frequency bands (20Hz .. Nyquist) by scaling the magnitude of the bins that fall into each band while leaving their phase untouched. Since this operates directly on the frequency-domain bins rather than an FIR/IIR approximation, band edges are exact and there is no filter ripple.

Author
phil schatzmann

Constructor & Destructor Documentation

◆ FFTEqualizer() [1/6]

FFTEqualizer ( AudioStream out)
inline

◆ FFTEqualizer() [2/6]

FFTEqualizer ( AudioStream out,
AudioFFTBase fft 
)
inline

◆ FFTEqualizer() [3/6]

FFTEqualizer ( AudioOutput out)
inline

◆ FFTEqualizer() [4/6]

FFTEqualizer ( AudioOutput out,
AudioFFTBase fft 
)
inline

◆ FFTEqualizer() [5/6]

FFTEqualizer ( Print out)
inline

◆ FFTEqualizer() [6/6]

FFTEqualizer ( Print out,
AudioFFTBase fft 
)
inline

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

provides the actual input AudioInfo

Implements AudioInfoSupport.

Reimplemented in AdapterPrintToAudioOutput, EncodedAudioOutput, and AdapterAudioStreamToAudioOutput.

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtualinherited

◆ begin() [1/4]

bool begin ( )
inlineoverridevirtual

Reimplemented from FFTEffect.

◆ begin() [2/4]

virtual bool begin ( AudioInfo  info)
inlinevirtualinherited

◆ begin() [3/4]

bool begin ( FFTEffectConfig  info)
inlineinherited

◆ begin() [4/4]

bool begin ( FFTEqualizerConfig  cfg)
inline

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ defaultConfig()

FFTEqualizerConfig defaultConfig ( )
inline

◆ effect()

void effect ( AudioFFTBase fft)
inlineoverrideprotectedvirtual

Scales the magnitude of the bins in each band by the configured gain, leaving the phase untouched

Implements FFTEffect.

◆ effect_callback()

static void effect_callback ( AudioFFTBase fft)
inlinestaticprotectedinherited

◆ end()

virtual void end ( )
inlinevirtualinherited

◆ flush()

virtual void flush ( )
inlinevirtualinherited

Reimplemented from Print.

Reimplemented in MultiOutput, and HexDumpOutput.

◆ getBandCount()

int getBandCount ( )
inline

Number of active bands.

◆ getBandDB()

float getBandDB ( int  band)
inline

Gets the currently defined gain for a band in dB.

◆ getBandFrequency()

float getBandFrequency ( int  band)
inline

Gets the center frequency of a band in Hz (only valid after begin())

◆ isDeletable()

virtual bool isDeletable ( )
inlinevirtualinherited

If true we need to release the related memory in the destructor.

Reimplemented in AdapterPrintToAudioOutput, and AdapterAudioStreamToAudioOutput.

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ processOutput()

void processOutput ( )
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 >.

◆ setAudioInfo()

virtual void setAudioInfo ( AudioInfo  info)
inlineoverridevirtualinherited

◆ setBandCount()

void setBandCount ( int  bands)
inline

Defines the number of logarithmically spaced bands; call before begin() or before defaultConfig() if you want a non-default band count.

◆ setBandDB()

bool setBandDB ( int  band,
float  gain_db 
)
inline

Sets the gain for a band directly in dB (-90 to +12 is a sane range; values are not clamped)

◆ setBandGain()

bool setBandGain ( int  band,
float  volume 
)
inline

Sets the gain for a band as a normalized volume (-1.0 to 1.0), mapped to -90dB..+12dB. For deeper cuts/boosts use setBandDB() directly.

◆ setBandGains()

bool setBandGains ( float  volume)
inline

Sets the same gain for all bands.

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

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

◆ setupBands()

void setupBands ( )
inlineprotected

Determines the fft bin range and center frequency of each logarithmically spaced band between 20Hz and Nyquist

◆ write() [1/2]

size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtualinherited

Implements AudioOutput.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Reimplemented in MetaDataOutput, and MultiOutput.

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes n 0 values (= silence)

Parameters
len

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ band_bin_from

Vector<int> band_bin_from
protected

◆ band_bin_to

Vector<int> band_bin_to
protected

◆ band_center_freq

Vector<float> band_center_freq
protected

◆ band_count

int band_count = 10
protected

◆ buffered

BufferedWindow buffered {&hann}
protectedinherited

◆ cfg

AudioInfo cfg
protectedinherited

◆ copier

StreamCopy copier
protectedinherited

◆ default_fft

AudioRealFFT default_fft
protectedinherited

◆ fft_cfg

AudioFFTConfig fft_cfg {default_fft.defaultConfig(RXTX_MODE)}
protectedinherited

◆ gains_db

Vector<float> gains_db
protected

◆ gains_linear

Vector<float> gains_linear
protected

◆ hann

Hann hann
protectedinherited

◆ is_active

bool is_active = false
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_fft

AudioFFTBase* p_fft = nullptr
protectedinherited

◆ p_out

Print* p_out = nullptr
protectedinherited

◆ tmp

SingleBuffer<uint8_t> tmp {MAX_SINGLE_CHARS}
protectedinherited

◆ tmpPos

int tmpPos = 0
protectedinherited

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