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

Multi-voice chorus/flanger with true stereo spread and smooth parameter handling. More...

#include <Chorus.h>

Collaboration diagram for dspark::Chorus< T >:

Public Types

enum class  Interpolation { Hermite , Sinc , Linear }
 Fractional read kernel of the modulated delay lines. More...
 
enum class  Model { Digital , Analog }
 The engine (setModel()). More...
 
enum class  AnalogMode { Slow , Fast , Vibrato }
 Presets of the analog model (setAnalogMode()). More...
 

Public Member Functions

 ~Chorus ()=default
 
void prepare (const AudioSpec &spec)
 Prepares the chorus for processing, allocating delay lines.
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes an audio block in-place.
 
void reset () noexcept
 Resets delay lines and LFO phases.
 
void setInterpolation (Interpolation mode) noexcept
 Selects the fractional read kernel. Thread-safe; an out-of-range value reads as Hermite.
 
Interpolation getInterpolation () const noexcept
 Returns the fractional read kernel.
 
void setRate (T hz) noexcept
 Sets the LFO modulation rate.
 
void setDepthMs (T ms) noexcept
 Sets the LFO modulation depth in milliseconds.
 
void setMix (T dryWet) noexcept
 Sets the wet/dry mix ratio.
 
void setVoices (int count) noexcept
 Sets the number of active voices per channel.
 
void setFeedback (T amount) noexcept
 Sets the feedback gain.
 
void setCenterDelay (T ms) noexcept
 Sets the base delay time.
 
void setStereoSpread (T amount) noexcept
 Sets the stereo spread amount.
 
void setAutoDepth (bool enabled) noexcept
 Couples depth to rate automatically to prevent pitch artifacts at high speeds.
 
void setModWaveform (typename Oscillator< T >::Waveform wf) noexcept
 Sets the oscillator waveform for all voices.
 
void setModel (Model m) noexcept
 Selects the engine (see Model). Thread-safe; the change fills the incoming engine, then crosses over (see the file notes).
 
Model getModel () const noexcept
 
T getRate () const noexcept
 
T getDepthMs () const noexcept
 
T getCenterDelay () const noexcept
 
void setAnalogMode (AnalogMode mode) noexcept
 Loads a preset of the analog model: rate, depth and centre (through their setters) and whether the taps move in opposition or in phase (setAnalogTapPhase()). In the analog model the centre, the depth and the taps' offset glide to a new setting with a 50 ms time constant (the rate only changes the sweep's speed, so it needs none). Out-of-range values are clamped.
 
AnalogMode getAnalogMode () const noexcept
 
void setAnalogNoise (T dB) noexcept
 Hiss of the analog lines: its RMS level in dBFS at the centre delay (it grows in proportion to the delay), the same at any rate; -120 and below turn it off (default -84). Non-finite values are ignored.
 
T getAnalogNoise () const noexcept
 
void setAnalogTapPhase (T degrees) noexcept
 The offset between the analog model's two taps, 0 to 180 degrees of the sweep (180 in opposition, 0 in phase; the presets set 180, and 0 for Vibrato). It glides with the 50 ms of the analog settings. Non-finite values are ignored.
 
T getAnalogTapPhase () const noexcept
 
void setAnalogTone (T tone) noexcept
 The tone of the analog wet, -1 to 1: the corner of the filter after the lines moves by up to an octave down or up (0, the default, leaves it at 7 kHz; 5.6 kHz with the circuit pair). Non-finite values are ignored.
 
T getAnalogTone () const noexcept
 
void setAnalogCircuitFilters (bool on) noexcept
 The analog lines with the filter pair of a chorus circuit (see the file notes) instead of the Butterworth pair. Thread-safe; applied at the next block.
 
bool getAnalogCircuitFilters () const noexcept
 
void setMixRule (typename DryWetMixer< T >::MixRule rule) noexcept
 The rule of the dry/wet mix (Linear by default; see DryWetMixer::MixRule). Thread-safe.
 
DryWetMixer< T >::MixRule getMixRule () const noexcept
 
std::vector< uint8_t > getState () const
 Serializes the parameter state (setup/UI threads; allocates).
 
bool setState (const uint8_t *data, size_t size)
 Restores parameters from a blob (tolerant; rejects foreign ids).
 

Static Public Attributes

static constexpr int kMaxVoices = 4
 
static constexpr int kMaxChannels = 16
 

Protected Member Functions

T targetPhase (int ch, int v, int nv, T spread) const noexcept
 Phase offset of a channel/voice LFO from channel 0, voice 0.
 
void updateLfoPhases () noexcept
 Sets every LFO phase to its target outright (prepare and reset; while running, the LFOs glide instead).
 
T readSinc (const RingBuffer< T > &ring, T delay) const noexcept
 Sinc read delay samples behind the newest sample of ring (the RingBuffer::read() convention; needs delay >= 16).
 
T readTap (const RingBuffer< T > &ring, T delay, Interpolation interp) const noexcept
 One modulated read with the selected kernel.
 
void processChunk (AudioBufferView< T > buffer) noexcept
 One block of at most the prepared size.
 
void runEngine (Model engine, AudioBufferView< T > buffer, int nCh, int nS) noexcept
 
void startSwitch (Model to) noexcept
 Starts a change of engine: the incoming one from silence, unheard until its line is full.
 
