Multi-voice chorus/flanger with true stereo spread and smooth parameter handling.
More...
|
| | ~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).
|
| |
|
| 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.
|
| |
|
| 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 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.
|
| |
template<FloatType T>
class dspark::Chorus< T >
Multi-voice chorus/flanger with true stereo spread and smooth parameter handling.
- Template Parameters
-
| T | Sample type (float or double). |
Definition at line 103 of file Chorus.h.
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.