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

Multi-band compressor: crossover split, per-band compression, sum. More...

#include <MultibandCompressor.h>

Public Member Functions

void prepare (const AudioSpec &spec)
 Prepares the multiband compressor and internal buffers for processing.
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes audio through the multi-band compressor.
 
void setNumBands (int n) noexcept
 Sets the number of active frequency bands.
 
void setCrossoverFrequency (int index, T freqHz) noexcept
 Sets the crossover frequency for a specific split point.
 
void setOrder (int order) noexcept
 Sets the crossover slope in dB/oct: 12, 24 or 48.
 
void setCrossoverMode (typename CrossoverFilter< T, MaxBands >::FilterMode mode) noexcept
 Sets the phase/processing mode of the crossover (IIR or linear-phase).
 
Compressor< T > & getBandCompressor (int band) noexcept
 Direct access to a band's compressor for full configuration.
 
const Compressor< T > & getBandCompressor (int band) const noexcept
 Direct constant access to a band's compressor for state queries.
 
void setBandThreshold (int band, T dB) noexcept
 Sets the threshold for a specific band.
 
void setBandRatio (int band, T ratio) noexcept
 Sets the ratio for a specific band.
 
void setBandAttack (int band, T ms) noexcept
 Sets the attack time for a specific band.
 
void setBandRelease (int band, T ms) noexcept
 Sets the release time for a specific band.
 
getBandGainReductionDb (int band) const noexcept
 Gets the current gain reduction applied to a specific band.
 
int getNumBands () const noexcept
 Returns the current number of active bands.
 
getCrossoverFrequency (int index) const noexcept
 Returns the target frequency of split point index in Hz.
 
int getOrder () const noexcept
 Returns the crossover slope in dB/oct (12, 24 or 48).
 
CrossoverFilter< T, MaxBands >::FilterMode getCrossoverMode () const noexcept
 Returns the crossover processing mode (IIR or linear-phase).
 
int getLatency () const noexcept
 Returns the total latency of the multi-band system.
 
void reset () noexcept
 Resets all internal states (envelopes, delay lines, etc.).
 
std::vector< uint8_t > getState () const
 Serializes crossover topology and per-band compressor states.
 
bool setState (const uint8_t *data, size_t size)
 Restores topology and band compressors from a blob.
 

Detailed Description

template<FloatType T, int MaxBands = 12>
class dspark::MultibandCompressor< T, MaxBands >

Multi-band compressor: crossover split, per-band compression, sum.

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

Definition at line 58 of file MultibandCompressor.h.

Member Function Documentation

◆ getBandCompressor() [1/2]

template<FloatType T, int MaxBands = 12>
const Compressor< T > & dspark::MultibandCompressor< T, MaxBands >::getBandCompressor ( int  band) const
inlinenoexcept

Direct constant access to a band's compressor for state queries.

Parameters
bandBand index. Clamped safely to valid range in release mode.
Returns
Const reference to the requested Compressor.

Definition at line 223 of file MultibandCompressor.h.

◆ getBandCompressor() [2/2]

template<FloatType T, int MaxBands = 12>
Compressor< T > & dspark::MultibandCompressor< T, MaxBands >::getBandCompressor ( int  band)
inlinenoexcept

Direct access to a band's compressor for full configuration.

Parameters
bandBand index. Clamped safely to valid range in release mode.
Returns
Reference to the requested Compressor.

Definition at line 211 of file MultibandCompressor.h.

◆ getBandGainReductionDb()

template<FloatType T, int MaxBands = 12>
T dspark::MultibandCompressor< T, MaxBands >::getBandGainReductionDb ( int  band) const
inlinenoexcept

Gets the current gain reduction applied to a specific band.

Metering read, safe from any thread. Bands that are currently disabled report the value frozen from when they were last active.

Parameters
bandTarget band index.
Returns
Gain reduction in decibels (typically <= 0.0).

Definition at line 287 of file MultibandCompressor.h.

◆ getCrossoverFrequency()

template<FloatType T, int MaxBands = 12>
T dspark::MultibandCompressor< T, MaxBands >::getCrossoverFrequency ( int  index) const
inlinenoexcept

Returns the target frequency of split point index in Hz.

Definition at line 297 of file MultibandCompressor.h.

◆ getCrossoverMode()

template<FloatType T, int MaxBands = 12>
CrossoverFilter< T, MaxBands >::FilterMode dspark::MultibandCompressor< T, MaxBands >::getCrossoverMode ( ) const
inlinenoexcept

Returns the crossover processing mode (IIR or linear-phase).

Definition at line 306 of file MultibandCompressor.h.

◆ getLatency()

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

Returns the total latency of the multi-band system.

Definition at line 312 of file MultibandCompressor.h.

◆ getNumBands()

template<FloatType T, int MaxBands = 12>
int dspark::MultibandCompressor< T, MaxBands >::getNumBands ( ) const
inlinenoexcept

