DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::DynamicEQ< T, MaxBands > Class Template Reference

Dynamic parametric EQ with dual above/below threshold per band. More...

#include <DynamicEQ.h>

Classes

struct  BandConfig
 Full configuration for a single dynamic EQ band. More...
 

Public Types

enum class  BandShape { Bell , LowShelf , HighShelf }
 Shape of the dynamic gain filter (and its detector region). More...
 

Public Member Functions

 DynamicEQ ()
 
void prepare (const AudioSpec &spec)
 Initializes the dynamic EQ, allocating ring buffers and oversamplers.
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes audio in-place using self-sidechain.
 
void processBlock (AudioBufferView< T > audio, AudioBufferView< T > sidechain) noexcept
 Processes audio with an external sidechain.
 
void setBand (int band, const BandConfig &config) noexcept
 Thread-safe configuration update for a specific band.
 
void setNumBands (int n) noexcept
 
void setOversampling (int factor) noexcept
 Sets the internal oversampling factor (RF-009 / ADR-011).
 
void setLookahead (T ms) noexcept
 Sets the lookahead (0..10 ms). Applied immediately (may click); non-finite values are ignored.
 
int getLatency () const noexcept
 Total latency in samples at the base rate.
 
getBandGainDb (int band) const noexcept
 
void reset () noexcept
 
std::vector< uint8_t > getState () const
 Serializes bands and modes (setup/UI threads; allocates).
 
bool setState (const uint8_t *data, size_t size)
 Restores bands from a blob (tolerant; rejects foreign ids).
 

Detailed Description

template<FloatType T, int MaxBands = 8>
class dspark::DynamicEQ< T, MaxBands >

Dynamic parametric EQ with dual above/below threshold per band.

Template Parameters
TSample type (float or double).
MaxBandsMaximum number of bands (compile-time, default 8).

Definition at line 65 of file DynamicEQ.h.

Member Enumeration Documentation

◆ BandShape

template<FloatType T, int MaxBands = 8>
enum class dspark::DynamicEQ::BandShape
strong

Shape of the dynamic gain filter (and its detector region).

Enumerator
Bell 

Parametric bell; detector is a bandpass at freq/Q.

LowShelf 

Dynamic low shelf; detector hears below freq.

HighShelf 

Dynamic high shelf; detector hears above freq.

Definition at line 69 of file DynamicEQ.h.

Constructor & Destructor Documentation

◆ DynamicEQ()

template<FloatType T, int MaxBands = 8>
dspark::DynamicEQ< T, MaxBands >::DynamicEQ ( )
inline

Definition at line 103 of file DynamicEQ.h.

Member Function Documentation

◆ getBandGainDb()

template<FloatType T, int MaxBands = 8>
T dspark::DynamicEQ< T, MaxBands >::getBandGainDb ( int  band) const
inlinenoexcept

Definition at line 288 of file DynamicEQ.h.

◆ getLatency()

template<FloatType T, int MaxBands = 8>
int dspark::DynamicEQ< T, MaxBands >::getLatency ( ) const
inlinenoexcept

Total latency in samples at the base rate.

Lookahead delay plus the oversampler's group delay. Neither was reported before, so hosts could not compensate (PDC). Safe to call from the main thread once prepared (the oversampler only changes inside prepare()).

Definition at line 280 of file DynamicEQ.h.

◆ getState()

template<FloatType T, int MaxBands = 8>
std::vector< uint8_t > dspark::DynamicEQ< T, MaxBands >::getState ( ) const
inline

Serializes bands and modes (setup/UI threads; allocates).

Definition at line 310 of file DynamicEQ.h.

◆ prepare()

template<FloatType T, int MaxBands = 8>
void dspark::DynamicEQ< T, MaxBands >::prepare ( const AudioSpec spec)
inline

Initializes the dynamic EQ, allocating ring buffers and oversamplers.

Parameters
specAudio specification containing sample rate and block size.

Definition at line 116 of file DynamicEQ.h.

◆ processBlock() [1/2]

template<FloatType T, int MaxBands = 8>
void dspark::DynamicEQ< T, MaxBands >::processBlock ( AudioBufferView< T >  audio,
AudioBufferView< T >  sidechain 
)
inlinenoexcept

Processes audio with an external sidechain.

Parameters
audioIn/Out audio buffer.
sidechainReference signal used for level detection.

Definition at line 162 of file DynamicEQ.h.

◆ processBlock() [2/2]

template<FloatType T, int MaxBands = 8>
void dspark::DynamicEQ< T, MaxBands >::processBlock ( AudioBufferView< T >  buffer)
inlinenoexcept

Processes audio in-place using self-sidechain.

Parameters
bufferIn/Out audio buffer.

Definition at line 152 of file DynamicEQ.h.

◆ reset()

template<FloatType T, int MaxBands = 8>
void dspark::DynamicEQ< T, MaxBands >::reset ( )
inlinenoexcept

Definition at line 294 of file DynamicEQ.h.

◆ setBand()

template<FloatType T, int MaxBands = 8>
void dspark::DynamicEQ< T, MaxBands >::setBand ( int  band,
const BandConfig config 
)
inlinenoexcept

Thread-safe configuration update for a specific band.

Fields are sanitized on the way in: non-finite values keep the band's previously published value (a NaN frequency/Q/time used to poison the detector or the gain ballistics permanently), wild shape enums are clamped, and the range fields are floored at 0.

Definition at line 205 of file DynamicEQ.h.

◆ setLookahead()

template<FloatType T, int MaxBands = 8>
void dspark::DynamicEQ< T, MaxBands >::setLookahead ( ms)
inlinenoexcept

Sets the lookahead (0..10 ms). Applied immediately (may click); non-finite values are ignored.

Definition at line 265 of file DynamicEQ.h.

◆ setNumBands()

template<FloatType T, int MaxBands = 8>
void dspark::DynamicEQ< T, MaxBands >::setNumBands ( int  n)
inlinenoexcept

Definition at line 232 of file DynamicEQ.h.

◆ setOversampling()

template<FloatType T, int MaxBands = 8>
void dspark::DynamicEQ< T, MaxBands >::setOversampling ( int  factor)
inlinenoexcept

Sets the internal oversampling factor (RF-009 / ADR-011).

Transparency policy: the factor is host-visible, fully configurable and can be turned OFF.

  • Supported factors: {1, 2, 4}. DEFAULT is 1 = OFF (no internal resampling, zero added latency, no hidden cascaded resampler). 3 rounds up to 4 (the underlying Oversampling engine works in powers of two); values outside [1,4] are clamped.
  • CPU/latency cost per factor (relative to 1x=off): 2x roughly doubles the per-band detector+filter work and adds the half-band polyphase group delay; 4x roughly quadruples it and adds ~2x that group delay. The exact added latency for the active factor is reported by getLatency() so the host can apply correct PDC. Prefer 1x and oversample the whole nonlinear section once (docs/cookbook.md) when a chain already oversamples.
Note
Setup threads only: this un-prepares the processor and requires a prepare() call before the new factor takes effect.

Definition at line 256 of file DynamicEQ.h.

◆ setState()

template<FloatType T, int MaxBands = 8>
bool dspark::DynamicEQ< T, MaxBands >::setState ( const uint8_t *  data,
size_t  size 
)
inline

Restores bands from a blob (tolerant; rejects foreign ids).

Definition at line 354 of file DynamicEQ.h.


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