DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::MultibandSaturation< T, MaxBands > Class Template Reference

Multi-band saturation: crossover split, a Saturation per band, sum. More...

#include <MultibandSaturation.h>

Public Types

using Crossover = CrossoverFilter< T, MaxBands >
 

Public Member Functions

 MultibandSaturation ()
 
 MultibandSaturation (const MultibandSaturation &)=delete
 
MultibandSaturation & operator= (const MultibandSaturation &)=delete
 
void prepare (const AudioSpec &spec)
 Prepares the crossover, every band and the buffers.
 
void reset () noexcept
 Clears the crossover, the bands and the alignment delays.
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes audio through the bands, in place.
 
void setNumBands (int n) noexcept
 Number of bands (2..MaxBands; any thread; re-spaces the split frequencies; a live change fades, see CrossoverFilter::setNumBands()).
 
void setNumBandsKeepingSplits (int n) noexcept
 Number of bands keeping the split frequencies (any thread; see CrossoverFilter::setNumBandsKeepingSplits()).
 
void setCrossoverFrequency (int index, T hz) noexcept
 Sets a split frequency (any thread).
 
void setOrder (int order) noexcept
 Slope of the crossover in dB per octave (any thread; see CrossoverFilter::setOrder()).
 
void setCrossoverMode (typename Crossover::FilterMode mode) noexcept
 Minimum-phase (IIR) or linear-phase crossover (any thread; see CrossoverFilter).
 
void setCrossoverStructure (typename Crossover::Structure structure) noexcept
 Direct-form or ladder sections in the minimum-phase crossover (any thread; see CrossoverFilter::setStructure()).
 
void setCrossoverTopology (typename Crossover::Topology topology) noexcept
 Cascade or balanced arrangement of the minimum-phase splits (any thread; see CrossoverFilter::setTopology()).
 
int getNumBands () const noexcept
 
T getCrossoverFrequency (int index) const noexcept
 
int getOrder () const noexcept
 
Crossover::FilterMode getCrossoverMode () const noexcept
 
Crossover::Structure getCrossoverStructure () const noexcept
 
Crossover::Topology getCrossoverTopology () const noexcept
 
Saturation< T > & getBandSaturation (int band) noexcept
 The Saturation of a band (the index is clamped).
 
const Saturation< T > & getBandSaturation (int band) const noexcept
 The Saturation of a band (the index is clamped).
 
void setBandAlgorithm (int band, typename Saturation< T >::Algorithm algo)
 The algorithm of a band (any thread).
 
void setBandDrive (int band, T dB)
 The drive of a band in dB (any thread).
 
void setBandLevel (int band, T dB) noexcept
 Level of a band in dB, -60 to +24 (any thread; glides over 20 ms).
 
void setBandPan (int band, T pan) noexcept
 Pan of a band, -1 (left) to +1 (right); a balance that never lifts a side (any thread).
 
void setBandMute (int band, bool on) noexcept
 Mutes a band (any thread; fades over 20 ms).
 
void setBandSolo (int band, bool on) noexcept
 Solos a band: while any band is soloed only the soloed ones are heard (any thread; fades over 20 ms).
 
T getBandLevel (int band) const noexcept
 
T getBandPan (int band) const noexcept
 
bool isBandMuted (int band) const noexcept
 
bool isBandSoloed (int band) const noexcept
 
bool isBandComputed (int band) const noexcept
 Whether a band is computed now (false while it is not heard; audio-thread state).
 
void setMix (T amount) noexcept
 Blends the sum of the bands with the programme, 0 (dry) to 1 (the default: the bands alone; any thread; glides over 20 ms).
 
T getMix () const noexcept
 
void setOutputClip (bool on) noexcept
 An oversampled clipper after the sum (off by default; any thread).
 
bool getOutputClip () const noexcept
 
void setOutputCeiling (T dB) noexcept
 Ceiling of the output clipper, -24 to 0 dBFS (default 0; any thread).
 
T getOutputCeiling () const noexcept
 
void setOversampling (int factor)
 The oversampling factor of every band (NOT real-time safe; see Saturation::setOversampling()).
 
void setOversamplingMode (typename Saturation< T >::OversamplingMode mode)
 The oversampler filters of every band (NOT real-time safe).
 