void processSwitch (AudioBufferView< T > buffer, int nCh, int nS) noexcept
 A block of a change of engine: both run; the incoming one is heard once its line is full.
 
void processDigital (AudioBufferView< T > buffer, int nCh, int nS) noexcept
 The digital engine on one block (wet only).
 
void processAnalog (AudioBufferView< T > buffer, int nCh, int nS) noexcept
 The analog model on one block: the mono sum, high-passed, into two bucket-brigade lines (sharing their input low-pass) whose delays a slightly asymmetric triangle moves, each with its hiss; the even channels take the first line, the odd ones the second.
 
void advanceAnalogPhase (double step) noexcept
 Moves the sweep's phase by step periods of time: the phase runs at 0.5 / kRise per period on its rising half and at 0.5 / (1 - kRise) on its falling half, so the rise takes kRise of the period.
 

Static Protected Member Functions

static const SincInterpolator< T > & sincTable ()
 The shared sinc table (built on first use: prepare() calls it).
 
static T moveTowards (T from, T to, T delta) noexcept
 

Protected Attributes

AudioSpec spec_ {}
 
int maxDelaySamples_ { 0 }
 
std::atomic< T > rate_ { T(1) }
 
std::atomic< T > depthMs_ { T(3.5) }
 
std::atomic< T > mix_ { T(0.5) }
 
std::atomic< T > feedback_ { T(0) }
 
std::atomic< T > centerDelayMs_ { T(7) }
 
std::atomic< T > stereoSpread_ { T(0.5) }
 
std::atomic< int > numVoices_ { 2 }
 
std::atomic< bool > autoDepth_ { false }
 
T lastSpread_ { T(0.5) }
 
std::atomic< typename Oscillator< T >::Waveform > lfoWaveform_ { Oscillator<T>::Waveform::Sine }
 
std::atomic< bool > lfoPhaseDirty_ { false }
 
std::atomic< bool > waveformDirty_ { false }
 
T smoothedCenterSamples_ { T(0) }
 
T smoothedDepthSamples_ { T(0) }
 
std::array< RingBuffer< T >, kMaxChannels > delayLines_ {}
 
std::array< std::array< Oscillator< T >, kMaxVoices >, kMaxChannels > lfos_ {}
 
std::array< T, kMaxChannels > fbState_ {}
 
std::array< T, kMaxVoices > voiceGain_ {}
 Voice fades (audio thread).
 
T voiceFadeStep_ = T(1)
 
std::atomic< Interpolation > interpolation_ { Interpolation::Hermite }
 
const SincInterpolator< T > * sinc_ = nullptr
 Set by prepare().
 
DryWetMixer< T > mixer_
 
std::atomic< Model > model_ { Model::Digital }
 
std::atomic< int > analogMode_ { 0 }
 
std::atomic< T > analogNoiseDb_ { T(-84) }
 
std::atomic< T > analogTapPhase_ { T(180) }
 
std::atomic< T > analogTone_ { T(0) }
 
std::atomic< bool > analogCircuit_ { false }
 
bool circuitFor_ = false
 
double analogToneFor_ = 0.0
 
double hissHpCoeff_ = 0.0
 
std::array< double, 2 > hissHpX_ {}
 
std::array< double, 2 > hissHpY_ {}
 
Model playing_ = Model::Digital
 
Model incoming_ = Model::Digital
 
bool switching_ = false
 
int fillLeft_ = 0
 
int fadeLeft_ = 0
 
int switchFade_ = 480
 
AudioBuffer< T > switchBuffer_
 
std::array< BucketBrigade< T >, 2 > bbd_ {}
 
bool halfRate_ = false
 
double engineRate_ = 48000.0
 
double analogCornerFor_ = -1.0
 
double hpCoeff_ = 0.0
 
double noiseCoeff_ = 0.0
 
double analogPhase_ = 0.0
 
double hpX1_ = 0.0
 
double hpY1_ = 0.0
 
double analogGlide_ = 1.0
 
double centreNow_ = 0.0
 
double depthNow_ = 0.0
 
double offsetNow_ = 0.5
 
double centreFrom_ = 0.0
 
double depthFrom_ = 0.0
 
bool analogPrimed_ = false
 
std::array< BiquadCoeffs, 2 > decimate_ {}
 
std::array< std::array< double, 2 >, 2 > decimateState_ {}
 
std::array< double, 2 > engineOut_ {}
 
std::array< double, 2 > engineLast_ {}
 
std::array< double, 2 > noiseLp_ {}
 
int decimatePhase_ = 0
 
uint32_t noiseRng_ = 0x6B43A9u
 

Static Protected Attributes

static constexpr int kAnalogStages = 512
 Stages of each analog line.
 
static constexpr double kRise = 0.53
 The sweep's rising share of its period.
 
static constexpr double kAnalogGlideSeconds = 0.05
 Glide of the analog centre, depth and offset.
 
static constexpr double kCornerOctaveSeconds = 0.25
 The analog filters' corner moves an octave in this time at most.
 
static constexpr double kAnalogCornerHz = 7000.0
 The analog filters' corner (tone 0).
 
static constexpr double kAnalogClockShare = 0.2
 The corner at most this share of the slowest clock.
 
static constexpr double kCircuitInputHz = 8000.0
 The circuit pair: the input filter's corner.
 
static constexpr double kCircuitOutputHz = 5600.0
 The circuit pair: the output filter's corner (tone 0).
 
