|
arduino-audio-tools
|
N-Band Equalizer using FIR filters with logarithmically spaced bands. More...
#include <EqualizerNBands.h>
Classes | |
| class | EQFIRFilter |
Protected Member Functions | |
| void | enterCritical () |
| void | exitCritical () |
| void | initializeKernel (volatile int16_t *kernel) |
| template<typename T > | |
| float | map (T x, T in_min, T in_max, T out_min, T out_max) |
| void | maybeUpdateKernel () |
| virtual int | not_supported (int out, const char *msg="") |
| void | notifyAudioChange (AudioInfo info) |
| void | preCalculateWindow () |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read() | |
| void | setupFrequencies (int sampleRate) |
| float | sinc (float x) |
| bool | updateFIRKernel () |
Protected Attributes | |
| int | _timeout = 10 |
| volatile int16_t * | activeKernel |
| bool | autoUpdate = false |
| float | centerFreqs [NUM_BANDS] |
| int | currentSampleRate = 0 |
| FilteredStream< SampleT, SampleT > | filtered |
| Vector< EQFIRFilter > | fir_vector |
| Vector of FIR filters for each channel. | |
| float | gains [NUM_BANDS] = {0} |
| volatile bool | gainsDirty = false |
| AudioInfo | info |
| bool | is_notify_active = true |
| volatile bool | isUpdating = false |
| int16_t | kernelA [NUM_TAPS] |
| int16_t | kernelB [NUM_TAPS] |
| Vector< AudioInfoSupport * > | notify_vector |
| Print * | p_print = nullptr |
| Output stream for write operations. | |
| Stream * | p_stream = nullptr |
| Input stream for read operations. | |
| float | pendingGains [NUM_BANDS] = {0} |
| float | tempFloat [NUM_TAPS] = {0} |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| volatile int16_t * | updateKernel |
| float | windowCoeffs [NUM_TAPS] |
| int | write_buffer_size = MAX_SINGLE_CHARS |
Static Protected Attributes | |
| static constexpr float | Q15_SCALE = 32767.0f |
N-Band Equalizer using FIR filters with logarithmically spaced bands.
This class implements a graphic equalizer with configurable number of bands using FIR (Finite Impulse Response) filtering. Frequency bands are logarithmically spaced between 20Hz and Nyquist frequency.
Features:
Thread Safety: Uses double-buffering with two kernel buffers. Audio processing reads from the active kernel while updates are written to the inactive kernel. An atomic pointer swap ensures glitch-free transitions without blocking audio processing.
| NUM_TAPS | Number of FIR filter taps (higher = sharper transitions, more CPU usage). Typical values: 64, 128, 256 |
| NUM_BANDS | Number of frequency bands. Typical values: 3, 5, 10, 31 |
|
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 |
|
inline |
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, CodecChain, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, RTSPClient< TcpClient, UdpSocket >, Pipeline, and Pipeline::ModifyingStreamAdapter.
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in JupyterAudioT< T >, MozziStream, TimerCallbackAudioStream, EncodedAudioStream, PureDataStream, AdapterAudioOutputToAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and InputMerge< T >.
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 >.
Reimplemented from Stream.
Reimplemented in AudioKitStream, AudioLoRa, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, VBANStream, AudioStreamWrapper, LoRaStream, FaustStream< DSP >, AudioFFTBase, AudioMP34DT05, I2SCodecStream, MiniAudioStream, StdioStream, TfLiteAudioStream, A2DPStream, ESPNowStream, HammingFEC< bytecount, block_t >, HLSStreamT< URLStream >, HttpRequest, ICYStreamT< T >, URLStream, BufferedTaskStream, ReedSolomonFEC< bytecount, additional_bytes >, UDPStream, AnalogAudioArduino, AnalogAudioStream, AudioEffectStreamT< T >, Equalizer3Bands, Equalizer3BandsPerChannel, I2SStream, ReformatBaseStream, TimedStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, BufferedStream, ConverterStream< T >, MeasuringStream, ProgressStream, Throttle, InputMerge< T >, CallbackStream, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, CatStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, FadeStream, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, Pipeline, Pipeline::ModifyingStreamAdapter, VolumeStream, FileLoopT< FileType >, FileLoopT< File >, AudioBLEClient, AudioBLEClient, AudioBLEServer, and AudioBLEServer.
Reimplemented from Print.
Reimplemented in AudioLoRa, UDPStream, VBANStream, AudioStreamWrapper, ConverterStream< T >, LoRaStream, EncodedAudioStream, FaustStream< DSP >, AudioFFTBase, I2SCodecStream, MiniAudioStream, StdioStream, A2DPStream, ESPNowStream, HammingFEC< bytecount, block_t >, AbstractURLStream, URLStreamESP32, ReedSolomonFEC< bytecount, additional_bytes >, AnalogAudioArduino, AnalogAudioStream, AudioEffectStreamT< T >, Equalizer3Bands, Equalizer3BandsPerChannel, I2SStream, ReformatBaseStream, TimedStream, MemoryStream, RingBufferStream, MeasuringStream, ProgressStream, Throttle, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, FadeStream, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, Pipeline, VolumeStream, AudioBLEClient, AudioBLEClient, AudioBLEServer, and AudioBLEServer.
|
inlineoverridevirtual |
Initializes the equalizer with the current audio info.
Reimplemented from BaseStream.
|
inline |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlinevirtual |
Reimplemented from BaseStream.
|
inlineprotected |
|
inlineprotected |
Reimplemented from Print.
Reimplemented in PureDataStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, AudioStreamWrapper, ResampleStream, URLStream, BufferedTaskStream, I2SStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and BufferedStream.
|
inline |
Get number of bands.
|
inline |
Get current gain for a specific band in dB
| band | Band index (0 to NUM_BANDS-1) |
|
inline |
Get center frequency for a specific band
| band | Band index (0 to NUM_BANDS-1) |
|
inline |
Get current gain for a specific band as normalized volume (-1.0 to 1.0)
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineoverridevirtual |
Reimplemented from AudioStream.
Source to generate silence: just sets the buffer to 0.
|
inlineprotectedinherited |
Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
Defines the input AudioInfo.
Implements AudioInfoSupport.
Reimplemented in VS1053Stream, WM8960Stream, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, VolumeStream, MiniAudioStream, PortAudioStream, I2SCodecStream, MozziStream, SPDIFOutput, AudioLoRa, AnalogAudioStream, I2SStream, TimerCallbackAudioStream, AudioBLEStream, LoRaStream, AudioFFTBase, AudioKitStream, VBANStream, AnalogAudioArduino, Equalizer3Bands, Equalizer3BandsPerChannel, AdapterAudioOutputToAudioStream, TimedStream, MeasuringStream, ProgressStream, CallbackStream, VolumeMeter, AudioInputMonitor, FormatConverterStream, FadeStream, GoertzelStream, Pipeline::ModifyingStreamAdapter, MDFEchoCancellationStream< Allocator >, EncodedAudioStream, PureDataStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inline |
Enable/disable automatic kernel updates during read/write
| enabled | When true, pending gain changes are applied automatically |
|
inline |
Set gain for a specific band directly in dB
| band | Band index (0 to NUM_BANDS-1) |
| gainDb | Gain in dB (-90 to +12). The lower limit matches Q15 dynamic range; the upper limit prevents clipping. |
|
inline |
Set gain for a specific frequency band
| band | Band index (0 to NUM_BANDS-1) |
| volume | Volume level (-1.0 to 1.0) mapped to -12dB to +12dB. For deeper cuts use setBandDB() directly. |
|
inline |
Set same gain for all frequency bands.
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inlineoverridevirtual |
Defines/Changes the output target
| out | Print stream where processed audio will be written |
Implements ModifyingStream.
|
inlineoverridevirtual |
Defines/Changes the input & output stream
| io | Stream to use for both reading and writing audio data |
Implements ModifyingStream.
|
inlineprotected |
|
inlineprotected |
|
inline |
|
inlineprotected |
|
inlineoverridevirtual |
Reimplemented from AudioStream.
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
Output stream for write operations.
|
protected |
Input stream for read operations.
|
protected |
|
staticconstexprprotected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |