sfFDN
Loading...
Searching...
No Matches
dattorro_delay.h
1// Copyright (C) 2026 Alexandre St-Onge
2// SPDX-License-Identifier: MIT
3#pragma once
4
5#include "sffdn/audio_buffer.h"
6#include "sffdn/audio_processor.h"
7#include "sffdn/delay_interp.h"
8#include "sffdn/filterbank.h"
9#include "sffdn/oscillator.h"
10#include "sffdn/types.h"
11
12#include <cstdint>
13#include <memory>
14
15namespace sfFDN
16{
17
51{
52 public:
60 explicit DattorroDelay(const DattorroDelayOptions& options = {});
61
63 static constexpr float kMinimumDelay = 2.f;
64
66 void SetBlend(float blend) noexcept SFFDN_NONBLOCKING;
67
69 float GetBlend() const noexcept SFFDN_NONBLOCKING;
70
72 void SetFeedforward(float feedforward) noexcept SFFDN_NONBLOCKING;
73
75 float GetFeedforward() const noexcept SFFDN_NONBLOCKING;
76
80 void SetFeedback(float feedback) noexcept SFFDN_NONBLOCKING;
81
83 float GetFeedback() const noexcept SFFDN_NONBLOCKING;
84
91 void SetDelay(float delay);
92
94 float GetDelay() const;
95
101 void SetMod(const ModulationOptions& options);
102
107 float Tick(float input) noexcept SFFDN_NONBLOCKING;
108
114 void Process(const AudioBuffer& input, AudioBuffer& output) noexcept SFFDN_NONBLOCKING override;
115
117 uint32_t InputChannelCount() const noexcept SFFDN_NONBLOCKING override;
118
120 uint32_t OutputChannelCount() const noexcept SFFDN_NONBLOCKING override;
121
123 void Clear() override;
124
128 std::unique_ptr<AudioProcessor> Clone() const override;
129
130 private:
131 float TickInternal(float input, float mod) noexcept SFFDN_NONBLOCKING;
132
133 DelayInterp delay_;
134 SineWave lfo_;
135
136 float base_delay_;
137 uint32_t feedback_tap_;
138
139 float blend_;
140 float feedforward_;
141 float feedback_;
142};
143
151DattorroDelayOptions MakeDattorroDelayOptions(DattorroEffectType type, float sample_rate);
152
160std::unique_ptr<FilterBank> MakeMultichannelDattorroDelay(const MultichannelDattorroDelayOptions& options);
161
197MultichannelDattorroDelayOptions MakeMultichannelDattorroDelayOptions(DattorroEffectType type, float sample_rate,
198 uint32_t channel_count);
199
200} // namespace sfFDN
A class representing an audio buffer with multiple channels of non-interleaved audio data.
Definition audio_buffer.h:20
Base class for audio processors.
Definition audio_processor.h:24
The delay-line effect described by Jon Dattorro in "Effect Design Part 2: Delay-Line Modulation and C...
Definition dattorro_delay.h:51
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...
std::unique_ptr< AudioProcessor > Clone() const override
Creates a copy of the processor.
static constexpr float kMinimumDelay
The smallest delay, in samples, that the delay line is allowed to take.
Definition dattorro_delay.h:63
void SetDelay(float delay)
Sets the nominal delay of the delay line.
DattorroDelay(const DattorroDelayOptions &options={})
Constructs a Dattorro delay-line effect.
float GetDelay() const
Returns the nominal delay of the delay line, in samples.
void Process(const AudioBuffer &input, AudioBuffer &output) noexcept SFFDN_NONBLOCKING override
Processes the audio buffer.
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.
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.
void SetBlend(float blend) noexcept SFFDN_NONBLOCKING
Sets the gain applied to the input of the delay line.
void SetMod(const ModulationOptions &options)
Sets the modulation applied to the feedforward tap.
uint32_t InputChannelCount() const noexcept SFFDN_NONBLOCKING override
Returns the number of input channels this processor expects.
float GetFeedforward() const noexcept SFFDN_NONBLOCKING
Returns the gain applied to the modulated output of the delay line.
float GetFeedback() const noexcept SFFDN_NONBLOCKING
Returns the gain applied to the fixed output of the delay line.
float Tick(float input) noexcept SFFDN_NONBLOCKING
Processes a single sample.
Delay line with interpolation.
Definition delay_interp.h:23
Implements a bank of filters.
Definition filterbank.h:19
A sine wave oscillator.
Definition oscillator.h:33
DattorroEffectType
Classic delay-line effects, as described in Table 1 of Jon Dattorro, "Effect Design Part 2: Delay-Lin...
Definition types.h:354
Options for configuring a Dattorro delay-line effect.
Definition types.h:368
Options for configuring signal modulation.
Definition types.h:180
Options for configuring a multichannel bank of Dattorro delay-line effects.
Definition types.h:391