arduino-audio-tools
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Equalizer3BandsPerChannelT< T > Class Template 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 <Equalizer3Bands.h>

Inheritance diagram for Equalizer3BandsPerChannelT< T >:
ModifyingStream AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

Classes

struct  EQSTATE
 

Public Member Functions

 Equalizer3BandsPerChannelT (AudioOutput &out)
 
 Equalizer3BandsPerChannelT (AudioStream &stream)
 
 Equalizer3BandsPerChannelT (Print &out)
 
 Equalizer3BandsPerChannelT (Stream &in)
 
 ~Equalizer3BandsPerChannelT ()
 
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 ()
 
ConfigEqualizer3Bands defaultConfig ()
 
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)
 
virtual void setOutput (AudioOutput &out)
 Defines/Changes the output target and registers for audio change notifications.
 
void setOutput (Print &out) override
 Defines/Changes the output target.
 
virtual void setStream (AudioStream &io)
 Defines/Changes the input & output and registers for audio change notifications.
 
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 ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 
sample (int channel, T 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::Equalizer3BandsPerChannelT::EQSTATEstate = nullptr
 
RingBuffer< uint8_t > tmp_in {0}
 
RingBuffer< uint8_t > tmp_out {0}
 
const T vsa = EqDenormalGuard<T>::value()
 Denormal-avoidance offset.
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

template<typename T = float>
class audio_tools::Equalizer3BandsPerChannelT< T >

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.

Template Parameters
TArithmetic type used for the filter state and coefficients; see Equalizer3BandsT for details. Equalizer3BandsPerChannel (no template argument) is a float-based alias kept for backwards compatibility.
Author
pschatzmann

Constructor & Destructor Documentation

◆ Equalizer3BandsPerChannelT() [1/4]

template<typename T = float>
Equalizer3BandsPerChannelT ( Print out)
inline

Constructor with Print output

Parameters
outPrint stream for output

◆ Equalizer3BandsPerChannelT() [2/4]

template<typename T = float>
Equalizer3BandsPerChannelT ( Stream in)
inline

Constructor with Stream input

Parameters
inStream for input

◆ Equalizer3BandsPerChannelT() [3/4]

template<typename T = float>
Equalizer3BandsPerChannelT ( AudioOutput out)
inline

Constructor with AudioOutput

Parameters
outAudioOutput for output with automatic audio change notifications

◆ Equalizer3BandsPerChannelT() [4/4]

template<typename T = float>
Equalizer3BandsPerChannelT ( AudioStream stream)
inline

Constructor with AudioStream

Parameters
streamAudioStream for input/output with automatic audio change notifications

◆ ~Equalizer3BandsPerChannelT()

template<typename T = float>
~Equalizer3BandsPerChannelT ( )
inline

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ allocateChannelArrays()

template<typename T = float>
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()

template<typename T = float>
int available ( )
inlineoverridevirtual

Get available data for reading

Returns
Number of bytes available for reading

Reimplemented from BaseStream.

◆ availableForWrite()

template<typename T = float>
int availableForWrite ( )
inlineoverridevirtual

Get available space for writing

Returns
Number of bytes available for writing

Reimplemented from BaseStream.

◆ begin() [1/2]

template<typename T = float>
bool begin ( )
inlinevirtual

Initialize the equalizer using the current configuration

Returns
true if initialization was successful

Reimplemented from BaseStream.

◆ begin() [2/2]

template<typename T = float>
bool begin ( ConfigEqualizer3Bands config)
inline

Initialize the equalizer with the given configuration

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

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ config()

template<typename T = float>
ConfigEqualizer3Bands & config ( )
inline

◆ defaultConfig()

template<typename T = float>
ConfigEqualizer3Bands defaultConfig ( )
inline

◆ end()

template<typename T = float>
void end ( )
inlineoverridevirtual

Reimplemented from BaseStream.

◆ ensureChannelArraysAllocated()

template<typename T = float>
void ensureChannelArraysAllocated ( )
inlineprotected

Ensures that per-channel arrays are allocated and properly sized.

◆ filterSamples()

template<typename T = float>
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

◆ getChannelFrequencies()

template<typename T = float>
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()

template<typename T = float>
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

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ not_supported()

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

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ readBytes()

template<typename T = float>
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.

◆ readSilence()

virtual size_t readSilence ( uint8_t *  buffer,
size_t  length 
)
inlinevirtualinherited

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

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

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

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ sample()

template<typename T = float>
T sample ( int  channel,
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()

template<typename T = float>
virtual void setAudioInfo ( AudioInfo  info)
inlineoverridevirtual

Defines the input AudioInfo.

Reimplemented from AudioStream.

◆ setChannelFrequencies()

template<typename T = float>
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()

template<typename T = float>
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)

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

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

◆ setOutput() [1/2]

virtual void setOutput ( AudioOutput out)
inlinevirtualinherited

Defines/Changes the output target and registers for audio change notifications.

Reimplemented in TimedStream, VolumeMeter, AudioInputMonitor, QualityAnalysisStream, ReformatBaseStream, FormatConverterStream, and EncodedAudioStream.

◆ setOutput() [2/2]

template<typename T = float>
void setOutput ( Print out)
inlineoverridevirtual

Defines/Changes the output target.

Implements ModifyingStream.

◆ setStream() [1/2]

virtual void setStream ( AudioStream io)
inlinevirtualinherited

Defines/Changes the input & output and registers for audio change notifications.

Reimplemented in VolumeMeter, AudioInputMonitor, QualityAnalysisStream, FormatConverterStream, ReformatBaseStream, TimedStream, and EncodedAudioStream.

◆ setStream() [2/2]

template<typename T = float>
void setStream ( Stream io)
inlineoverridevirtual

Defines/Changes the input & output.

Implements ModifyingStream.

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ write() [1/2]

template<typename T = float>
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

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes len bytes of silence (=0).

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ cfg

template<typename T = float>
ConfigEqualizer3Bands cfg
protected

Default configuration instance.

◆ freq_high

template<typename T = float>
Vector<int> freq_high
protected

High frequency cutoffs per channel (Hz)

◆ freq_low

template<typename T = float>
Vector<int> freq_low
protected

Low frequency cutoffs per channel (Hz)

◆ gain_high

template<typename T = float>
Vector<float> gain_high
protected

High frequency gains per channel.

◆ gain_low

template<typename T = float>
Vector<float> gain_low
protected

Low frequency gains per channel.

◆ gain_medium

template<typename T = float>
Vector<float> gain_medium
protected

Medium frequency gains per channel.

◆ info

AudioInfo info
protectedinherited

◆ is_active

template<typename T = float>
bool is_active = false
protected

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ max_state_count

template<typename T = float>
int max_state_count = 0
protected

Maximum number of allocated channel states.

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_cfg

template<typename T = float>
ConfigEqualizer3Bands* p_cfg = &cfg
protected

Pointer to active configuration.

◆ p_print

template<typename T = float>
Print* p_print = nullptr
protected

Output stream for write operations.

◆ p_stream

template<typename T = float>
Stream* p_stream = nullptr
protected

Input/output stream for read operations.

◆ state

template<typename T = float>
struct audio_tools::Equalizer3BandsPerChannelT::EQSTATE* state = nullptr
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ vsa

template<typename T = float>
const T vsa = EqDenormalGuard<T>::value()
protected

Denormal-avoidance offset.

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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