feat(amps): split combined Amp pedal into California/British/Chime voices

Replace the single AmpPedal (a model-selector pedal) with three dedicated
amp-voice blocks, each fixing one tone-stack model and adding a signature
control so the per-amp UI can be customized:

- AmpVoicePedal: open base — shared Gain/Bass/Mid/Treble/Cab chain
  (TriodeStage preamp → ToneStack → TriodeStage power amp → shapeVoice →
  ConvolutionReverb cab), overridable toneStackModel/summary/signatureKnobs/
  shapeVoice.
- CaliforniaAmpPedal (.fender): Bright high-shelf, clean-leaning gain default.
- BritishAmpPedal (.marshall): Presence high-shelf, crunch gain default.
- ChimeAmpPedal (.vox): Cut low-pass, top-boost jangle.

Registered in PedalRegistry / PedalType / PedalCategory / palette order /
enclosure colors. Help acknowledgment updated for the three tone stacks.
12 new tests in AmpVoicePedalTests; removed AmpPedal + its tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-02 14:47:07 -07:00
parent 23d607b9fc
commit 1b247cf766
14 changed files with 462 additions and 291 deletions
@@ -0,0 +1,156 @@
// AmpVoicePedalTests.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("AmpVoicePedal")
struct AmpVoicePedalTests {
private let sampleRate: Double = 48000.0
private func render<P: AmpVoicePedal>(_ make: () -> P, configure: (P) -> 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: P = make()
pedal.inputBus = srcBus.index
pedal.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
}
}
/// The three concrete voices under test, keyed by their display name / registry key.
private let voices: [(name: String, make: () -> AmpVoicePedal)] = [
("California", { CaliforniaAmpPedal() }),
("British", { BritishAmpPedal() }),
("Chime", { ChimeAmpPedal() }),
]
@Test func allVoicesBuildNonSilentFiniteOutput() throws {
for voice in voices {
let samples: [Float] = try render(voice.make)
#expect(!samples.isEmpty)
#expect(hasNonSilentOutput(samples), "\(voice.name) produced silence")
#expect(samples.allSatisfy { $0.isFinite }, "\(voice.name) produced non-finite output")
}
}
@Test func gainChangesOutput() throws {
for voice in voices {
let clean: [Float] = try render(voice.make) { $0.gain = 2.0 }
let hot: [Float] = try render(voice.make) { $0.gain = 25.0 }
#expect(windowedSSD(clean, hot) > 0, "\(voice.name) gain had no effect")
}
}
@Test func toneControlsChangeOutput() throws {
for voice in voices {
let dark: [Float] = try render(voice.make) { $0.treble = 0.0; $0.bass = 1.0 }
let bright: [Float] = try render(voice.make) { $0.treble = 1.0; $0.bass = 0.0 }
#expect(windowedSSD(dark, bright) > 0, "\(voice.name) tone controls had no effect")
}
}
@Test func midChangesOutput() throws {
for voice in voices {
let scooped: [Float] = try render(voice.make) { $0.mid = 0.0 }
let full: [Float] = try render(voice.make) { $0.mid = 1.0 }
#expect(windowedSSD(scooped, full) > 0, "\(voice.name) mid control had no effect")
}
}
@Test func cabChangesOutput() throws {
for voice in voices {
let cabA: [Float] = try render(voice.make) { $0.cab = 0.0 }
let cabB: [Float] = try render(voice.make) { $0.cab = 2.0 }
#expect(windowedSSD(cabA, cabB) > 0, "\(voice.name) cab selection had no effect")
}
}
// MARK: - Signature controls
@Test func californiaBrightChangesOutput() throws {
let flat: [Float] = try render({ CaliforniaAmpPedal() }) { $0.bright = 0.0 }
let sparkle: [Float] = try render({ CaliforniaAmpPedal() }) { $0.bright = 1.0 }
#expect(windowedSSD(flat, sparkle) > 0, "California Bright had no effect")
}
@Test func britishPresenceChangesOutput() throws {
let flat: [Float] = try render({ BritishAmpPedal() }) { $0.presence = 0.0 }
let lifted: [Float] = try render({ BritishAmpPedal() }) { $0.presence = 1.0 }
#expect(windowedSSD(flat, lifted) > 0, "British Presence had no effect")
}
@Test func chimeCutChangesOutput() throws {
let open: [Float] = try render({ ChimeAmpPedal() }) { $0.cut = 0.0 }
let dark: [Float] = try render({ ChimeAmpPedal() }) { $0.cut = 1.0 }
#expect(windowedSSD(open, dark) > 0, "Chime Cut had no effect")
}
// MARK: - Chrome / config
@Test func exposesControls() throws {
#expect(CaliforniaAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Bright"])
#expect(BritishAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence"])
#expect(ChimeAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Cut"])
for voice in voices {
let pedal: AmpVoicePedal = voice.make()
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"], "\(voice.name) selectors")
#expect(pedal.widthUnits == 2, "\(voice.name) amp head should use a double-width card")
#expect(pedal.showsMixControl == false, "\(voice.name) should be fully wet")
}
}
@Test func distinctToneStackModels() throws {
#expect(CaliforniaAmpPedal().toneStackModel == .fender)
#expect(BritishAmpPedal().toneStackModel == .marshall)
#expect(ChimeAmpPedal().toneStackModel == .vox)
}
@Test func selectionsRoundTripThroughState() throws {
let pedal: CaliforniaAmpPedal = CaliforniaAmpPedal()
pedal.gain = 12.0
pedal.cab = 2.0
pedal.bright = 0.8
let restored: CaliforniaAmpPedal = CaliforniaAmpPedal()
restored.applyState(pedal.captureState())
#expect(restored.gain == 12.0 && restored.cab == 2.0 && restored.bright == 0.8,
"California controls did not round-trip")
}
@Test func registeredInBuiltInRegistry() throws {
#expect(PedalRegistry.makePedal(type: "California") is CaliforniaAmpPedal)
#expect(PedalRegistry.makePedal(type: "British") is BritishAmpPedal)
#expect(PedalRegistry.makePedal(type: "Chime") is ChimeAmpPedal)
}
}