static constexpr double kCircuitClockShare = 0.23
 The circuit pair's input corner at most this share of the slowest clock.
 
static constexpr double kHissHighPassHz = 200.0
 The hiss has no lows under this.
 
static constexpr double kSwitchFadeSeconds = 0.01
 A change of engine crosses over in this.
 
static constexpr double kSwitchSettleSeconds = 0.003
 The analog line's filters settle in this after it fills.
 
static constexpr T kMaxGlideHz = T(0.5)
 Phase glide: half a cycle per second.
 

Detailed Description

template<FloatType T>
class dspark::Chorus< T >

Multi-voice chorus/flanger with true stereo spread and smooth parameter handling.

Template Parameters
TSample type (float or double).

Definition at line 103 of file Chorus.h.

Member Enumeration Documentation

◆ AnalogMode

template<FloatType T>
enum class dspark::Chorus::AnalogMode
strong

Presets of the analog model (setAnalogMode()).

Enumerator
Slow 

0.5 Hz, 1.6 ms of depth about 5 ms, taps in opposition.

Fast 

0.85 Hz, the same depth and centre.

Vibrato 

7 Hz, 0.25 ms about 7 ms, taps in phase.

Definition at line 130 of file Chorus.h.

◆ Interpolation

template<FloatType T>
enum class dspark::Chorus::Interpolation
strong

Fractional read kernel of the modulated delay lines.

Enumerator
Hermite 

4-point cubic (default).

Sinc 

32-tap Kaiser sinc: transparent to 15 kHz at 44.1/48 kHz, about 5x the read cost; the shortest delay is 16 samples.

Linear 

2-point linear: its loss of highs (a gentle low-pass that moves with the fraction, -6 dB at Nyquist half way between samples) is part of the sound of many chorus units.

Definition at line 112 of file Chorus.h.

◆ Model

template<FloatType T>
enum class dspark::Chorus::Model
strong

The engine (setModel()).

Enumerator
Digital 

Delay lines read by interpolation, voices and feedback (default).

Analog 

Two bucket-brigade lines on the mono sum (see the file notes).

Definition at line 123 of file Chorus.h.

Constructor & Destructor Documentation

◆ ~Chorus()

template<FloatType T>
dspark::Chorus< T >::~Chorus ( )
default

Member Function Documentation

◆ advanceAnalogPhase()

template<FloatType T>
void dspark::Chorus< T >::advanceAnalogPhase ( double  step)
inlineprotectednoexcept

Moves the sweep's phase by step periods of time: the phase runs at 0.5 / kRise per period on its rising half and at 0.5 / (1 - kRise) on its falling half, so the rise takes kRise of the period.

Definition at line 998 of file Chorus.h.

◆ getAnalogCircuitFilters()

template<FloatType T>
bool dspark::Chorus< T >::getAnalogCircuitFilters ( ) const
inlinenoexcept
Returns
Whether the analog lines use the circuit pair.

Definition at line 467 of file Chorus.h.

◆ getAnalogMode()

template<FloatType T>
AnalogMode dspark::Chorus< T >::getAnalogMode ( ) const
inlinenoexcept
Returns
The analog preset last loaded.

Definition at line 419 of file Chorus.h.

◆ getAnalogNoise()

template<FloatType T>
T dspark::Chorus< T >::getAnalogNoise ( ) const
inlinenoexcept
Returns
The hiss level of the analog lines.

Definition at line 432 of file Chorus.h.

◆ getAnalogTapPhase()

template<FloatType T>
T dspark::Chorus< T >::getAnalogTapPhase ( ) const
inlinenoexcept
Returns
The offset between the analog taps, in degrees.

Definition at line 445 of file Chorus.h.

◆ getAnalogTone()

template<FloatType T>
T dspark::Chorus< T >::getAnalogTone ( ) const
inlinenoexcept
Returns
The tone of the analog wet.

Definition at line 458 of file Chorus.h.

◆ getCenterDelay()

template<FloatType T>
T dspark::Chorus< T >::getCenterDelay ( ) const
inlinenoexcept
Returns
The centre delay in milliseconds.

Definition at line 396 of file Chorus.h.

◆ getDepthMs()

template<FloatType T>
T dspark::Chorus< T >::getDepthMs ( ) const
inlinenoexcept
Returns
The modulation depth in milliseconds.

Definition at line 394 of file Chorus.h.

◆ getInterpolation()

template<FloatType T>
Interpolation dspark::Chorus< T >::getInterpolation ( ) const
inlinenoexcept

Returns the fractional read kernel.

Definition at line 280 of file Chorus.h.

◆ getMixRule()

template<FloatType T>
DryWetMixer< T >::MixRule dspark::Chorus< T >::getMixRule ( ) const
inlinenoexcept
Returns
The rule of the dry/wet mix.

Definition at line 472 of file Chorus.h.

◆ getModel()

template<FloatType T>
Model dspark::Chorus< T >::getModel ( ) const
inlinenoexcept
Returns
The engine.

Definition at line 389 of file Chorus.h.

◆ getRate()

template<FloatType T>
T dspark::Chorus< T >::getRate ( ) const
inlinenoexcept
Returns
The LFO rate in hertz.

Definition at line 392 of file Chorus.h.

◆ getState()

template<FloatType T>
std::vector< uint8_t > dspark::Chorus< T >::getState ( ) const
inline

