Files
ShoeGaze/Sources/LyrebirdShoeGaze/Pedals/MultiTapDelayPedal.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

115 lines
3.7 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.
// MultiTapDelayPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Three-tap delay pedal with no feedback and an independent volume per tap.
///
/// The dry signal is split into three non-regenerating delay lines at independent times;
/// each tap's level is set by its own volume knob, and the three taps are summed into the
/// wet output. Because no tap feeds back, the result is a fixed three-echo pattern rather
/// than a decaying repeat train — useful for rhythmic slap-back groups and chords of echoes.
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry ─┬─ DelayLine(time1) × vol1 ─┐
/// ├─ DelayLine(time2) × vol2 ─┼─ Σ → wet
/// └─ DelayLine(time3) × vol3 ─┘
/// ```
///
/// `effect` returns the summed wet signal — the base `Pedal` blends it via `mix`.
///
/// ## Knobs (two rows of three)
/// - `time1`, `time2`, `time3`: Delay time of each tap, in seconds.
/// - `vol1`, `vol2`, `vol3`: Linear output level of each tap in `[0, 1]`.
public final class MultiTapDelayPedal: Pedal {
// MARK: - Tap times
/// Tap 1 delay time, in seconds.
@UIParam public var time1: Double = 0.12
/// Tap 2 delay time, in seconds.
@UIParam public var time2: Double = 0.24
/// Tap 3 delay time, in seconds.
@UIParam public var time3: Double = 0.36
// MARK: - Tap volumes
/// Tap 1 linear level in [0, 1].
@UIParam public var vol1: Double = 0.8
/// Tap 2 linear level in [0, 1].
@UIParam public var vol2: Double = 0.5
/// Tap 3 linear level in [0, 1].
@UIParam public var vol3: Double = 0.3
// MARK: - Constants
/// Maximum supported per-tap delay time in seconds. Sizes each delay-line buffer at init.
private let maxDelayTime: Double = 1.0
/// Partial wet/dry blend so the dry note and its taps coexist.
private static let defaultMix: Double = 0.4
// MARK: - Ranges
private let timeRange: ClosedRange<Double> = 0.01 ... 1.0
private let volRange: ClosedRange<Double> = 0.0 ... 1.0
// MARK: - Knobs
/// Two rows of three: the three tap times, then the three tap volumes.
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Time 1", node: $time1, range: timeRange),
PedalKnob(label: "Time 2", node: $time2, range: timeRange),
PedalKnob(label: "Time 3", node: $time3, range: timeRange),
PedalKnob(label: "Vol 1", node: $vol1, range: volRange),
PedalKnob(label: "Vol 2", node: $vol2, range: volRange),
PedalKnob(label: "Vol 3", node: $vol3, range: volRange),
]
}
// MARK: - Init
public init(inputBus: Int = 0, outputBus: Int = 0) {
super.init(
name: "Multi-Tap Delay",
inputBus: inputBus,
outputBus: outputBus,
initialMix: MultiTapDelayPedal.defaultMix
)
}
// MARK: - Effect
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
let tap1: DelayLine = makeTap(dry, delay: $time1, volume: $vol1)
let tap2: DelayLine = makeTap(dry, delay: $time2, volume: $vol2)
let tap3: DelayLine = makeTap(dry, delay: $time3, volume: $vol3)
return tap1 + tap2 + tap3
}
private func makeTap(
_ dry: any ValidGeneratorInput,
delay: any ValidGeneratorInput,
volume: any ValidGeneratorInput
) -> DelayLine {
DelayLine(
input: dry,
maxDelay: maxDelayTime,
delay: delay,
sampleRate: sampleRate,
interpolation: .linear,
mul: volume
)
}
}