sfFDN
Loading...
Searching...
No Matches
sfFDN::DattorroDelay Class Reference

The delay-line effect described by Jon Dattorro in "Effect Design Part 2: Delay-Line Modulation and Chorus", J. More...

#include <dattorro_delay.h>

Inheritance diagram for sfFDN::DattorroDelay:
[legend]
Collaboration diagram for sfFDN::DattorroDelay:
[legend]

Public Member Functions

 DattorroDelay (const DattorroDelayOptions &options={})
 Constructs a Dattorro delay-line effect.
 
void SetBlend (float blend) noexcept SFFDN_NONBLOCKING
 Sets the gain applied to the input of the delay line.
 
float GetBlend () const noexcept SFFDN_NONBLOCKING
 Returns the gain applied to the input of the delay line.
 
void SetFeedforward (float feedforward) noexcept SFFDN_NONBLOCKING
 Sets the gain applied to the modulated output of the delay line.
 
float GetFeedforward () const noexcept SFFDN_NONBLOCKING
 Returns the gain applied to the modulated output of the delay line.
 
void SetFeedback (float feedback) noexcept SFFDN_NONBLOCKING
 Sets the gain applied to the fixed output of the delay line before it is fed back into the delay line.
 
float GetFeedback () const noexcept SFFDN_NONBLOCKING
 Returns the gain applied to the fixed output of the delay line.
 
void SetDelay (float delay)
 Sets the nominal delay of the delay line.
 
float GetDelay () const
 Returns the nominal delay of the delay line, in samples.
 
void SetMod (const ModulationOptions &options)
 Sets the modulation applied to the feedforward tap.
 
float Tick (float input) noexcept SFFDN_NONBLOCKING
 Processes a single sample.
 
void Process (const AudioBuffer &input, AudioBuffer &output) noexcept SFFDN_NONBLOCKING override
 Processes the audio buffer.
 
uint32_t InputChannelCount () const noexcept SFFDN_NONBLOCKING override
 Returns the number of input channels this processor expects.
 
uint32_t OutputChannelCount () const noexcept SFFDN_NONBLOCKING override
 Returns the number of output channels this processor produces.
 
void Clear () override
 Clears the delay line and resets the modulation phase.
 
std::unique_ptr< AudioProcessorClone () const override
 Creates a copy of the processor.
 
- Public Member Functions inherited from sfFDN::AudioProcessor

Static Public Attributes

static constexpr float kMinimumDelay = 2.f
 The smallest delay, in samples, that the delay line is allowed to take.
 

Additional Inherited Members

- Protected Member Functions inherited from sfFDN::AudioProcessor
 AudioProcessor (const AudioProcessor &)=default
 
AudioProcessoroperator= (const AudioProcessor &)=default
 
 AudioProcessor (AudioProcessor &&) noexcept=default
 
AudioProcessoroperator= (AudioProcessor &&) noexcept=default
 

Detailed Description

The delay-line effect described by Jon Dattorro in "Effect Design Part 2: Delay-Line Modulation and Chorus", J.

Audio Eng. Soc., Vol. 45, No. 10, 1997.

A single delay line is read at two taps and wrapped in a comb filter with three knobs: blend, feedforward and feedback.

\[ w[n] = x[n] - \mathit{FB} \cdot w[n - M] \\ y[n] = \mathit{FF} \cdot w[n - M(n)] + \mathit{BL} \cdot w[n] \]

The feedback tap sits at the fixed nominal delay \(M\) and is read without interpolation. Only the feedforward tap is modulated: it is read with interpolation at \(M(n) = M + \mathit{width} \cdot \sin(2 \pi f n)\). Modulating the feedback tap would change the length of the recirculating loop on every sample, so it is deliberately left fixed.

Vibrato, flanging, chorus, doubling and echo are all obtained from this one structure by changing the three gains. See MakeDattorroDelayOptions().