Serializes the parameter state (setup/UI threads; allocates).

Definition at line 475 of file Chorus.h.

◆ moveTowards()

template<FloatType T>
static T dspark::Chorus< T >::moveTowards ( T  from,
T  to,
T  delta 
)
inlinestaticprotectednoexcept

Definition at line 842 of file Chorus.h.

◆ prepare()

template<FloatType T>
void dspark::Chorus< T >::prepare ( const AudioSpec &  spec)
inline

Prepares the chorus for processing, allocating delay lines.

An invalid spec (non-positive or non-finite fields) is a no-op that keeps the previous state.

Parameters
specAudio environment specification (sample rate, channels).

Definition at line 147 of file Chorus.h.

◆ processAnalog()

template<FloatType T>
void dspark::Chorus< T >::processAnalog ( AudioBufferView< T >  buffer,
int  nCh,
int  nS 
)
inlineprotectednoexcept

The analog model on one block: the mono sum, high-passed, into two bucket-brigade lines (sharing their input low-pass) whose delays a slightly asymmetric triangle moves, each with its hiss; the even channels take the first line, the odd ones the second.

The asymmetry lives in the speed of one phase (slower on the way up), and both taps read the same symmetric triangle of that phase, half a turn apart in opposition: the second is then the first inverted, so the two delays always add up to twice the centre, as with a triangle and an inverter; in phase (Vibrato) they are the same. The centre and the depth ramp across the block toward the values set and then glide with the taps' offset (kAnalogGlideSeconds). At half rate the sum is low-passed and every other sample runs the engine; the sample after a run is that run's output and the run's own sample the mean of it and the one before, so the output keeps one sample's delay throughout.

Definition at line 864 of file Chorus.h.

◆ processBlock()

template<FloatType T>
void dspark::Chorus< T >::processBlock ( AudioBufferView< T >  buffer)
inlinenoexcept

Processes an audio block in-place.

Channels beyond the prepared count pass through untouched.

Parameters
bufferAudio buffer view to process (planar layout expected).

Definition at line 217 of file Chorus.h.

◆ processChunk()

template<FloatType T>
void dspark::Chorus< T >::processChunk ( AudioBufferView< T >  buffer)
inlineprotectednoexcept

One block of at most the prepared size.

Definition at line 584 of file Chorus.h.

◆ processDigital()

template<FloatType T>
void dspark::Chorus< T >::processDigital ( AudioBufferView< T >  buffer,
int  nCh,
int  nS 
)
inlineprotectednoexcept

The digital engine on one block (wet only).

Definition at line 670 of file Chorus.h.

◆ processSwitch()

template<FloatType T>
void dspark::Chorus< T >::processSwitch ( AudioBufferView< T >  buffer,
int  nCh,
int  nS 
)
inlineprotectednoexcept

A block of a change of engine: both run; the incoming one is heard once its line is full.

Definition at line 637 of file Chorus.h.

◆ readSinc()

template<FloatType T>
T dspark::Chorus< T >::readSinc ( const RingBuffer< T > &  ring,
T  delay 
) const
inlineprotectednoexcept

Sinc read delay samples behind the newest sample of ring (the RingBuffer::read() convention; needs delay >= 16).

Definition at line 565 of file Chorus.h.

◆ readTap()

template<FloatType T>
T dspark::Chorus< T >::readTap ( const RingBuffer< T > &  ring,
T  delay,
Interpolation  interp 
) const
inlineprotectednoexcept

One modulated read with the selected kernel.

Definition at line 576 of file Chorus.h.

◆ reset()

template<FloatType T>
void dspark::Chorus< T >::reset ( )
inlinenoexcept

Resets delay lines and LFO phases.

Definition at line 244 of file Chorus.h.

◆ runEngine()

template<FloatType T>
void dspark::Chorus< T >::runEngine ( Model  engine,
AudioBufferView< T >  buffer,
int  nCh,
int  nS 
)
inlineprotectednoexcept

Definition at line 601 of file Chorus.h.

◆ setAnalogCircuitFilters()

template<FloatType T>
void dspark::Chorus< T >::setAnalogCircuitFilters ( bool  on)
inlinenoexcept

The analog lines with the filter pair of a chorus circuit (see the file notes) instead of the Butterworth pair. Thread-safe; applied at the next block.

Definition at line 465 of file Chorus.h.

◆ setAnalogMode()

template<FloatType T>
void dspark::Chorus< T >::setAnalogMode ( AnalogMode  mode)
inlinenoexcept

Loads a preset of the analog model: rate, depth and centre (through their setters) and whether the taps move in opposition or in phase (setAnalogTapPhase()). In the analog model the centre, the depth and the taps' offset glide to a new setting with a 50 ms time constant (the rate only changes the sweep's speed, so it needs none). Out-of-range values are clamped.

Definition at line 406 of file Chorus.h.

◆ setAnalogNoise()

template<FloatType T>
void dspark::Chorus< T >::setAnalogNoise ( T  dB)
inlinenoexcept

Hiss of the analog lines: its RMS level in dBFS at the centre delay (it grows in proportion to the delay), the same at any rate; -120 and below turn it off (default -84). Non-finite values are ignored.

Definition at line 427 of file Chorus.h.

◆ setAnalogTapPhase()