void setOversamplingBand (typename Saturation< T >::OversamplingBand band)
 The band the first stage of every band's oversampler keeps (NOT real-time safe; see Saturation::setOversamplingBand()).
 
void setAntialiasing (typename Saturation< T >::Antialiasing mode) noexcept
 The antialiasing order of every band.
 
int getLatency () const noexcept
 Latency in samples: the crossover's and the slowest band's.
 
std::vector< uint8_t > getState () const
 Serializes the crossover, each band's Saturation and its level, pan, mute and solo.
 
bool setState (const uint8_t *data, size_t size)
 Restores what getState() wrote (setup thread: the bands may reallocate).
 

Detailed Description

template<FloatType T, int MaxBands = 6>
class dspark::MultibandSaturation< T, MaxBands >

Multi-band saturation: crossover split, a Saturation per band, sum.

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

Definition at line 83 of file MultibandSaturation.h.

Member Typedef Documentation

◆ Crossover

template<FloatType T, int MaxBands = 6>
using dspark::MultibandSaturation< T, MaxBands >::Crossover = CrossoverFilter<T, MaxBands>

Definition at line 88 of file MultibandSaturation.h.

Constructor & Destructor Documentation

◆ MultibandSaturation() [1/2]

template<FloatType T, int MaxBands = 6>
dspark::MultibandSaturation< T, MaxBands >::MultibandSaturation ( )
inline

Definition at line 90 of file MultibandSaturation.h.

◆ MultibandSaturation() [2/2]

template<FloatType T, int MaxBands = 6>
dspark::MultibandSaturation< T, MaxBands >::MultibandSaturation ( const MultibandSaturation< T, MaxBands > &  )
delete

Member Function Documentation

◆ getBandLevel()

template<FloatType T, int MaxBands = 6>
T dspark::MultibandSaturation< T, MaxBands >::getBandLevel ( int  band) const
inlinenoexcept

Definition at line 238 of file MultibandSaturation.h.

◆ getBandPan()

template<FloatType T, int MaxBands = 6>
T dspark::MultibandSaturation< T, MaxBands >::getBandPan ( int  band) const
inlinenoexcept

Definition at line 239 of file MultibandSaturation.h.

◆ getBandSaturation() [1/2]

template<FloatType T, int MaxBands = 6>
const Saturation< T > & dspark::MultibandSaturation< T, MaxBands >::getBandSaturation ( int  band) const
inlinenoexcept

The Saturation of a band (the index is clamped).

Definition at line 203 of file MultibandSaturation.h.

◆ getBandSaturation() [2/2]

template<FloatType T, int MaxBands = 6>
Saturation< T > & dspark::MultibandSaturation< T, MaxBands >::getBandSaturation ( int  band)
inlinenoexcept

The Saturation of a band (the index is clamped).

Definition at line 198 of file MultibandSaturation.h.

◆ getCrossoverFrequency()

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

Definition at line 189 of file MultibandSaturation.h.

◆ getCrossoverMode()

template<FloatType T, int MaxBands = 6>
Crossover::FilterMode dspark::MultibandSaturation< T, MaxBands >::getCrossoverMode ( ) const
inlinenoexcept

Definition at line 191 of file MultibandSaturation.h.

◆ getCrossoverStructure()

template<FloatType T, int MaxBands = 6>
Crossover::Structure dspark::MultibandSaturation< T, MaxBands >::getCrossoverStructure ( ) const
inlinenoexcept

Definition at line 192 of file MultibandSaturation.h.

◆ getCrossoverTopology()

template<FloatType T, int MaxBands = 6>
Crossover::Topology dspark::MultibandSaturation< T, MaxBands >::getCrossoverTopology ( ) const
inlinenoexcept

Definition at line 193 of file MultibandSaturation.h.

◆ getLatency()

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

Latency in samples: the crossover's and the slowest band's.

Every band is delayed to the slowest band's latency, so this is the latency of the sum whatever each band runs with; the output clipper adds its own while it is on.

Definition at line 323 of file MultibandSaturation.h.

◆ getMix()