Note
The feedback is subtracted at the summing junction, as drawn in the paper. A positive feedback gain therefore recirculates with inverted polarity, and the gains of Table 1 can be used exactly as printed. See MakeDattorroDelayOptions().
Choose the interpolation type to match how the delay is used. Linear interpolation is the cheaper choice on a modulated tap and its magnitude droop near Nyquist is inaudible for an insert effect, which is what the presets returned by MakeDattorroDelayOptions() use. Allpass interpolation costs a little more but has a flat magnitude response; prefer it whenever the effect sits inside a feedback loop, where the droop of linear interpolation compounds on every circulation and pulls the high-frequency T60 below target. Allpass interpolation is safe on a modulated tap: DelayInterp::SetDelay() re-seeds the allpass state from the new tap whenever the integer part of the delay changes, so crossing a sample boundary no longer leaves a step in the output.

Constructor & Destructor Documentation

◆ DattorroDelay()

sfFDN::DattorroDelay::DattorroDelay ( const DattorroDelayOptions & options = {})
explicit

Constructs a Dattorro delay-line effect.

Parameters
optionsThe configuration options for the effect.
Note
The instantaneous delay is never allowed to fall below kMinimumDelay samples. The constructor throws std::invalid_argument if the nominal delay minus the modulation width is smaller than that.
The fixed feedback tap is placed at the nearest integer to the nominal delay, since it is read without interpolation. The modulated feedforward tap keeps the fractional part of the nominal delay.

Member Function Documentation

◆ Clear()

void sfFDN::DattorroDelay::Clear ( )
overridevirtual

Clears the delay line and resets the modulation phase.

The three gains are left untouched.

Implements sfFDN::AudioProcessor.

◆ Clone()

std::unique_ptr< AudioProcessor > sfFDN::DattorroDelay::Clone ( ) const
overridevirtual

Creates a copy of the processor.

Returns
A unique pointer to the cloned processor.

Implements sfFDN::AudioProcessor.

◆ InputChannelCount()

uint32_t sfFDN::DattorroDelay::InputChannelCount ( ) const
overridevirtualnoexcept

Returns the number of input channels this processor expects.

This is always 1.

Implements sfFDN::AudioProcessor.

◆ OutputChannelCount()

uint32_t sfFDN::DattorroDelay::OutputChannelCount ( ) const
overridevirtualnoexcept

Returns the number of output channels this processor produces.

This is always 1.

Implements sfFDN::AudioProcessor.

◆ Process()

void sfFDN::DattorroDelay::Process ( const AudioBuffer & input,
AudioBuffer & output )
overridevirtualnoexcept

Processes the audio buffer.

Parameters
inputThe input audio buffer.
outputThe output audio buffer.
Note
The input and output buffers must have one channel and the same number of samples.

Implements sfFDN::AudioProcessor.

◆ SetDelay()

void sfFDN::DattorroDelay::SetDelay ( float delay)

Sets the nominal delay of the delay line.

Parameters
delayThe delay in samples.
Note
This moves both the fixed feedback tap and the center of the modulated feedforward tap.
Throws std::invalid_argument if the delay minus the current modulation width is smaller than kMinimumDelay.

◆ SetFeedback()

void sfFDN::DattorroDelay::SetFeedback ( float feedback)
noexcept

Sets the gain applied to the fixed output of the delay line before it is fed back into the delay line.

Parameters
feedbackThe feedback gain. The value is clamped to the range (-1, 1) to keep the loop stable.

◆ SetMod()

void sfFDN::DattorroDelay::SetMod ( const ModulationOptions & options)

Sets the modulation applied to the feedforward tap.

Parameters
optionsThe modulation options. The amplitude is the peak deviation, in samples, of the feedforward tap around the nominal delay.
Note
Throws std::invalid_argument if the nominal delay minus the amplitude is smaller than kMinimumDelay.

◆ Tick()

float sfFDN::DattorroDelay::Tick ( float input)
noexcept

Processes a single sample.

Parameters
inputThe input sample.
Returns
The output sample.

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