template<FloatType T>
void dspark::Chorus< T >::setAnalogTapPhase ( T  degrees)
inlinenoexcept

The offset between the analog model's two taps, 0 to 180 degrees of the sweep (180 in opposition, 0 in phase; the presets set 180, and 0 for Vibrato). It glides with the 50 ms of the analog settings. Non-finite values are ignored.

Definition at line 440 of file Chorus.h.

◆ setAnalogTone()

template<FloatType T>
void dspark::Chorus< T >::setAnalogTone ( T  tone)
inlinenoexcept

The tone of the analog wet, -1 to 1: the corner of the filter after the lines moves by up to an octave down or up (0, the default, leaves it at 7 kHz; 5.6 kHz with the circuit pair). Non-finite values are ignored.

Definition at line 453 of file Chorus.h.

◆ setAutoDepth()

template<FloatType T>
void dspark::Chorus< T >::setAutoDepth ( bool  enabled)
inlinenoexcept

Couples depth to rate automatically to prevent pitch artifacts at high speeds.

Parameters
enabledTrue to activate automatic depth attenuation.

Definition at line 363 of file Chorus.h.

◆ setCenterDelay()

template<FloatType T>
void dspark::Chorus< T >::setCenterDelay ( T  ms)
inlinenoexcept

Sets the base delay time.

Parameters
msTime in milliseconds [0.1 - 30.0]. Non-finite values are ignored.

Definition at line 343 of file Chorus.h.

◆ setDepthMs()

template<FloatType T>
void dspark::Chorus< T >::setDepthMs ( T  ms)
inlinenoexcept

Sets the LFO modulation depth in milliseconds.

Parameters
msDepth in milliseconds [0.0 - 20.0]. Non-finite values are ignored.

Definition at line 301 of file Chorus.h.

◆ setFeedback()

template<FloatType T>
void dspark::Chorus< T >::setFeedback ( T  amount)
inlinenoexcept

Sets the feedback gain.

Parameters
amountFeedback from -0.99 to 0.99. Negative values yield flanger effects. Non-finite values are ignored.

Definition at line 333 of file Chorus.h.

◆ setInterpolation()

template<FloatType T>
void dspark::Chorus< T >::setInterpolation ( Interpolation  mode)
inlinenoexcept

Selects the fractional read kernel. Thread-safe; an out-of-range value reads as Hermite.

Definition at line 273 of file Chorus.h.

◆ setMix()

template<FloatType T>
void dspark::Chorus< T >::setMix ( T  dryWet)
inlinenoexcept

Sets the wet/dry mix ratio.

Parameters
dryWetRatio from 0.0 (fully dry) to 1.0 (fully wet). Non-finite values are ignored.

Definition at line 312 of file Chorus.h.

◆ setMixRule()

template<FloatType T>
void dspark::Chorus< T >::setMixRule ( typename DryWetMixer< T >::MixRule  rule)
inlinenoexcept

The rule of the dry/wet mix (Linear by default; see DryWetMixer::MixRule). Thread-safe.

Definition at line 470 of file Chorus.h.

◆ setModel()

template<FloatType T>
void dspark::Chorus< T >::setModel ( Model  m)
inlinenoexcept

Selects the engine (see Model). Thread-safe; the change fills the incoming engine, then crosses over (see the file notes).

Definition at line 384 of file Chorus.h.

◆ setModWaveform()

template<FloatType T>
void dspark::Chorus< T >::setModWaveform ( typename Oscillator< T >::Waveform  wf)
inlinenoexcept

Sets the oscillator waveform for all voices.

Warning
Using Saw or Square waves for delay modulation without additional lowpass filtering will cause audible clicks. Sine or Triangle are recommended.
Parameters
wfThe desired waveform type (wild enum values clamp).

Definition at line 371 of file Chorus.h.

◆ setRate()

template<FloatType T>
void dspark::Chorus< T >::setRate ( T  hz)
inlinenoexcept

Sets the LFO modulation rate.

Parameters
hzFrequency in Hertz [0.01 - 20.0]. Non-finite values are ignored.

Definition at line 291 of file Chorus.h.

◆ setState()

template<FloatType T>
bool dspark::Chorus< T >::setState ( const uint8_t *  data,
size_t  size 
)
inline

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

Definition at line 502 of file Chorus.h.

◆ setStereoSpread()

template<FloatType T>
void dspark::Chorus< T >::setStereoSpread ( T  amount)
inlinenoexcept

Sets the stereo spread amount.

Parameters
amountOffset ratio from 0.0 to 1.0. Non-finite values are ignored.

Definition at line 353 of file Chorus.h.

◆ setVoices()

template<FloatType T>
void dspark::Chorus< T >::setVoices ( int  count)
inlinenoexcept

Sets the number of active voices per channel.

Parameters
countVoices from 1 to 4.

Definition at line 322 of file Chorus.h.

◆ sincTable()

template<FloatType T>
static const SincInterpolator< T > & dspark::Chorus< T >::sincTable ( )
inlinestaticprotected

The shared sinc table (built on first use: prepare() calls it).

Definition at line 557 of file Chorus.h.

◆ startSwitch()

template<FloatType T>
void dspark::Chorus< T >::startSwitch ( Model  to)
inlineprotectednoexcept

Starts a change of engine: the incoming one from silence, unheard until its line is full.

Definition at line 608 of file Chorus.h.

◆ targetPhase()

