feat(pedals): component Amp pedal (S2) on Lyrebird 1.7

Bump Lyrebird dependency to 1.7.0 and add a full white-box amp built on its new
amp-modeling core.

AmpPedal chain: preamp TriodeStage(drive: gain) → ToneStack(bass/mid/treble,
model) → gentle power-amp TriodeStage → speaker-cabinet ConvolutionReverb. The
tone-stack model (Fender/Marshall/Vox) and cabinet voice are each built per
option and picked live with Select, so both round-trip through the rig save
format. Fully wet (Level is master; Mix hidden).

Controls: Gain, Bass, Mid, Treble knobs + Amp / Cab selectors. Registered in
PedalRegistry / PedalType / PedalCategory (.gain) / palette / enclosure color;
Help acknowledgments cite the Yeh & Smith tone-stack model.

Tests: builds/non-silent/finite; gain, tone, amp-model, and cab all change the
output; controls exposed; amp/cab selections round-trip through PedalState;
registry resolves "Amp". Full suite 494.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-01 20:06:28 -07:00
parent 77df1675cb
commit fe31eb6d7d
10 changed files with 287 additions and 6 deletions
@@ -0,0 +1,107 @@
// AmpPedalTests.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("AmpPedal")
struct AmpPedalTests {
private let sampleRate: Double = 48000.0
private func render(configure: (AmpPedal) -> Void = { _ in }) throws -> [Float] {
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
duration: 0.2, 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: AmpPedal = AmpPedal(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 buildsAndProducesNonSilentFiniteOutput() throws {
let samples: [Float] = try render()
#expect(!samples.isEmpty)
#expect(hasNonSilentOutput(samples), "AmpPedal produced silence")
#expect(samples.allSatisfy { $0.isFinite }, "AmpPedal produced non-finite output")
}
@Test func gainChangesOutput() throws {
let clean: [Float] = try render { $0.gain = 2.0 }
let hot: [Float] = try render { $0.gain = 25.0 }
#expect(hasNonSilentOutput(clean) && hasNonSilentOutput(hot))
#expect(windowedSSD(clean, hot) > 0, "gain had no effect")
}
@Test func toneControlsChangeOutput() throws {
let dark: [Float] = try render { $0.treble = 0.0; $0.bass = 1.0 }
let bright: [Float] = try render { $0.treble = 1.0; $0.bass = 0.0 }
#expect(windowedSSD(dark, bright) > 0, "tone controls had no effect")
}
@Test func midChangesOutput() throws {
let scooped: [Float] = try render { $0.mid = 0.0 }
let full: [Float] = try render { $0.mid = 1.0 }
#expect(windowedSSD(scooped, full) > 0, "mid control had no effect")
}
@Test func ampModelChangesOutput() throws {
let fender: [Float] = try render { $0.amp = 0.0 }
let vox: [Float] = try render { $0.amp = 2.0 }
#expect(windowedSSD(fender, vox) > 0, "amp model had no effect")
}
@Test func cabChangesOutput() throws {
let cabA: [Float] = try render { $0.cab = 0.0 }
let cabB: [Float] = try render { $0.cab = 2.0 }
#expect(windowedSSD(cabA, cabB) > 0, "cab selection had no effect")
}
@Test func exposesControls() throws {
let pedal: AmpPedal = AmpPedal()
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble"])
#expect(pedal.effectSelectors.map { $0.label } == ["Amp", "Cab"])
}
@Test func selectionsRoundTripThroughState() throws {
let pedal: AmpPedal = AmpPedal()
pedal.amp = 1.0
pedal.cab = 2.0
let restored: AmpPedal = AmpPedal()
restored.applyState(pedal.captureState())
#expect(restored.amp == 1.0 && restored.cab == 2.0, "amp/cab selection did not round-trip")
}
@Test func registeredInBuiltInRegistry() throws {
let pedal: Pedal? = PedalRegistry.makePedal(type: "Amp")
#expect(pedal is AmpPedal)
}
}