Files
ShoeGaze/Sources/LyrebirdShoeGaze/Pedals/FeedbackDelayPedal.swift
T
josh c28e7cac90 Add four pedals: Mu-Tron, Auto-Wah, Feedback Delay, Multi-Tap Delay
Two envelope filters and two delays, registered in PedalRegistry and
showcased on demo Board 3.

- Mu-Tron: wraps the MuTronIII generator; three parallel LP/BP/HP
  instances switched live by a Select on the mode knob so filter state
  stays warmed across mode changes. Knobs: Mode, Sensitivity, Resonance.
- Auto-Wah: explicit amplitude-tracking chain — AmplitudeFollower scaled
  by sensitivity, clamped, mapped through LinExp to a swept SVF bandpass.
  Knobs: Sensitivity, Resonance, Range.
- Feedback Delay: DelayLineFeedback (cubic) into an RBJ lowpass for a
  darker, tape-style multi-repeat echo. Knobs: Time, Feedback, Tone.
- Multi-Tap Delay: three non-feedback DelayLine taps summed, per-tap
  volume folded into each tap's mul. Six knobs in two rows of three.

Bumps the Lyrebird dependency to 1.2.0 for the MuTronIII/SVF generators.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 15:07:34 -07:00

100 lines
3.2 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// FeedbackDelayPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Feedback (tape-style) delay pedal with multiple regenerating repeats.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry → DelayLineFeedback(delay: time, decayTime: feedback) → RBJLowPass(tone) → wet
/// ```
///
/// The feedback path regenerates the echo so a single note produces a train of repeats
/// that decays over `feedback` seconds. A `Tone` lowpass darkens the wet signal for the
/// warm, rolled-off character of a tape echo (cubic interpolation adds the same smear).
/// `effect` returns the pure wet signal — the base `Pedal` blends it via `mix`.
///
/// ## Knobs
/// - `time`: Delay time between repeats, in seconds.
/// - `feedback`: Repeat decay time in seconds — how long the echoes regenerate before
/// falling to −60 dB. Longer values produce more audible repeats.
/// - `tone`: Lowpass cutoff in Hz applied to the wet signal; lower darkens the echoes.
public final class FeedbackDelayPedal: Pedal {
// MARK: - Parameters
/// Delay time between repeats, in seconds.
@UIParam public var time: Double = 0.3
/// Repeat decay time in seconds (time for echoes to reach −60 dB). Longer = more repeats.
@UIParam public var feedback: Double = 2.5
/// Tone (lowpass) cutoff in Hz applied to the wet echoes.
@UIParam public var tone: Double = 4000.0
// MARK: - Constants
/// Maximum supported delay time in seconds. Sizes the delay-line buffer at init.
private let maxDelayTime: Double = 1.5
/// Amplitude target for the `decayTime` calculation (−60 dB).
private let targetAmp: Double = 0.001
/// Butterworth Q for the tone lowpass (no resonant peak).
private let toneQ: Double = 0.707
/// Partial wet/dry blend so the dry note and its echoes coexist.
private static let defaultMix: Double = 0.35
// MARK: - Ranges
private let timeRange: ClosedRange<Double> = 0.02 ... 1.5
private let feedbackRange: ClosedRange<Double> = 0.1 ... 8.0
private let toneRange: ClosedRange<Double> = 500.0 ... 8000.0
// MARK: - Knobs
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Time", node: $time, range: timeRange),
PedalKnob(label: "Feedback", node: $feedback, range: feedbackRange),
PedalKnob(label: "Tone", node: $tone, range: toneRange),
]
}
// MARK: - Init
public init(inputBus: Int = 0, outputBus: Int = 0) {
super.init(
name: "Feedback Delay",
inputBus: inputBus,
outputBus: outputBus,
initialMix: FeedbackDelayPedal.defaultMix
)
}
// MARK: - Effect
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
let echoes: DelayLineFeedback = DelayLineFeedback(
input: dry,
maxDelay: maxDelayTime,
delay: $time,
decayTime: $feedback,
targetAmp: targetAmp,
sampleRate: sampleRate,
interpolation: .cubic
)
return RBJLowPass.Audio(
input: echoes,
freq: $tone,
q: toneQ
)
}
}