template<FloatType T>
T dspark::Chorus< T >::targetPhase ( int  ch,
int  v,
int  nv,
T  spread 
) const
inlineprotectednoexcept

Phase offset of a channel/voice LFO from channel 0, voice 0.

Definition at line 532 of file Chorus.h.

◆ updateLfoPhases()

template<FloatType T>
void dspark::Chorus< T >::updateLfoPhases ( )
inlineprotectednoexcept

Sets every LFO phase to its target outright (prepare and reset; while running, the LFOs glide instead).

Definition at line 546 of file Chorus.h.

Member Data Documentation

◆ analogCircuit_

template<FloatType T>
std::atomic<bool> dspark::Chorus< T >::analogCircuit_ { false }
protected

Definition at line 1071 of file Chorus.h.

◆ analogCornerFor_

template<FloatType T>
double dspark::Chorus< T >::analogCornerFor_ = -1.0
protected

Definition at line 1082 of file Chorus.h.

◆ analogGlide_

template<FloatType T>
double dspark::Chorus< T >::analogGlide_ = 1.0
protected

Definition at line 1084 of file Chorus.h.

◆ analogMode_

template<FloatType T>
std::atomic<int> dspark::Chorus< T >::analogMode_ { 0 }
protected

Definition at line 1067 of file Chorus.h.

◆ analogNoiseDb_

template<FloatType T>
std::atomic<T> dspark::Chorus< T >::analogNoiseDb_ { T(-84) }
protected

Definition at line 1068 of file Chorus.h.

◆ analogPhase_

template<FloatType T>
double dspark::Chorus< T >::analogPhase_ = 0.0
protected

Definition at line 1083 of file Chorus.h.

◆ analogPrimed_

template<FloatType T>
bool dspark::Chorus< T >::analogPrimed_ = false
protected

Definition at line 1086 of file Chorus.h.

◆ analogTapPhase_

template<FloatType T>
std::atomic<T> dspark::Chorus< T >::analogTapPhase_ { T(180) }
protected

Definition at line 1069 of file Chorus.h.

◆ analogTone_

template<FloatType T>
std::atomic<T> dspark::Chorus< T >::analogTone_ { T(0) }
protected

Definition at line 1070 of file Chorus.h.

◆ analogToneFor_

template<FloatType T>
double dspark::Chorus< T >::analogToneFor_ = 0.0
protected

Definition at line 1073 of file Chorus.h.

◆ autoDepth_

template<FloatType T>
std::atomic<bool> dspark::Chorus< T >::autoDepth_ { false }
protected

Definition at line 1042 of file Chorus.h.

◆ bbd_

template<FloatType T>
std::array<BucketBrigade<T>, 2> dspark::Chorus< T >::bbd_ {}
protected

Definition at line 1080 of file Chorus.h.

◆ centerDelayMs_

template<FloatType T>
std::atomic<T> dspark::Chorus< T >::centerDelayMs_ { T(7) }
protected

Definition at line 1039 of file Chorus.h.

◆ centreFrom_

template<FloatType T>
double dspark::Chorus< T >::centreFrom_ = 0.0
protected

Definition at line 1085 of file Chorus.h.

◆ centreNow_

template<FloatType T>
double dspark::Chorus< T >::centreNow_ = 0.0
protected

Definition at line 1084 of file Chorus.h.

◆ circuitFor_

template<FloatType T>
bool dspark::Chorus< T >::circuitFor_ = false
protected

Definition at line 1072 of file Chorus.h.

◆ decimate_

template<FloatType T>
std::array<BiquadCoeffs, 2> dspark::Chorus< T >::decimate_ {}
protected

Definition at line 1087 of file Chorus.h.

◆ decimatePhase_

template<FloatType T>
int dspark::Chorus< T >::decimatePhase_ = 0
protected

Definition at line 1090 of file Chorus.h.

◆ decimateState_

template<FloatType T>
std::array<std::array<double, 2>, 2> dspark::Chorus< T >::decimateState_ {}
protected

Definition at line 1088 of file Chorus.h.

◆ delayLines_

template<FloatType T>
std::array<RingBuffer<T>, kMaxChannels> dspark::Chorus< T >::delayLines_ {}
protected

Definition at line 1054 of file Chorus.h.

◆ depthFrom_

template<FloatType T>
double dspark::Chorus< T >::depthFrom_ = 0.0
protected

Definition at line 1085 of file Chorus.h.

◆ depthMs_

template<FloatType T>
std::atomic<T> dspark::Chorus< T >::depthMs_ { T(3.5) }
protected

Definition at line 1036 of file Chorus.h.

◆ depthNow_

template<FloatType T>
double dspark::Chorus< T >::depthNow_ = 0.0
protected

Definition at line 1084 of file Chorus.h.

◆ engineLast_

template<FloatType T>
std::array<double, 2> dspark::Chorus< T >::engineLast_ {}
protected

Definition at line 1089 of file Chorus.h.

◆ engineOut_

template<FloatType T>
std::array<double, 2> dspark::Chorus< T >::engineOut_ {}
protected

Definition at line 1089 of file Chorus.h.

◆ engineRate_

template<FloatType T>
double dspark::Chorus< T >::engineRate_ = 48000.0
protected

Definition at line 1082 of file Chorus.h.

◆ fadeLeft_