Returns the current number of active bands.

Definition at line 294 of file MultibandCompressor.h.

◆ getOrder()

template<FloatType T, int MaxBands = 12>
int dspark::MultibandCompressor< T, MaxBands >::getOrder ( ) const
inlinenoexcept

Returns the crossover slope in dB/oct (12, 24 or 48).

Definition at line 303 of file MultibandCompressor.h.

◆ getState()

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

Serializes crossover topology and per-band compressor states.

Definition at line 332 of file MultibandCompressor.h.

◆ prepare()

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

Prepares the multiband compressor and internal buffers for processing.

Invalid specs (non-positive/non-finite rate, block size or channel count) are ignored: the previous state is kept and an unprepared instance stays pass-through. May allocate; setup thread only.

Parameters
specThe audio specification (sample rate, max block size, channels).

Definition at line 74 of file MultibandCompressor.h.

◆ processBlock()

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

Processes audio through the multi-band compressor.

Pass-through until prepare() succeeds. The processed span is clamped to the prepared maxBlockSize (trailing samples of an oversized block are left untouched); channels beyond the prepared count pass through.

Parameters
bufferIn/Out audio buffer view.

Definition at line 100 of file MultibandCompressor.h.

◆ reset()

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

Resets all internal states (envelopes, delay lines, etc.).

Definition at line 324 of file MultibandCompressor.h.

◆ setBandAttack()

template<FloatType T, int MaxBands = 12>
void dspark::MultibandCompressor< T, MaxBands >::setBandAttack ( int  band,
ms 
)
inlinenoexcept

Sets the attack time for a specific band.

Parameters
bandTarget band index.
msAttack time in milliseconds.

Definition at line 259 of file MultibandCompressor.h.

◆ setBandRatio()

template<FloatType T, int MaxBands = 12>
void dspark::MultibandCompressor< T, MaxBands >::setBandRatio ( int  band,
ratio 
)
inlinenoexcept

Sets the ratio for a specific band.

Parameters
bandTarget band index.
ratioCompression ratio (e.g., 4.0 for 4:1).

Definition at line 248 of file MultibandCompressor.h.

◆ setBandRelease()

template<FloatType T, int MaxBands = 12>
void dspark::MultibandCompressor< T, MaxBands >::setBandRelease ( int  band,
ms 
)
inlinenoexcept

Sets the release time for a specific band.

Parameters
bandTarget band index.
msRelease time in milliseconds.

Definition at line 270 of file MultibandCompressor.h.

◆ setBandThreshold()

template<FloatType T, int MaxBands = 12>
void dspark::MultibandCompressor< T, MaxBands >::setBandThreshold ( int  band,
dB 
)
inlinenoexcept

Sets the threshold for a specific band.

Parameters
bandTarget band index.
dBThreshold in decibels.

Definition at line 237 of file MultibandCompressor.h.

◆ setCrossoverFrequency()

template<FloatType T, int MaxBands = 12>
void dspark::MultibandCompressor< T, MaxBands >::setCrossoverFrequency ( int  index,
freqHz 
)
inlinenoexcept

Sets the crossover frequency for a specific split point.

Parameters
indexSplit point index (0 is between band 0 and 1).
freqHzTarget frequency in Hertz (non-finite values are ignored).

Definition at line 181 of file MultibandCompressor.h.

◆ setCrossoverMode()

template<FloatType T, int MaxBands = 12>
void dspark::MultibandCompressor< T, MaxBands >::setCrossoverMode ( typename CrossoverFilter< T, MaxBands >::FilterMode  mode)
inlinenoexcept

Sets the phase/processing mode of the crossover (IIR or linear-phase).

Parameters
modeSelected filter mode from the CrossoverFilter enum.

Definition at line 199 of file MultibandCompressor.h.

◆ setNumBands()

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

Sets the number of active frequency bands.

Safe from any thread. A live change applies instantly (audible click) and re-initialises ALL split frequencies to the crossover's log-spaced defaults - reapply custom frequencies afterwards (see CrossoverFilter::setNumBands). Compressors of newly enabled bands are reset on the audio thread so they start clean.

Parameters
nNumber of bands (clamped between 2 and MaxBands - a crossover needs at least one split point).

Definition at line 171 of file MultibandCompressor.h.

◆ setOrder()

template<FloatType T, int MaxBands = 12>
void dspark::MultibandCompressor< T, MaxBands >::setOrder ( int  order)
inlinenoexcept

Sets the crossover slope in dB/oct: 12, 24 or 48.

Parameters
orderSlope in dB/oct; other values are ignored (see CrossoverFilter::setOrder).

Definition at line 190 of file MultibandCompressor.h.

◆ setState()

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

Restores topology and band compressors from a blob.

Definition at line 354 of file MultibandCompressor.h.


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