template<FloatType T, int MaxBands = 6>
T dspark::MultibandSaturation< T, MaxBands >::getMix ( ) const
inlinenoexcept

Definition at line 269 of file MultibandSaturation.h.

◆ getNumBands()

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

Definition at line 188 of file MultibandSaturation.h.

◆ getOrder()

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

Definition at line 190 of file MultibandSaturation.h.

◆ getOutputCeiling()

template<FloatType T, int MaxBands = 6>
T dspark::MultibandSaturation< T, MaxBands >::getOutputCeiling ( ) const
inlinenoexcept

Definition at line 290 of file MultibandSaturation.h.

◆ getOutputClip()

template<FloatType T, int MaxBands = 6>
bool dspark::MultibandSaturation< T, MaxBands >::getOutputClip ( ) const
inlinenoexcept

Definition at line 281 of file MultibandSaturation.h.

◆ getState()

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

Serializes the crossover, each band's Saturation and its level, pan, mute and solo.

Definition at line 332 of file MultibandSaturation.h.

◆ isBandComputed()

template<FloatType T, int MaxBands = 6>
bool dspark::MultibandSaturation< T, MaxBands >::isBandComputed ( int  band) const
inlinenoexcept

Whether a band is computed now (false while it is not heard; audio-thread state).

Definition at line 244 of file MultibandSaturation.h.

◆ isBandMuted()

template<FloatType T, int MaxBands = 6>
bool dspark::MultibandSaturation< T, MaxBands >::isBandMuted ( int  band) const
inlinenoexcept

Definition at line 240 of file MultibandSaturation.h.

◆ isBandSoloed()

template<FloatType T, int MaxBands = 6>
bool dspark::MultibandSaturation< T, MaxBands >::isBandSoloed ( int  band) const
inlinenoexcept

Definition at line 241 of file MultibandSaturation.h.

◆ operator=()

template<FloatType T, int MaxBands = 6>
MultibandSaturation & dspark::MultibandSaturation< T, MaxBands >::operator= ( const MultibandSaturation< T, MaxBands > &  )
delete

◆ prepare()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::prepare ( const AudioSpec &  spec)
inline

Prepares the crossover, every band and the buffers.

Invalid specs are ignored. May allocate; setup thread only.

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

Definition at line 107 of file MultibandSaturation.h.

◆ processBlock()

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

Processes audio through the bands, in place.

Pass-through until prepare() succeeds. A block longer than the prepared maxBlockSize is processed in pieces of that size; channels beyond the prepared count pass through.

Definition at line 161 of file MultibandSaturation.h.

◆ reset()

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

Clears the crossover, the bands and the alignment delays.

Definition at line 133 of file MultibandSaturation.h.

◆ setAntialiasing()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setAntialiasing ( typename Saturation< T >::Antialiasing  mode)
inlinenoexcept

The antialiasing order of every band.

Definition at line 311 of file MultibandSaturation.h.

◆ setBandAlgorithm()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setBandAlgorithm ( int  band,
typename Saturation< T >::Algorithm  algo 
)
inline

The algorithm of a band (any thread).

Definition at line 209 of file MultibandSaturation.h.

◆ setBandDrive()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setBandDrive ( int  band,
T  dB 
)
inline

The drive of a band in dB (any thread).

Definition at line 211 of file MultibandSaturation.h.

◆ setBandLevel()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setBandLevel ( int  band,
T  dB 
)
inlinenoexcept

Level of a band in dB, -60 to +24 (any thread; glides over 20 ms).

Definition at line 214 of file MultibandSaturation.h.

◆ setBandMute()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setBandMute ( int  band,
bool  on 
)
inlinenoexcept

Mutes a band (any thread; fades over 20 ms).

Definition at line 226 of file MultibandSaturation.h.

◆ setBandPan()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setBandPan ( int  band,
T  pan 
)
inlinenoexcept

Pan of a band, -1 (left) to +1 (right); a balance that never lifts a side (any thread).

Definition at line 220 of file MultibandSaturation.h.

◆ setBandSolo()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setBandSolo ( int  band,
bool  on 
)
inlinenoexcept

Solos a band: while any band is soloed only the soloed ones are heard (any thread; fades over 20 ms).

Definition at line 232 of file MultibandSaturation.h.

