arduino-audio-tools
|
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>
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. | |
ConfigEqualizer3Bands & | config () |
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) | |
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 |
ConfigEqualizer3Bands * | p_cfg = &cfg |
Pointer to active configuration. | |
Print * | p_print = nullptr |
Output stream for write operations. | |
Stream * | p_stream = nullptr |
Input/output stream for read operations. | |
struct audio_tools::Equalizer3BandsPerChannel::EQSTATE * | state = 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 |
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.
|
inline |
|
inline |
|
inline |
Constructor with AudioOutput
out | AudioOutput for output with automatic audio change notifications |
|
inline |
Constructor with AudioStream
stream | AudioStream for input/output with automatic audio change notifications |
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlineprotected |
Allocates and initializes per-channel frequency and gain arrays
num_channels | Number of channels to allocate arrays for |
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in JupyterAudioT< T >, MozziStream, TimerCallbackAudioStream, EncodedAudioStream, PureDataStream, AdapterAudioOutputToAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and InputMerge< T >.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in PureDataStream, PWMAudioOutput, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inlineoverridevirtual |
Get available data for reading
Reimplemented from BaseStream.
|
inlineoverridevirtual |
Get available space for writing
Reimplemented from BaseStream.
|
inlinevirtual |
Initialize the equalizer using the current configuration
Reimplemented from BaseStream.
|
inline |
Initialize the equalizer with the given configuration
config | Configuration settings for the equalizer |
|
inlineoverridevirtual |
Reimplemented from BaseStream.
|
inlineprotected |
Applies per-channel 3-band equalization to audio samples
data | Pointer to audio data buffer |
len | Length of the data buffer in bytes |
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in ResampleStream, BufferedTaskStream, and BufferedStream.
|
inline |
Get frequency parameters for a specific channel
channel | Channel index (0-based) |
freq_low_val | Reference to store the low frequency cutoff |
freq_high_val | Reference to store the high frequency cutoff |
|
inline |
Get gain parameters for a specific channel
channel | Channel index (0-based) |
gain_low_val | Reference to store the low frequency gain |
gain_medium_val | Reference to store the medium frequency gain |
gain_high_val | Reference to store the high frequency gain |
|
inlinevirtualinherited |
Reimplemented in A2DPStream, ICYStreamT< T >, I2SStream, MemoryStream, and Pipeline.
|
inlineoverridevirtual |
Read and process audio data through the per-channel equalizer
data | Buffer to store processed audio data |
len | Maximum number of bytes to read |
Reimplemented from AudioStream.
|
inlineprotected |
Processes a single sample through the 3-band equalizer for a specific channel
channel | The channel number to process |
sample_val | The input sample value |
|
inlineoverridevirtual |
Defines the input AudioInfo.
Reimplemented from AudioStream.
|
inline |
Set frequency parameters for a specific channel
channel | Channel index (0-based) |
freq_low_val | Low frequency cutoff in Hz |
freq_high_val | High frequency cutoff in Hz |
|
inline |
Set gain parameters for a specific channel
channel | Channel index (0-based) |
gain_low_val | Gain multiplier for low frequencies (0.0-2.0) |
gain_medium_val | Gain multiplier for medium frequencies (0.0-2.0) |
gain_high_val | Gain multiplier for high frequencies (0.0-2.0) |
|
inlineoverridevirtual |
Defines/Changes the output target.
Implements ModifyingStream.
|
inlineoverridevirtual |
Defines/Changes the input & output.
Implements ModifyingStream.
|
inlineoverridevirtual |
Process and write audio data through the per-channel equalizer
data | Pointer to audio data buffer |
len | Length of data in bytes |
Reimplemented from AudioStream.
|
inlineoverridevirtualinherited |
Reimplemented in BufferedTaskStream, and BufferedStream.