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

3 Band Equalizer with per-channel frequency and gain control Allows independent frequency and gain settings for each audio channel. Each channel can have different low/high frequency cutoffs and different gain values for low, medium, and high frequency bands. More...

#include <Equalizer.h>

Inheritance diagram for Equalizer3BandsPerChannel:
ModifyingStream AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

Classes

struct  EQSTATE
 

Public Member Functions

 Equalizer3BandsPerChannel (AudioOutput &out)
 
 Equalizer3BandsPerChannel (AudioStream &stream)
 
 Equalizer3BandsPerChannel (Print &out)
 
 Equalizer3BandsPerChannel (Stream &in)
 
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
 
int availableForWrite () override
 
bool begin ()
 
bool begin (ConfigEqualizer3Bands config)
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
ConfigEqualizer3Bandsconfig ()
 
ConfigEqualizer3BandsdefaultConfig ()
 
void end () override
 
virtual void flush () override
 
bool getChannelFrequencies (int channel, int &freq_low_val, int &freq_high_val)
 
bool getChannelGains (int channel, float &gain_low_val, float &gain_medium_val, float &gain_high_val)
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
size_t readBytes (uint8_t *data, size_t len) override
 
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
virtual void setAudioInfo (AudioInfo info) override
 Defines the input AudioInfo.
 
void setChannelFrequencies (int channel, int freq_low_val, int freq_high_val)
 
void setChannelGains (int channel, float gain_low_val, float gain_medium_val, float gain_high_val)
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
void setOutput (Print &out) override
 Defines/Changes the output target.
 
void setStream (Stream &io) override
 Defines/Changes the input & output.
 
void setWriteBufferSize (int size)
 
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)
 Writes len bytes of silence (=0).
 

Protected Member Functions

void allocateChannelArrays (int num_channels)
 
void ensureChannelArraysAllocated ()
 Ensures that per-channel arrays are allocated and properly sized.
 
void filterSamples (const uint8_t *data, size_t len)
 
virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void refillReadBuffer ()
 
float sample (int channel, float sample_val)
 

Protected Attributes

int _timeout = 10
 
ConfigEqualizer3Bands cfg
 Default configuration instance.
 
Vector< int > freq_high
 High frequency cutoffs per channel (Hz)
 
Vector< int > freq_low
 Low frequency cutoffs per channel (Hz)
 
Vector< float > gain_high
 High frequency gains per channel.
 
Vector< float > gain_low
 Low frequency gains per channel.
 
Vector< float > gain_medium
 Medium frequency gains per channel.
 
AudioInfo info
 
bool is_active = false
 
bool is_notify_active = true
 
int max_state_count = 0
 Maximum number of allocated channel states.
 
Vector< AudioInfoSupport * > notify_vector
 
ConfigEqualizer3Bandsp_cfg = &cfg
 Pointer to active configuration.
 
Printp_print = nullptr
 Output stream for write operations.
 
Streamp_stream = nullptr
 Input/output stream for read operations.
 
struct audio_tools::Equalizer3BandsPerChannel::EQSTATEstate = nullptr
 
RingBuffer< uint8_t > tmp_in {0}
 
RingBuffer< uint8_t > tmp_out {0}
 
const float vsa = (1.0 / 4294967295.0)
 Very small amount for denormal fix.
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

3 Band Equalizer with per-channel frequency and gain control Allows independent frequency and gain settings for each audio channel. Each channel can have different low/high frequency cutoffs and different gain values for low, medium, and high frequency bands.

Author
pschatzmann

Constructor & Destructor Documentation

◆ Equalizer3BandsPerChannel() [1/4]

Equalizer3BandsPerChannel ( Print out)
inline

Constructor with Print output

Parameters
outPrint stream for output

◆ Equalizer3BandsPerChannel() [2/4]

Constructor with Stream input

Parameters
inStream for input

◆ Equalizer3BandsPerChannel() [3/4]

Constructor with AudioOutput

Parameters
outAudioOutput for output with automatic audio change notifications

◆ Equalizer3BandsPerChannel() [4/4]

Equalizer3BandsPerChannel ( AudioStream stream)
inline

