DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
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.
 
T 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.
 
T 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 236 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 224 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 300 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 310 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 319 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 325 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 307 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 316 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 345 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. A block longer than the prepared maxBlockSize is processed in consecutive chunks of that size (the tail of an oversized block used to be left unprocessed: dry, unfiltered); channels beyond the prepared count pass through.

Parameters
bufferIn/Out audio buffer view.

Definition at line 101 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 337 of file MultibandCompressor.h.

◆ setBandAttack()

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

Sets the attack time for a specific band.

Parameters
bandTarget band index.
msAttack time in milliseconds.

Definition at line 272 of file MultibandCompressor.h.

◆ setBandRatio()

template<FloatType T, int MaxBands = 12>
void dspark::MultibandCompressor< T, MaxBands >::setBandRatio ( int  band,
T  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 261 of file MultibandCompressor.h.

◆ setBandRelease()

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

Sets the release time for a specific band.

Parameters
bandTarget band index.
msRelease time in milliseconds.

Definition at line 283 of file MultibandCompressor.h.

◆ setBandThreshold()

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

Sets the threshold for a specific band.

Parameters
bandTarget band index.
dBThreshold in decibels.

Definition at line 250 of file MultibandCompressor.h.

◆ setCrossoverFrequency()

template<FloatType T, int MaxBands = 12>
void dspark::MultibandCompressor< T, MaxBands >::setCrossoverFrequency ( int  index,
T  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 194 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 212 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 184 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 203 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 367 of file MultibandCompressor.h.


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