template<FloatType T>
int dspark::Chorus< T >::fadeLeft_ = 0
protected

Definition at line 1078 of file Chorus.h.

◆ fbState_

template<FloatType T>
std::array<T, kMaxChannels> dspark::Chorus< T >::fbState_ {}
protected

Definition at line 1057 of file Chorus.h.

◆ feedback_

template<FloatType T>
std::atomic<T> dspark::Chorus< T >::feedback_ { T(0) }
protected

Definition at line 1038 of file Chorus.h.

◆ fillLeft_

template<FloatType T>
int dspark::Chorus< T >::fillLeft_ = 0
protected

Definition at line 1078 of file Chorus.h.

◆ halfRate_

template<FloatType T>
bool dspark::Chorus< T >::halfRate_ = false
protected

Definition at line 1081 of file Chorus.h.

◆ hissHpCoeff_

template<FloatType T>
double dspark::Chorus< T >::hissHpCoeff_ = 0.0
protected

Definition at line 1073 of file Chorus.h.

◆ hissHpX_

template<FloatType T>
std::array<double, 2> dspark::Chorus< T >::hissHpX_ {}
protected

Definition at line 1074 of file Chorus.h.

◆ hissHpY_

template<FloatType T>
std::array<double, 2> dspark::Chorus< T >::hissHpY_ {}
protected

Definition at line 1074 of file Chorus.h.

◆ hpCoeff_

template<FloatType T>
double dspark::Chorus< T >::hpCoeff_ = 0.0
protected

Definition at line 1082 of file Chorus.h.

◆ hpX1_

template<FloatType T>
double dspark::Chorus< T >::hpX1_ = 0.0
protected

Definition at line 1083 of file Chorus.h.

◆ hpY1_

template<FloatType T>
double dspark::Chorus< T >::hpY1_ = 0.0
protected

Definition at line 1083 of file Chorus.h.

◆ incoming_

template<FloatType T>
Model dspark::Chorus< T >::incoming_ = Model::Digital
protected

Definition at line 1076 of file Chorus.h.

◆ interpolation_

template<FloatType T>
std::atomic<Interpolation> dspark::Chorus< T >::interpolation_ { Interpolation::Hermite }
protected

Definition at line 1060 of file Chorus.h.

◆ kAnalogClockShare

template<FloatType T>
constexpr double dspark::Chorus< T >::kAnalogClockShare = 0.2
staticconstexprprotected

The corner at most this share of the slowest clock.

Definition at line 1021 of file Chorus.h.

◆ kAnalogCornerHz

template<FloatType T>
constexpr double dspark::Chorus< T >::kAnalogCornerHz = 7000.0
staticconstexprprotected

The analog filters' corner (tone 0).

Definition at line 1020 of file Chorus.h.

◆ kAnalogGlideSeconds

template<FloatType T>
constexpr double dspark::Chorus< T >::kAnalogGlideSeconds = 0.05
staticconstexprprotected

Glide of the analog centre, depth and offset.

Definition at line 1018 of file Chorus.h.

◆ kAnalogStages

template<FloatType T>
constexpr int dspark::Chorus< T >::kAnalogStages = 512
staticconstexprprotected

Stages of each analog line.

Definition at line 1016 of file Chorus.h.

◆ kCircuitClockShare

template<FloatType T>
constexpr double dspark::Chorus< T >::kCircuitClockShare = 0.23
staticconstexprprotected

The circuit pair's input corner at most this share of the slowest clock.

Definition at line 1024 of file Chorus.h.

◆ kCircuitInputHz

template<FloatType T>
constexpr double dspark::Chorus< T >::kCircuitInputHz = 8000.0
staticconstexprprotected

The circuit pair: the input filter's corner.

Definition at line 1022 of file Chorus.h.

◆ kCircuitOutputHz

template<FloatType T>
constexpr double dspark::Chorus< T >::kCircuitOutputHz = 5600.0
staticconstexprprotected

The circuit pair: the output filter's corner (tone 0).

Definition at line 1023 of file Chorus.h.

◆ kCornerOctaveSeconds

template<FloatType T>
constexpr double dspark::Chorus< T >::kCornerOctaveSeconds = 0.25
staticconstexprprotected

The analog filters' corner moves an octave in this time at most.

Definition at line 1019 of file Chorus.h.

◆ kHissHighPassHz

template<FloatType T>
constexpr double dspark::Chorus< T >::kHissHighPassHz = 200.0
staticconstexprprotected

The hiss has no lows under this.

Definition at line 1025 of file Chorus.h.

◆ kMaxChannels

template<FloatType T>
constexpr int dspark::Chorus< T >::kMaxChannels = 16
staticconstexpr

Definition at line 109 of file Chorus.h.

◆ kMaxGlideHz

template<FloatType T>
constexpr T dspark::Chorus< T >::kMaxGlideHz = T(0.5)
staticconstexprprotected

Phase glide: half a cycle per second.

Definition at line 1029 of file Chorus.h.

◆ kMaxVoices

template<FloatType T>
constexpr int dspark::Chorus< T >::kMaxVoices = 4
staticconstexpr

Definition at line 108 of file Chorus.h.

◆ kRise

template<FloatType T>
constexpr double dspark::Chorus< T >::kRise = 0.53
staticconstexprprotected

The sweep's rising share of its period.

Definition at line 1017 of file Chorus.h.

◆ kSwitchFadeSeconds

