From 6718914ee0fba86bfaa0a298ca44a68af5bb2b81 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Mon, 3 Aug 2026 07:03:51 -0700 Subject: [PATCH] =?UTF-8?q?feat(amps):=20Fullerton=20Reverb=20=E2=80=94=20?= =?UTF-8?q?full=20control=20surface=20(reverb=20+=20tremolo=20+=20bright)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First combo amp with onboard effects, modeling the American blackface clean voice. Adds two overridable hooks to AmpVoicePedal so an amp can insert stages without touching the fixed chain: - inputShaping(_:) — pre-preamp (bright switch here) - onboardEffects(_:) — after tone stack, before power amp (reverb + tremolo here) FullertonReverbAmpPedal (.fender): - Spring reverb (SpringReverb) with a Reverb mix knob. - Tremolo (unipolar sine gain LFO) with Speed + Intensity knobs; defaults off so the amp opens as a clean reverbed platform. ("Vibrato" channel is really AM.) - Bright switch: a pre-preamp high-shelf whose gain is scaled by the toggle, so Off is a true identity and the switch is live (no rebuild). - Full surface: Gain/Bass/Mid/Treble + Reverb/Speed/Intensity knobs, Bright switch, Cab selector; widthUnits 3. Registered across registry / type / category / palette / enclosure color; Help acknowledgment lists its tone stack. 9 tests (FX effect, ceiling with FX on, control surface, state round-trip, registry). Co-Authored-By: Claude Opus 4.8 --- Sources/LyrebirdShoeGaze/PedalType.swift | 1 + .../Pedals/AmpVoicePedal.swift | 28 +++- .../Pedals/FullertonReverbAmpPedal.swift | 116 ++++++++++++++++ .../Presets/PedalRegistry.swift | 1 + Sources/LyrebirdShoeGazeUI/HelpView.swift | 7 +- .../LyrebirdShoeGazeUI/PedalCategory.swift | 2 +- .../LyrebirdShoeGazeUI/PedalPaletteView.swift | 2 +- Sources/LyrebirdShoeGazeUI/PedalView.swift | 1 + .../FullertonReverbAmpPedalTests.swift | 129 ++++++++++++++++++ 9 files changed, 279 insertions(+), 8 deletions(-) create mode 100644 Sources/LyrebirdShoeGaze/Pedals/FullertonReverbAmpPedal.swift create mode 100644 Tests/LyrebirdShoeGazeTests/FullertonReverbAmpPedalTests.swift diff --git a/Sources/LyrebirdShoeGaze/PedalType.swift b/Sources/LyrebirdShoeGaze/PedalType.swift index e064687..a6eda8e 100644 --- a/Sources/LyrebirdShoeGaze/PedalType.swift +++ b/Sources/LyrebirdShoeGaze/PedalType.swift @@ -47,6 +47,7 @@ public extension PedalType { static let california = PedalType("California") static let british = PedalType("British") static let chime = PedalType("Chime") + static let fullertonReverb = PedalType("Fullerton Reverb") static let neuralAmp = PedalType("Neural Amp") static let overdrive = PedalType("Overdrive") static let distortion = PedalType("Distortion") diff --git a/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift b/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift index a94cef0..a29e4d7 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift @@ -12,8 +12,10 @@ import LyrebirdUI /// Each concrete amp fixes one tone-stack ``ToneStackModel`` and adds one signature control, but /// shares the common chain built here: /// ``` -/// dry → TriodeStage(drive: gain) (preamp) +/// dry → inputShaping(_:) (subclass hook — e.g. bright switch; default identity) +/// → TriodeStage(drive: gain) (preamp) /// → ToneStack(bass, mid, treble, model) (fixed per amp) +/// → onboardEffects(_:) (subclass hook — e.g. reverb + tremolo; default identity) /// → TriodeStage(power-amp drive) (power-amp warmth) /// → shapeVoice(_:) (subclass signature filter) /// → ConvolutionReverb(cab IR) (speaker cabinet — voice-selectable, rebuild on change) @@ -64,6 +66,24 @@ open class AmpVoicePedal: Pedal { signal } + /// Shaping applied to the dry input *before* the preamp — e.g. a bright-switch treble lift that + /// hits the tubes pre-distortion. Default: identity. Subclasses override. + /// + /// - Parameter signal: The dry input signal. + /// - Returns: The shaped signal fed into the preamp. + open func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput { + signal + } + + /// Onboard effects inserted *after* the tone stack and *before* the power amp — the slot a + /// combo amp's built-in reverb and tremolo occupy. Default: identity. Subclasses override. + /// + /// - Parameter signal: The post-tone-stack signal. + /// - Returns: The signal fed into the power-amp stage. + open func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput { + signal + } + // MARK: - Constants private static let defaultMix: Double = 1.0 @@ -165,11 +185,13 @@ open class AmpVoicePedal: Pedal { /// - Returns: The amped, cab-convolved, soft-limited, ceiling-clamped mono output. public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput { let sr: Double = sampleRate - let preamp: TriodeStage = TriodeStage(input: dry, drive: $gain, bias: preampBias, oversample: 4) + let preShaped: any ValidGeneratorInput = inputShaping(dry) + let preamp: TriodeStage = TriodeStage(input: preShaped, drive: $gain, bias: preampBias, oversample: 4) let toned: ToneStack = ToneStack( input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel) + let processed: any ValidGeneratorInput = onboardEffects(toned) let powerAmp: TriodeStage = TriodeStage( - input: toned, drive: powerAmpDrive, bias: powerAmpBias, oversample: 2) + input: processed, drive: powerAmpDrive, bias: powerAmpBias, oversample: 2) let shaped: any ValidGeneratorInput = shapeVoice(powerAmp) let voice: CabinetVoice = CabinetVoice.voice(atSelectorValue: cab) let cabinet: ConvolutionReverb.Audio = ConvolutionReverb.Audio( diff --git a/Sources/LyrebirdShoeGaze/Pedals/FullertonReverbAmpPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/FullertonReverbAmpPedal.swift new file mode 100644 index 0000000..041aaf6 --- /dev/null +++ b/Sources/LyrebirdShoeGaze/Pedals/FullertonReverbAmpPedal.swift @@ -0,0 +1,116 @@ +// FullertonReverbAmpPedal.swift +// Lyrebird +// +// Copyright (c) 2026 Joshua Parmenter / realizedsound +// SPDX-License-Identifier: MIT + +import LyrebirdSynth +import LyrebirdUI + +/// American blackface-combo amp with a full onboard control surface: spring **reverb**, **tremolo** +/// (Speed / Intensity), and a **Bright** switch — the loud, headroom-rich clean voice. +/// +/// A ``AmpVoicePedal`` fixed to the American tone stack that fills both subclass hooks: +/// - ``inputShaping(_:)`` applies the Bright switch as a pre-preamp treble shelf. +/// - ``onboardEffects(_:)`` inserts the spring reverb then the tremolo, between the tone stack and +/// the power amp — the slot a combo amp's built-in reverb/tremolo occupy. +/// +/// The amp's "vibrato" channel is historically amplitude modulation (tremolo), not pitch vibrato, +/// so `Intensity` drives a unipolar-sine gain LFO. Tremolo defaults off (`Intensity = 0`) so the +/// amp opens as a clean, reverbed platform. +public final class FullertonReverbAmpPedal: AmpVoicePedal { + + // MARK: - Onboard-effect parameters + + /// Spring-reverb wet mix in [0, 1]. `0` = dry, `1` = fully wet. + @UIParam public var reverb: Double = 0.25 + /// Tremolo LFO rate in Hz. Range [0.5, 12]. + @UIParam public var speed: Double = 4.0 + /// Tremolo depth in [0, 1]. `0` = off (clean), `1` = full silence-to-unity swing. + @UIParam public var intensity: Double = 0.0 + /// Bright switch: `0` = flat, `1` = treble shelf engaged. + @UIParam public var bright: Double = 0.0 + + // MARK: - Constants + + /// Bright-switch shelf corner in Hz. + private let brightFreqHz: Double = 2500.0 + /// Bright-switch shelf lift in dB when engaged. + private let brightMaxGainDb: Double = 6.0 + /// Bright-switch shelf slope. + private let brightSlope: Double = 0.8 + /// Tremolo depth scaling — at full `intensity` the LFO swings over half the normalised range so + /// the peak gain is 1.0 and the trough is `1 − intensity`. + private let tremoloDepthScale: Double = 0.5 + + private let reverbRange: ClosedRange = 0.0 ... 1.0 + private let speedRange: ClosedRange = 0.5 ... 12.0 + private let intensityRange: ClosedRange = 0.0 ... 1.0 + private let brightOffValue: Double = 0.0 + private let brightOnValue: Double = 1.0 + + // MARK: - Voice configuration + + public override var toneStackModel: ToneStackModel { .fender } + public override var summaryText: String { + "American blackface clean — spring reverb, tremolo, and a Bright switch." + } + public override var signatureKnobs: [PedalKnob] { + [ + PedalKnob(label: "Reverb", node: $reverb, range: reverbRange), + PedalKnob(label: "Speed", node: $speed, range: speedRange), + PedalKnob(label: "Intensity", node: $intensity, range: intensityRange), + ] + } + + /// Wider card to hold the extra reverb/tremolo knobs plus the Bright switch. + public override var widthUnits: Int { 3 } + + // MARK: - Init + + /// Creates a Fullerton Reverb amp. + /// + /// - 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: "Fullerton Reverb", inputBus: inputBus, outputBus: outputBus) + gain = 4.0 // headroom-rich clean default + } + + // MARK: - Switches + + public override var effectSwitches: [PedalSwitch] { + [ + PedalSwitch( + label: "Bright", + node: $bright, + options: [ + PedalSwitch.Option(title: "Off", value: brightOffValue), + PedalSwitch.Option(title: "On", value: brightOnValue), + ] + ), + ] + } + + // MARK: - Hooks + + /// Bright switch: a high-shelf lift ahead of the preamp. The switch value (`0`/`1`) scales the + /// shelf gain, so "Off" is a true identity and the effect is live (no rebuild). + public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput { + let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb + return RBJHighShelf.Audio( + input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope) + } + + /// Spring reverb → tremolo, inserted after the tone stack and before the power amp. + public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput { + let reverbed: SpringReverb.Audio = SpringReverb.Audio( + input: signal, mix: $reverb, sampleRate: sampleRate) + // Unipolar sine LFO over [1 − intensity, 1]: peak gain 1.0, trough 1 − intensity. + let lfoScale: any ValidGeneratorInput = $intensity * tremoloDepthScale + let lfoOffset: any ValidGeneratorInput = 1.0 - ($intensity * tremoloDepthScale) + let lfo: OscSin.Audio = OscSin.Audio(freq: $speed, mul: lfoScale, add: lfoOffset) + return reverbed * lfo + } +} diff --git a/Sources/LyrebirdShoeGaze/Presets/PedalRegistry.swift b/Sources/LyrebirdShoeGaze/Presets/PedalRegistry.swift index 0d2bf11..07578df 100644 --- a/Sources/LyrebirdShoeGaze/Presets/PedalRegistry.swift +++ b/Sources/LyrebirdShoeGaze/Presets/PedalRegistry.swift @@ -34,6 +34,7 @@ public enum PedalRegistry { "California": { CaliforniaAmpPedal() }, "British": { BritishAmpPedal() }, "Chime": { ChimeAmpPedal() }, + "Fullerton Reverb": { FullertonReverbAmpPedal() }, "Neural Amp": { NeuralAmpPedal() }, "Overdrive": { OverdrivePedal() }, "Distortion": { DistortionPedal() }, diff --git a/Sources/LyrebirdShoeGazeUI/HelpView.swift b/Sources/LyrebirdShoeGazeUI/HelpView.swift index 28fb2c0..b1e8ffb 100644 --- a/Sources/LyrebirdShoeGazeUI/HelpView.swift +++ b/Sources/LyrebirdShoeGazeUI/HelpView.swift @@ -178,9 +178,10 @@ public struct HelpView: View { + "built-in speaker impulse responses.", "The Cabinet pedal's built-in cab voicings are original impulse responses generated in " + "code — not captures of any third-party hardware or IR pack.", - "The California, British, and Chime amp pedals' tone stacks follow the Yeh & Smith analysis " - + "of the classic passive tone-stack circuit (\"Discretization of the '59 Fender Bassman Tone " - + "Stack\", DAFx-06); their models are original code, not captures of specific hardware.", + "The California, British, Chime, and Fullerton Reverb amp pedals' tone stacks follow the " + + "Yeh & Smith analysis of the classic passive tone-stack circuit (\"Discretization of the " + + "'59 Fender Bassman Tone Stack\", DAFx-06); their models are original code, not captures of " + + "specific hardware.", "The Neural Amp pedal loads GuitarML Proteus / NeuralPi capture models (the open LSTM " + "format from github.com/GuitarML). You supply the model file; none are bundled, and " + "those models are licensed by their respective authors.", diff --git a/Sources/LyrebirdShoeGazeUI/PedalCategory.swift b/Sources/LyrebirdShoeGazeUI/PedalCategory.swift index 278b9fd..a14f478 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalCategory.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalCategory.swift @@ -42,7 +42,7 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable { } private static let mapping: [String: PedalCategory] = [ - "California": .gain, "British": .gain, "Chime": .gain, "Neural Amp": .gain, "Overdrive": .gain, "Distortion": .gain, "Fuzz": .gain, "Volume": .gain, + "California": .gain, "British": .gain, "Chime": .gain, "Fullerton Reverb": .gain, "Neural Amp": .gain, "Overdrive": .gain, "Distortion": .gain, "Fuzz": .gain, "Volume": .gain, "Compressor": .dynamics, "Sustainer": .dynamics, "Limiter": .dynamics, "Noise Gate": .dynamics, "Graphic EQ": .filter, "Auto-Wah": .filter, "Wah": .filter, "Mutant": .filter, "Cabinet": .filter, diff --git a/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift b/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift index 14d83a1..cb2bab6 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift @@ -54,7 +54,7 @@ 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] = [ - "California", "British", "Chime", "Neural Amp", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz", + "California", "British", "Chime", "Fullerton Reverb", "Neural Amp", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz", "Volume", "Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary", "Auto-Wah", "Wah", "Mutant", "Cabinet", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator", diff --git a/Sources/LyrebirdShoeGazeUI/PedalView.swift b/Sources/LyrebirdShoeGazeUI/PedalView.swift index 1d1c690..29d9a1a 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalView.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalView.swift @@ -20,6 +20,7 @@ private func enclosureColor(for displayName: String) -> Color { case "California": return Color(red: 0.20, green: 0.28, blue: 0.34) // West-Coast steel blue case "British": return Color(red: 0.30, green: 0.16, blue: 0.10) // oxblood tolex case "Chime": return Color(red: 0.16, green: 0.24, blue: 0.22) // vintage green + case "Fullerton Reverb": return Color(red: 0.15, green: 0.22, blue: 0.30) // blackface panel case "Neural Amp": return Color(red: 0.22, green: 0.16, blue: 0.30) // deep neural violet 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 diff --git a/Tests/LyrebirdShoeGazeTests/FullertonReverbAmpPedalTests.swift b/Tests/LyrebirdShoeGazeTests/FullertonReverbAmpPedalTests.swift new file mode 100644 index 0000000..db75cc9 --- /dev/null +++ b/Tests/LyrebirdShoeGazeTests/FullertonReverbAmpPedalTests.swift @@ -0,0 +1,129 @@ +// FullertonReverbAmpPedalTests.swift +// Lyrebird +// +// Copyright (c) 2026 Joshua Parmenter / realizedsound +// SPDX-License-Identifier: MIT + +import Testing +import Foundation +import LyrebirdSynth +import LyrebirdUI +@testable import LyrebirdShoeGaze + +@MainActor +@Suite("FullertonReverbAmpPedal") +struct FullertonReverbAmpPedalTests { + + private let sampleRate: Double = 48000.0 + + private func render(configure: (FullertonReverbAmpPedal) -> Void = { _ in }) throws -> [Float] { + let (engine, url): (SynthesisEngine, URL) = makeNRTEngine( + duration: 0.3, sampleRate: sampleRate, numAudioBuses: 64) + defer { try? FileManager.default.removeItem(at: url) } + + let srcBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1) + let dstBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1) + defer { + engine.busAllocator.releaseAudioBus(srcBus) + engine.busAllocator.releaseAudioBus(dstBus) + } + + let source: TestLoopSource = TestLoopSource(targetBus: srcBus.index) + let pedal: FullertonReverbAmpPedal = FullertonReverbAmpPedal( + inputBus: srcBus.index, outputBus: dstBus.index) + pedal.sampleRate = sampleRate + configure(pedal) + let master: TestRouteMaster = TestRouteMaster(inputBusIndex: dstBus.index) + try engine.add(source) + try engine.add(pedal, position: NodePosition.after(source)) + try engine.add(master, position: NodePosition.after(pedal)) + try engine.start() + return readStereoCAF(url: url, sampleRate: sampleRate) + } + + private func windowedSSD(_ a: [Float], _ b: [Float], skip: Int = 4096, window: Int = 4096) -> Double { + guard a.count >= skip + window, b.count >= skip + window else { return 0.0 } + return zip(a[skip..<(skip + window)], b[skip..<(skip + window)]).reduce(0.0) { acc, pair in + let d: Double = Double(pair.0 - pair.1); return acc + d * d + } + } + + @Test func buildsNonSilentFiniteOutput() throws { + let samples: [Float] = try render() + #expect(!samples.isEmpty) + #expect(hasNonSilentOutput(samples), "Fullerton Reverb produced silence") + #expect(samples.allSatisfy { $0.isFinite }, "Fullerton Reverb produced non-finite output") + } + + @Test func reverbMixChangesOutput() throws { + let dry: [Float] = try render { $0.reverb = 0.0 } + let wet: [Float] = try render { $0.reverb = 0.9 } + #expect(windowedSSD(dry, wet) > 0, "reverb mix had no effect") + } + + @Test func tremoloIntensityChangesOutput() throws { + let off: [Float] = try render { $0.intensity = 0.0 } + let on: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0 } + #expect(windowedSSD(off, on) > 0, "tremolo intensity had no effect") + } + + @Test func tremoloSpeedChangesOutput() throws { + let slow: [Float] = try render { $0.intensity = 1.0; $0.speed = 1.0 } + let fast: [Float] = try render { $0.intensity = 1.0; $0.speed = 10.0 } + #expect(windowedSSD(slow, fast) > 0, "tremolo speed had no effect") + } + + @Test func brightSwitchChangesOutput() throws { + let flat: [Float] = try render { $0.bright = 0.0 } + let bright: [Float] = try render { $0.bright = 1.0 } + #expect(windowedSSD(flat, bright) > 0, "bright switch had no effect") + } + + @Test func outputStaysWithinCeilingWithFXEngaged() throws { + let ceilingEpsilon: Double = 1.0e-4 + let hot: [Float] = try render { (pedal: FullertonReverbAmpPedal) in + pedal.gain = 30.0 + pedal.bass = 1.0 + pedal.treble = 1.0 + pedal.reverb = 1.0 + pedal.bright = 1.0 + } + let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) } + #expect(peak <= 1.0 + ceilingEpsilon, "peak \(peak) exceeds the ±1 ceiling") + #expect(peak > 0.3, "unexpectedly quiet at max gain: \(peak)") + } + + @Test func exposesFullControlSurface() throws { + let pedal: FullertonReverbAmpPedal = FullertonReverbAmpPedal() + #expect(pedal.effectKnobs.map { $0.label } + == ["Gain", "Bass", "Mid", "Treble", "Reverb", "Speed", "Intensity"]) + #expect(pedal.effectSwitches.map { $0.label } == ["Bright"]) + #expect(pedal.effectSelectors.map { $0.label } == ["Cab"]) + #expect(pedal.effectSelectors.first?.rebuildsOnChange == true) + #expect(pedal.widthUnits == 3) + #expect(pedal.showsMixControl == false) + #expect(pedal.toneStackModel == .fender) + } + + @Test func controlsRoundTripThroughState() throws { + let pedal: FullertonReverbAmpPedal = FullertonReverbAmpPedal() + pedal.gain = 8.0 + pedal.reverb = 0.7 + pedal.speed = 9.0 + pedal.intensity = 0.6 + pedal.bright = 1.0 + pedal.cab = 2.0 + let restored: FullertonReverbAmpPedal = FullertonReverbAmpPedal() + restored.applyState(pedal.captureState()) + #expect(restored.gain == 8.0) + #expect(restored.reverb == 0.7) + #expect(restored.speed == 9.0) + #expect(restored.intensity == 0.6) + #expect(restored.bright == 1.0) + #expect(restored.cab == 2.0) + } + + @Test func registeredInBuiltInRegistry() throws { + #expect(PedalRegistry.makePedal(type: "Fullerton Reverb") is FullertonReverbAmpPedal) + } +}