Add Flanger, Vibrato, and Distortion pedals; 6th intervals on Harmonizer
- Flanger: wraps Lyrebird Flanger (Rate/Depth/Feedback), run fully wet. - Vibrato: sine-swept delay line, fully wet pitch wobble (Rate/Depth). - Distortion: DC-block → tanh drive → tone LPF → hard clip (Drive/Tone); sits between Overdrive and Fuzz. - Harmonizer interval pickers gain minor/major sixths above and below. Each registered (PedalType + registry + enclosure color + palette slot) with build/non-silent + parameter-change + registry tests. Suite 227. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,7 @@ public extension PedalType {
|
||||
|
||||
// Drive & dynamics
|
||||
static let overdrive = PedalType("Overdrive")
|
||||
static let distortion = PedalType("Distortion")
|
||||
static let fuzz = PedalType("Fuzz")
|
||||
static let compressor = PedalType("Compressor")
|
||||
static let limiter = PedalType("Limiter")
|
||||
@@ -60,6 +61,8 @@ public extension PedalType {
|
||||
static let tremolo = PedalType("Tremolo")
|
||||
static let modulation = PedalType("Modulation")
|
||||
static let chorus = PedalType("Chorus")
|
||||
static let flanger = PedalType("Flanger")
|
||||
static let vibrato = PedalType("Vibrato")
|
||||
static let ringModulator = PedalType("Ring Modulator")
|
||||
static let diffuser = PedalType("Diffuser")
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
// DistortionPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Mid-gain distortion — more saturated than `OverdrivePedal`, more controlled than `FuzzPedal`.
|
||||
///
|
||||
/// A DC-blocking high-pass feeds a `tanh` soft-clipper driven hard by the `Drive` knob; a
|
||||
/// post-clip low-pass `Tone` control tames the harmonics, and a final hard clip guarantees the
|
||||
/// output stays bounded.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `drive`: Pre-clip gain into the `tanh` stage. Range `[1, 50]`.
|
||||
/// - `tone`: Post-clip low-pass cutoff in Hz. Range `[500, 6000]`.
|
||||
public final class DistortionPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Mid-gain saturated distortion sitting between overdrive and fuzz."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Pre-clip gain into the `tanh` stage. Range [1, 50].
|
||||
@UIParam public var drive: Double = 12.0
|
||||
|
||||
/// Post-clip low-pass cutoff in Hz. Range [500, 6000].
|
||||
@UIParam public var tone: Double = 3000.0
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Distortion is heard fully wet; the `Level` knob sets output gain.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// DC-blocking high-pass cutoff in Hz, applied before the clipper.
|
||||
private let dcBlockFreq: Double = 80.0
|
||||
|
||||
/// Butterworth Q (no resonant peak) for the conditioning filters.
|
||||
private let filterQ: Double = 0.707
|
||||
|
||||
/// Output hard-clip bounds — guarantees a bounded signal after tone shaping.
|
||||
private let clipLow: Double = -1.0
|
||||
private let clipHigh: Double = 1.0
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let driveRange: ClosedRange<Double> = 1.0 ... 50.0
|
||||
private let toneRange: ClosedRange<Double> = 500.0 ... 6000.0
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||||
PedalKnob(label: "Tone", node: $tone, range: toneRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a distortion pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Distortion",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: DistortionPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let dcBlocked: RBJHighPass.Audio = RBJHighPass.Audio(
|
||||
input: dry,
|
||||
freq: dcBlockFreq,
|
||||
q: filterQ
|
||||
)
|
||||
let driven: Tanh.Audio = Tanh.Audio(dcBlocked, mul: $drive)
|
||||
let toned: RBJLowPass.Audio = RBJLowPass.Audio(
|
||||
input: driven,
|
||||
freq: $tone,
|
||||
q: filterQ
|
||||
)
|
||||
return Clip.Audio(toned, lo: clipLow, hi: clipHigh)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
// FlangerPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Classic jet-flanger.
|
||||
///
|
||||
/// A short LFO-swept delay summed with the dry signal produces the sweeping comb-filter notches;
|
||||
/// feedback sharpens them into the metallic "jet" whoosh. Wraps Lyrebird's `Flanger` generator,
|
||||
/// run fully wet so the pedal's own `Mix` knob sets the wet/dry blend.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `rate`: LFO sweep rate in Hz. Range `[0.05, 8]`.
|
||||
/// - `depth`: Sweep depth as a fraction of the center delay. Range `[0, 1]`.
|
||||
/// - `feedback`: Comb feedback (resonance). Range `[0, 0.95]`.
|
||||
public final class FlangerPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Sweeping comb-filter jet flanger, with feedback for that metallic whoosh."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// LFO sweep rate in Hz. Range [0.05, 8].
|
||||
@UIParam public var rate: Double = 0.4
|
||||
|
||||
/// Sweep depth as a fraction of the center delay. Range [0, 1].
|
||||
@UIParam public var depth: Double = 0.6
|
||||
|
||||
/// Comb feedback (resonance). Range [0, 0.95].
|
||||
@UIParam public var feedback: Double = 0.3
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Default wet/dry blend — flanger sits under the dry signal.
|
||||
private static let defaultMix: Double = 0.5
|
||||
|
||||
/// Center delay the LFO sweeps around, in seconds.
|
||||
private let centerDelayTime: Double = 0.005
|
||||
|
||||
/// Maximum delay the line is allocated for, in seconds. Covers `centerDelayTime · (1 + maxDepth)`.
|
||||
private let maxDelayTime: Double = 0.05
|
||||
|
||||
/// The wrapped generator runs fully wet; the `Pedal` base `Mix` knob does the blend.
|
||||
private let fullyWetMix: Double = 1.0
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let rateRange: ClosedRange<Double> = 0.05 ... 8.0
|
||||
private let depthRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
private let feedbackRange: ClosedRange<Double> = 0.0 ... 0.95
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||
PedalKnob(label: "Depth", node: $depth, range: depthRange),
|
||||
PedalKnob(label: "Feedback", node: $feedback, range: feedbackRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a flanger pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Flanger",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: FlangerPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
Flanger.Audio(
|
||||
input: dry,
|
||||
delayTime: centerDelayTime,
|
||||
depth: $depth,
|
||||
rate: $rate,
|
||||
feedback: $feedback,
|
||||
mix: fullyWetMix,
|
||||
sampleRate: sampleRate,
|
||||
maxDelayTime: maxDelayTime
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// VibratoPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Pitch vibrato.
|
||||
///
|
||||
/// A single delay line whose time is swept by a sine LFO produces a periodic pitch wobble. Unlike
|
||||
/// `TremoloPedal` (which modulates *volume*), vibrato modulates *pitch*, and unlike `ChorusPedal`
|
||||
/// it is heard fully wet — there is no dry voice underneath, so the result is pure pitch movement.
|
||||
///
|
||||
/// ## Knobs
|
||||
/// - `rate`: LFO rate in Hz. Range `[0.1, 8]`.
|
||||
/// - `depth`: Delay-sweep depth in seconds (half-swing around the base delay). Range
|
||||
/// `[0.0005, 0.006]`.
|
||||
public final class VibratoPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Periodic pitch wobble — a sine-swept delay heard fully wet."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// LFO rate in Hz. Range [0.1, 8].
|
||||
@UIParam public var rate: Double = 5.0
|
||||
|
||||
/// Delay-sweep depth in seconds. Range [0.0005, 0.006].
|
||||
@UIParam public var depth: Double = 0.002
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Vibrato is pure pitch movement — fully wet, no dry voice underneath.
|
||||
private static let defaultMix: Double = 1.0
|
||||
|
||||
/// Base delay around which the LFO sweeps, in seconds.
|
||||
private let baseDelayTime: Double = 0.006
|
||||
|
||||
/// Maximum delay the line is allocated for, in seconds. Covers `baseDelayTime + max depth`.
|
||||
private let maxDelayTime: Double = 0.02
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let rateRange: ClosedRange<Double> = 0.1 ... 8.0
|
||||
private let depthRange: ClosedRange<Double> = 0.0005 ... 0.006
|
||||
|
||||
// MARK: - Knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Rate", node: $rate, range: rateRange),
|
||||
PedalKnob(label: "Depth", node: $depth, range: depthRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a vibrato pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Vibrato",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: VibratoPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
let sweep: OscSin.Audio = OscSin.Audio(
|
||||
freq: $rate,
|
||||
phase: 0.0,
|
||||
mul: $depth,
|
||||
add: baseDelayTime
|
||||
)
|
||||
return DelayLine(
|
||||
input: dry,
|
||||
maxDelay: maxDelayTime,
|
||||
delay: sweep,
|
||||
sampleRate: sampleRate,
|
||||
interpolation: .linear
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ public enum PedalRegistry {
|
||||
/// to a board via `board.add(_:)`.
|
||||
public static let builtIn: [String: @MainActor () -> Pedal] = [
|
||||
"Overdrive": { OverdrivePedal() },
|
||||
"Distortion": { DistortionPedal() },
|
||||
"Delay": { DelayPedal() },
|
||||
"Reverb": { ReverbPedal() },
|
||||
"Modulation": { ModulationPedal() },
|
||||
@@ -51,6 +52,8 @@ public enum PedalRegistry {
|
||||
"Noise Gate": { NoiseGatePedal() },
|
||||
"Graphic EQ": { GraphicEQPedal() },
|
||||
"Chorus": { ChorusPedal() },
|
||||
"Flanger": { FlangerPedal() },
|
||||
"Vibrato": { VibratoPedal() },
|
||||
"Sustainer": { SustainerPedal() },
|
||||
"Ring Modulator": { RingModulatorPedal() },
|
||||
"Diffuser": { DiffuserPedal() },
|
||||
|
||||
@@ -51,8 +51,8 @@ public struct PedalPaletteView: View {
|
||||
/// Preferred display order for the built-in pedals. Any registered pedal not listed here is
|
||||
/// appended afterwards (sorted) so the palette never silently drops a newly added pedal.
|
||||
private static let preferredOrder: [String] = [
|
||||
"Overdrive", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus",
|
||||
"Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz",
|
||||
"Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus", "Flanger", "Vibrato",
|
||||
"Auto-Wah", "Mutant", "Ring Modulator", "Diffuser", "Bass Octaver", "Octave Splitter",
|
||||
"Harmonizer",
|
||||
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverb",
|
||||
|
||||
@@ -17,6 +17,7 @@ import LyrebirdShoeGaze
|
||||
private func enclosureColor(for displayName: String) -> Color {
|
||||
switch displayName {
|
||||
case "Overdrive": return Color(red: 0.85, green: 0.42, blue: 0.08) // warm orange
|
||||
case "Distortion": return Color(red: 0.80, green: 0.26, blue: 0.12) // hot rust
|
||||
case "Delay": return Color(red: 0.10, green: 0.55, blue: 0.55) // teal
|
||||
case "Reverb": return Color(red: 0.30, green: 0.18, blue: 0.65) // indigo
|
||||
case "Modulation": return Color(red: 0.12, green: 0.58, blue: 0.22) // green
|
||||
@@ -32,6 +33,8 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
case "Noise Gate": return Color(red: 0.24, green: 0.26, blue: 0.30) // gunmetal
|
||||
case "Graphic EQ": return Color(red: 0.14, green: 0.40, blue: 0.50) // deep teal
|
||||
case "Chorus": return Color(red: 0.16, green: 0.50, blue: 0.64) // aqua
|
||||
case "Flanger": return Color(red: 0.28, green: 0.52, blue: 0.78) // steel blue
|
||||
case "Vibrato": return Color(red: 0.42, green: 0.30, blue: 0.70) // violet-blue
|
||||
case "Sustainer": return Color(red: 0.22, green: 0.46, blue: 0.30) // pine green
|
||||
case "Ring Modulator": return Color(red: 0.64, green: 0.30, blue: 0.10) // burnt amber
|
||||
case "Diffuser": return Color(red: 0.34, green: 0.30, blue: 0.62) // periwinkle
|
||||
|
||||
Reference in New Issue
Block a user