◆ setCrossoverFrequency()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setCrossoverFrequency ( int  index,
T  hz 
)
inlinenoexcept

Sets a split frequency (any thread).

Definition at line 178 of file MultibandSaturation.h.

◆ setCrossoverMode()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setCrossoverMode ( typename Crossover::FilterMode  mode)
inlinenoexcept

Minimum-phase (IIR) or linear-phase crossover (any thread; see CrossoverFilter).

Definition at line 182 of file MultibandSaturation.h.

◆ setCrossoverStructure()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setCrossoverStructure ( typename Crossover::Structure  structure)
inlinenoexcept

Direct-form or ladder sections in the minimum-phase crossover (any thread; see CrossoverFilter::setStructure()).

Definition at line 184 of file MultibandSaturation.h.

◆ setCrossoverTopology()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setCrossoverTopology ( typename Crossover::Topology  topology)
inlinenoexcept

Cascade or balanced arrangement of the minimum-phase splits (any thread; see CrossoverFilter::setTopology()).

Definition at line 186 of file MultibandSaturation.h.

◆ setMix()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setMix ( T  amount)
inlinenoexcept

Blends the sum of the bands with the programme, 0 (dry) to 1 (the default: the bands alone; any thread; glides over 20 ms).

The dry side is the programme as the crossover leaves it (the bands summed without their curves) and as late as the slowest band, so it meets the processed bands in the crossover's phase: with no drive a mix of one half is as flat as the crossover is, at the splits too. Each band's dry side crosses what that band's does: the filters of minimum-phase oversampling, and between the two ends the phase (not the magnitude) of its Saturation's high-passes, so a mix of one half is the mean of the two levels at the bottom and at the top as well. Each band's own Saturation mix still acts inside its band.

Definition at line 265 of file MultibandSaturation.h.

◆ setNumBands()

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

Number of bands (2..MaxBands; any thread; re-spaces the split frequencies; a live change fades, see CrossoverFilter::setNumBands()).

Definition at line 174 of file MultibandSaturation.h.

◆ setNumBandsKeepingSplits()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setNumBandsKeepingSplits ( int  n)
inlinenoexcept

Number of bands keeping the split frequencies (any thread; see CrossoverFilter::setNumBandsKeepingSplits()).

Definition at line 176 of file MultibandSaturation.h.

◆ setOrder()

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

Slope of the crossover in dB per octave (any thread; see CrossoverFilter::setOrder()).

Definition at line 180 of file MultibandSaturation.h.

◆ setOutputCeiling()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setOutputCeiling ( T  dB)
inlinenoexcept

Ceiling of the output clipper, -24 to 0 dBFS (default 0; any thread).

Definition at line 284 of file MultibandSaturation.h.

◆ setOutputClip()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setOutputClip ( bool  on)
inlinenoexcept

An oversampled clipper after the sum (off by default; any thread).

Driven bands add up to more than any one of them (six bands at their ceilings sum to several times full scale). With this on, the sum is clipped at setOutputCeiling() four times oversampled, and no sample leaves over the ceiling; under it nothing changes but the latency, which grows by the clipper's (getLatency() reports it).

Definition at line 280 of file MultibandSaturation.h.

◆ setOversampling()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setOversampling ( int  factor)
inline

The oversampling factor of every band (NOT real-time safe; see Saturation::setOversampling()).

Definition at line 295 of file MultibandSaturation.h.

◆ setOversamplingBand()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setOversamplingBand ( typename Saturation< T >::OversamplingBand  band)
inline

The band the first stage of every band's oversampler keeps (NOT real-time safe; see Saturation::setOversamplingBand()).

Definition at line 306 of file MultibandSaturation.h.

◆ setOversamplingMode()

template<FloatType T, int MaxBands = 6>
void dspark::MultibandSaturation< T, MaxBands >::setOversamplingMode ( typename Saturation< T >::OversamplingMode  mode)
inline

The oversampler filters of every band (NOT real-time safe).

Definition at line 300 of file MultibandSaturation.h.

◆ setState()

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

Restores what getState() wrote (setup thread: the bands may reallocate).

Definition at line 367 of file MultibandSaturation.h.


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