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>
This commit is contained in:
2026-06-21 15:07:34 -07:00
parent 6f55615d7b
commit c28e7cac90
11 changed files with 882 additions and 7 deletions
@@ -0,0 +1,118 @@
// AutoWahPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Amplitude-tracked auto-wah pedal built from discrete tracking + filter stages.
///
/// Unlike `MuTronPedal` (which wraps the single fused `MuTronIII` generator), this pedal
/// wires the envelope path explicitly: an `AmplitudeFollower` tracks the dry signal level,
/// the envelope is scaled by `sensitivity` and clamped to `[0, 1]`, then mapped through an
/// exponential `LinExp` curve to a cutoff frequency that sweeps a resonant `SVF` bandpass.
/// Louder playing opens the filter — the classic "wah" vowel that follows your picking.
///
/// ## Signal path
/// ```
/// dry → AmplitudeFollower → ×sensitivity → Clip[0,1] → LinExp(freqLo…range) → SVF.bandpass
/// ↑freq
/// ```
///
/// ## Knobs
/// - `sensitivity`: How hard the envelope drives the sweep; higher reaches the top of the range sooner.
/// - `resonance`: Bandpass Q. Higher values sharpen the vowel and add emphasis.
/// - `range`: Upper cutoff in Hz reached at full envelope. Sets the sweep span over `freqLo`.
public final class AutoWahPedal: Pedal {
// MARK: - Parameters
/// Envelope drive into the cutoff sweep. Higher values open the filter on quieter input.
@UIParam public var sensitivity: Double = 2.0
/// Bandpass resonance (SVF quality factor). Higher values sharpen the wah vowel.
@UIParam public var resonance: Double = 3.0
/// Upper cutoff frequency in Hz at maximum envelope.
@UIParam public var range: Double = 2400.0
// MARK: - Constants
private static let defaultMix: Double = 1.0
/// Cutoff at zero envelope, in Hz. `LinExp` requires a strictly positive lower bound.
private let freqLo: Double = 200.0
/// Envelope-follower attack/release times, in seconds.
private let attackTime: Double = 0.01
private let releaseTime: Double = 0.12
/// Clamp bounds for the scaled envelope before the exponential frequency map.
private let envFloor: Double = 0.0
private let envCeiling: Double = 1.0
// MARK: - Ranges
private let sensitivityRange: ClosedRange<Double> = 0.0 ... 4.0
private let resonanceRange: ClosedRange<Double> = 0.5 ... 8.0
private let rangeRange: ClosedRange<Double> = 500.0 ... 5000.0
// MARK: - Knobs
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Sensitivity", node: $sensitivity, range: sensitivityRange),
PedalKnob(label: "Resonance", node: $resonance, range: resonanceRange),
PedalKnob(label: "Range", node: $range, range: rangeRange),
]
}
// MARK: - Init
public init(inputBus: Int = 0, outputBus: Int = 0) {
super.init(
name: "Auto-Wah",
inputBus: inputBus,
outputBus: outputBus,
initialMix: AutoWahPedal.defaultMix
)
}
// MARK: - Effect
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
// Track the dry signal's amplitude envelope.
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
in: dry,
attackTime: attackTime,
releaseTime: releaseTime
)
// Scale by sensitivity and clamp to [0, 1] so the exponential map stays in range
// and the swept cutoff never exceeds `range` (and thus never approaches Nyquist).
let driven: Clip.Audio = Clip.Audio(
envelope * $sensitivity,
lo: envFloor,
hi: envCeiling
)
// Map the clamped envelope to an exponential cutoff sweep from freqLo to range.
let cutoff: LinExp.Audio = LinExp.Audio(
driven,
inLo: envFloor,
inHi: envCeiling,
outLo: freqLo,
outHi: $range
)
// Resonant bandpass swept by the tracked envelope — the wah voice.
let filtered: SVF.Audio = SVF.Audio(
input: dry,
freq: cutoff,
q: $resonance
)
return filtered.bandpass
}
}
@@ -0,0 +1,99 @@
// 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
)
}
}
@@ -0,0 +1,115 @@
// MuTronPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Envelope-following filter pedal modeled on the Musitronics Mu-Tron III.
///
/// Wraps the Lyrebird `MuTronIII` generator. The input amplitude drives an exponential
/// cutoff sweep through a resonant Chamberlin state-variable filter. Because `MuTronIII`
/// fixes its filter `mode` at `init`, three instances (lowpass, bandpass, highpass) run
/// in parallel on the shared dry signal and a `Select` switch picks the active one from
/// the `mode` knob — this keeps all three filter states warmed so mode changes are
/// click-free (SuperCollider `Select` semantics: every input advances each block).
///
/// ## Knobs
/// - `mode`: Filter response. `0` = lowpass, `1` = bandpass (classic vowel wah), `2` = highpass.
/// - `sensitivity`: Drive into the envelope follower; higher values open the filter on quieter notes.
/// - `resonance`: Filter peak emphasis at the swept cutoff.
public final class MuTronPedal: Pedal {
// MARK: - Parameters
/// Filter response selector. `0` = lowpass, `1` = bandpass, `2` = highpass.
@UIParam public var mode: Double = 1.0
/// Envelope-follower drive. Higher values make the filter respond to quieter input.
@UIParam public var sensitivity: Double = 1.5
/// Filter resonance (Chamberlin SVF peak emphasis). Clamped to `≥ 1.0` internally.
@UIParam public var resonance: Double = 4.0
// MARK: - Constants
private static let defaultMix: Double = 1.0
/// Sweep direction is fixed to the classic "louder opens the filter" response.
private let sweepDirection: MuTronIIISweep = .up
/// Cutoff at zero envelope, in Hz.
private let freqLo: Double = 80.0
/// Cutoff at maximum envelope, in Hz (≈40× sweep over `freqLo`).
private let freqHi: Double = 3200.0
/// Envelope attack/release times, in seconds.
private let attackTime: Double = 0.005
private let releaseTime: Double = 0.15
/// Half-step bias added before `Select`'s truncate-toward-zero index, turning the
/// `mode` knob into a round-to-nearest 3-position switch over `[0, 2]`.
private let modeRoundingBias: Double = 0.5
// MARK: - Ranges
private let modeRange: ClosedRange<Double> = 0.0 ... 2.0
private let sensitivityRange: ClosedRange<Double> = 0.0 ... 4.0
private let resonanceRange: ClosedRange<Double> = 1.0 ... 12.0
// MARK: - Knobs
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Mode", node: $mode, range: modeRange),
PedalKnob(label: "Sensitivity", node: $sensitivity, range: sensitivityRange),
PedalKnob(label: "Resonance", node: $resonance, range: resonanceRange),
]
}
// MARK: - Init
public init(inputBus: Int = 0, outputBus: Int = 0) {
super.init(
name: "Mu-Tron",
inputBus: inputBus,
outputBus: outputBus,
initialMix: MuTronPedal.defaultMix
)
}
// MARK: - Effect
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
let lowpass: MuTronIII.Audio = makeFilter(dry, mode: .lowpass)
let bandpass: MuTronIII.Audio = makeFilter(dry, mode: .bandpass)
let highpass: MuTronIII.Audio = makeFilter(dry, mode: .highpass)
// Round the [0, 2] knob to the nearest integer index, then switch.
let which: any ValidGeneratorInput = $mode + modeRoundingBias
return Select.Audio(
which: which,
inputs: [lowpass, bandpass, highpass]
)
}
private func makeFilter(
_ dry: any ValidGeneratorInput,
mode: MuTronIIIMode
) -> MuTronIII.Audio {
MuTronIII.Audio(
input: dry,
mode: mode,
direction: sweepDirection,
sensitivity: $sensitivity,
peak: $resonance,
freqLo: freqLo,
freqHi: freqHi,
attackTime: attackTime,
releaseTime: releaseTime
)
}
}
@@ -0,0 +1,114 @@
// 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
)
}
}
@@ -12,9 +12,9 @@
/// are silently skipped by the loader.
///
/// To register custom pedal types, extend `builtIn` by building your own dictionary
/// and merging it before calling `loadRig`. The built-in registry covers the eight
/// factory pedals: Overdrive, Delay, Reverb, Modulation, Fuzz, Tremolo, Phaser, and
/// Compressor.
/// and merging it before calling `loadRig`. The built-in registry covers the twelve
/// factory pedals: Overdrive, Delay, Reverb, Modulation, Fuzz, Tremolo, Phaser,
/// Compressor, Mu-Tron, Auto-Wah, Feedback Delay, and Multi-Tap Delay.
public enum PedalRegistry {
/// Maps each built-in pedal display name to a `@MainActor` no-argument constructor.
@@ -32,6 +32,10 @@ public enum PedalRegistry {
"Tremolo": { TremoloPedal() },
"Phaser": { PhaserPedal() },
"Compressor": { CompressorPedal() },
"Mu-Tron": { MuTronPedal() },
"Auto-Wah": { AutoWahPedal() },
"Feedback Delay": { FeedbackDelayPedal() },
"Multi-Tap Delay": { MultiTapDelayPedal() },
]
/// Returns a new `Pedal` instance for the given type string, or `nil` if the type