template<FloatType T>
constexpr double dspark::Chorus< T >::kSwitchFadeSeconds = 0.01
staticconstexprprotected

A change of engine crosses over in this.

Definition at line 1026 of file Chorus.h.

◆ kSwitchSettleSeconds

template<FloatType T>
constexpr double dspark::Chorus< T >::kSwitchSettleSeconds = 0.003
staticconstexprprotected

The analog line's filters settle in this after it fills.

Definition at line 1027 of file Chorus.h.

◆ lastSpread_

template<FloatType T>
T dspark::Chorus< T >::lastSpread_ { T(0.5) }
protected

Definition at line 1044 of file Chorus.h.

◆ lfoPhaseDirty_

template<FloatType T>
std::atomic<bool> dspark::Chorus< T >::lfoPhaseDirty_ { false }
protected

Definition at line 1046 of file Chorus.h.

◆ lfos_

template<FloatType T>
std::array<std::array<Oscillator<T>, kMaxVoices>, kMaxChannels> dspark::Chorus< T >::lfos_ {}
protected

Definition at line 1056 of file Chorus.h.

◆ lfoWaveform_

template<FloatType T>
std::atomic<typename Oscillator<T>::Waveform> dspark::Chorus< T >::lfoWaveform_ { Oscillator<T>::Waveform::Sine }
protected

Definition at line 1045 of file Chorus.h.

◆ maxDelaySamples_

template<FloatType T>
int dspark::Chorus< T >::maxDelaySamples_ { 0 }
protected

Definition at line 1032 of file Chorus.h.

◆ mix_

template<FloatType T>
std::atomic<T> dspark::Chorus< T >::mix_ { T(0.5) }
protected

Definition at line 1037 of file Chorus.h.

◆ mixer_

template<FloatType T>
DryWetMixer<T> dspark::Chorus< T >::mixer_
protected

Definition at line 1063 of file Chorus.h.

◆ model_

template<FloatType T>
std::atomic<Model> dspark::Chorus< T >::model_ { Model::Digital }
protected

Definition at line 1066 of file Chorus.h.

◆ noiseCoeff_

template<FloatType T>
double dspark::Chorus< T >::noiseCoeff_ = 0.0
protected

Definition at line 1082 of file Chorus.h.

◆ noiseLp_

template<FloatType T>
std::array<double, 2> dspark::Chorus< T >::noiseLp_ {}
protected

Definition at line 1089 of file Chorus.h.

◆ noiseRng_

template<FloatType T>
uint32_t dspark::Chorus< T >::noiseRng_ = 0x6B43A9u
protected

Definition at line 1091 of file Chorus.h.

◆ numVoices_

template<FloatType T>
std::atomic<int> dspark::Chorus< T >::numVoices_ { 2 }
protected

Definition at line 1041 of file Chorus.h.

◆ offsetNow_

template<FloatType T>
double dspark::Chorus< T >::offsetNow_ = 0.5
protected

Definition at line 1084 of file Chorus.h.

◆ playing_

template<FloatType T>
Model dspark::Chorus< T >::playing_ = Model::Digital
protected

Definition at line 1076 of file Chorus.h.

◆ rate_

template<FloatType T>
std::atomic<T> dspark::Chorus< T >::rate_ { T(1) }
protected

Definition at line 1035 of file Chorus.h.

◆ sinc_

template<FloatType T>
const SincInterpolator<T>* dspark::Chorus< T >::sinc_ = nullptr
protected

Set by prepare().

Definition at line 1061 of file Chorus.h.

◆ smoothedCenterSamples_

template<FloatType T>
T dspark::Chorus< T >::smoothedCenterSamples_ { T(0) }
protected

Definition at line 1050 of file Chorus.h.

◆ smoothedDepthSamples_

template<FloatType T>
T dspark::Chorus< T >::smoothedDepthSamples_ { T(0) }
protected

Definition at line 1051 of file Chorus.h.

◆ spec_

template<FloatType T>
AudioSpec dspark::Chorus< T >::spec_ {}
protected

Definition at line 1031 of file Chorus.h.

◆ stereoSpread_

template<FloatType T>
std::atomic<T> dspark::Chorus< T >::stereoSpread_ { T(0.5) }
protected

Definition at line 1040 of file Chorus.h.

◆ switchBuffer_

template<FloatType T>
AudioBuffer<T> dspark::Chorus< T >::switchBuffer_
protected

Definition at line 1079 of file Chorus.h.

◆ switchFade_

template<FloatType T>
int dspark::Chorus< T >::switchFade_ = 480
protected

Definition at line 1078 of file Chorus.h.

◆ switching_

template<FloatType T>
bool dspark::Chorus< T >::switching_ = false
protected

Definition at line 1077 of file Chorus.h.

◆ voiceFadeStep_

template<FloatType T>
T dspark::Chorus< T >::voiceFadeStep_ = T(1)
protected

Definition at line 1059 of file Chorus.h.

◆ voiceGain_

template<FloatType T>
std::array<T, kMaxVoices> dspark::Chorus< T >::voiceGain_ {}
protected

Voice fades (audio thread).

Definition at line 1058 of file Chorus.h.

◆ waveformDirty_

template<FloatType T>
std::atomic<bool> dspark::Chorus< T >::waveformDirty_ { false }
protected

Definition at line 1047 of file Chorus.h.


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