Constructor with AudioStream

Parameters
streamAudioStream for input/output with automatic audio change notifications

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ allocateChannelArrays()

void allocateChannelArrays ( int  num_channels)
inlineprotected

Allocates and initializes per-channel frequency and gain arrays

Parameters
num_channelsNumber of channels to allocate arrays for

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

int available ( )
inlineoverridevirtual

Get available data for reading

Returns
Number of bytes available for reading

Reimplemented from BaseStream.

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtual

Get available space for writing

Returns
Number of bytes available for writing

Reimplemented from BaseStream.

◆ begin() [1/2]

bool begin ( )
inlinevirtual

Initialize the equalizer using the current configuration

Returns
true if initialization was successful

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( ConfigEqualizer3Bands  config)
inline

Initialize the equalizer with the given configuration

Parameters
configConfiguration settings for the equalizer
Returns
true if initialization was successful

◆ end()

void end ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ filterSamples()

void filterSamples ( const uint8_t *  data,
size_t  len 
)
inlineprotected

Applies per-channel 3-band equalization to audio samples

Parameters
dataPointer to audio data buffer
lenLength of the data buffer in bytes

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

Reimplemented from Print.

Reimplemented in ResampleStream, BufferedTaskStream, and BufferedStream.

◆ getChannelFrequencies()

bool getChannelFrequencies ( int  channel,
int &  freq_low_val,
int &  freq_high_val 
)
inline

Get frequency parameters for a specific channel

Parameters
channelChannel index (0-based)
freq_low_valReference to store the low frequency cutoff
freq_high_valReference to store the high frequency cutoff
Returns
true if successful, false if channel index is invalid

◆ getChannelGains()

bool getChannelGains ( int  channel,
float &  gain_low_val,
float &  gain_medium_val,
float &  gain_high_val 
)
inline

Get gain parameters for a specific channel

Parameters
channelChannel index (0-based)
gain_low_valReference to store the low frequency gain
gain_medium_valReference to store the medium frequency gain
gain_high_valReference to store the high frequency gain
Returns
true if successful, false if channel index is invalid

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ readBytes()

size_t readBytes ( uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Read and process audio data through the per-channel equalizer

Parameters
dataBuffer to store processed audio data
lenMaximum number of bytes to read
Returns
Number of bytes actually read and processed

Reimplemented from AudioStream.

◆ sample()

float sample ( int  channel,
float  sample_val 
)
inlineprotected

Processes a single sample through the 3-band equalizer for a specific channel

Parameters
channelThe channel number to process
sample_valThe input sample value
Returns
The processed sample value with per-channel equalization applied

◆ setAudioInfo()

virtual void setAudioInfo ( AudioInfo  info)
inlineoverridevirtual

Defines the input AudioInfo.

Reimplemented from AudioStream.

◆ setChannelFrequencies()

void setChannelFrequencies ( int  channel,
int  freq_low_val,
int  freq_high_val 
)
inline

Set frequency parameters for a specific channel

Parameters
channelChannel index (0-based)
freq_low_valLow frequency cutoff in Hz
freq_high_valHigh frequency cutoff in Hz

◆ setChannelGains()

void setChannelGains ( int  channel,
float  gain_low_val,
float  gain_medium_val,
float  gain_high_val 
)
inline

Set gain parameters for a specific channel

Parameters
channelChannel index (0-based)
gain_low_valGain multiplier for low frequencies (0.0-2.0)
gain_medium_valGain multiplier for medium frequencies (0.0-2.0)
gain_high_valGain multiplier for high frequencies (0.0-2.0)

◆ setOutput()

void setOutput ( Print out)
inlineoverridevirtual

Defines/Changes the output target.

Implements ModifyingStream.

◆ setStream()

void setStream ( Stream io)
inlineoverridevirtual

Defines/Changes the input & output.

Implements ModifyingStream.

◆ write() [1/2]

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

Process and write audio data through the per-channel equalizer

Parameters
dataPointer to audio data buffer
lenLength of data in bytes
Returns
Number of bytes written

Reimplemented from AudioStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Reimplemented in BufferedTaskStream, and BufferedStream.


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