Struct BbdDelayLine
pub struct BbdDelayLine {
pub model: BbdModel,
/* private fields */
}Expand description
BBD delay line processor.
Implements a physically-modeled bucket-brigade delay with:
- Variable delay time (via clock frequency)
- Anti-alias filtering (models the BBD’s Nyquist limit)
- Subtle soft clipping (BBDs clip gently at high levels)
- Noise injection (characteristic BBD hiss)
- Compander with proper envelope tracking
The delay buffer uses linear interpolation for fractional-sample delay, modeling the smooth time modulation of chorus/flanger effects.
§Compander Architecture
Real BBD companders (NE570/NE571) work by:
- Compressing the input signal using the INPUT envelope
- Delaying the compressed signal through the BBD
- Expanding using a DELAYED version of the compression envelope
- The tracking error between compression and expansion envelopes causes characteristic “breathing” and “pumping” artifacts
The expander must use the delayed compression envelope, NOT an independent envelope of the output signal, to achieve unity gain in steady state while preserving the analog artifacts.
Fields§
§model: BbdModelImplementations§
§impl BbdDelayLine
impl BbdDelayLine
pub fn new(model: BbdModel, sample_rate: f64) -> BbdDelayLine
pub fn new(model: BbdModel, sample_rate: f64) -> BbdDelayLine
Create a new BBD delay line.
Buffer size is determined by the maximum delay time at the current sample rate, plus headroom for interpolation.
pub fn set_clock(&mut self, clock_hz: f64)
pub fn set_clock(&mut self, clock_hz: f64)
Set the clock frequency directly (Hz).
This controls the delay time: delay = num_stages / (2 * fclk). Modulating this with an LFO creates chorus/flanger effects.
pub fn set_delay_normalized(&mut self, norm: f64)
pub fn set_delay_normalized(&mut self, norm: f64)
Set delay time as a normalized value (0.0 = min delay, 1.0 = max delay).
Maps logarithmically across the clock frequency range.
pub fn set_feedback(&mut self, feedback: f64)
pub fn set_feedback(&mut self, feedback: f64)
Set feedback amount (0.0 = no feedback, <1.0 for stability).
pub fn process(&mut self, input: f64) -> f64
pub fn process(&mut self, input: f64) -> f64
Process one sample through the BBD delay line.
Signal chain (models real BBD circuit with NE571-style companding):
- Compander input stage: compress dynamic range (NE571 compressor)
- Store compression envelope in delay buffer
- Soft clip to BBD voltage swing limit
- Write to delay buffer (with feedback)
- Read from buffer with interpolation
- Charge leakage LPF (darker at longer delays)
- Anti-alias LPF (BBD Nyquist bandwidth limit)
- Clock feedthrough injection
- Noise injection
- Read DELAYED compression envelope for expander
- Expand using delayed envelope (restores original dynamics)
- Apply tracking error as small modulation artifact
pub fn set_sample_rate(&mut self, sample_rate: f64)
pub fn set_sample_rate(&mut self, sample_rate: f64)
Update sample rate and resize buffer.
pub fn reset(&mut self)
pub fn reset(&mut self)
Reset all state.
pub fn delay_time(&self) -> f64
pub fn delay_time(&self) -> f64
Get current delay time in seconds.
pub fn clock_freq(&self) -> f64
pub fn clock_freq(&self) -> f64
Get current clock frequency.
Trait Implementations§
§impl Clone for BbdDelayLine
impl Clone for BbdDelayLine
§fn clone(&self) -> BbdDelayLine
fn clone(&self) -> BbdDelayLine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more