feat(amps): Marshall non-master voices — Plexi / JTM / Bluesbreaker (Phase 2)
Add a shared non-master British base and three voices. BritishComboAmpPedal (open) provides the common surface: .marshall tone stack, Presence lift (post-power-amp shelf), Bright switch (pre-preamp shelf), fixed power-amp drive (loudness from Gain, no Master — distinct from the master-volume BritishAmpPedal). - British Plexi — non-master Super Lead, higher gain, 4×12. - British JTM — warmer, lower-gain JTM crunch, darker top. - British Bluesbreaker — 2×12 combo crunch + onboard tremolo (Speed/Intensity + Tremolo footswitch), widthUnits 3. Registered across all 6 sites as .amp; Help tone-stack acknowledgment genericized so it no longer needs editing per amp. 12 tests (Presence/Bright per voice, non-master check, Plexi/JTM surface, voices differ, Bluesbreaker tremolo + footswitch bit-exact bypass, ceiling, round-trip, registry). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
// BritishComboAmpPedalTests.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("British non-master combos")
|
||||
struct BritishComboAmpPedalTests {
|
||||
|
||||
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.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: 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
|
||||
}
|
||||
}
|
||||
|
||||
private let voices: [(name: String, make: () -> BritishComboAmpPedal)] = [
|
||||
("British Plexi", { BritishPlexiAmpPedal() }),
|
||||
("British JTM", { BritishJTMAmpPedal() }),
|
||||
("British Bluesbreaker", { BritishBluesbreakerAmpPedal() }),
|
||||
]
|
||||
|
||||
@Test func allBuildNonSilentFinite() throws {
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let s: [Float] = try render(v.make)
|
||||
#expect(hasNonSilentOutput(s), "\(v.name) produced silence")
|
||||
#expect(s.allSatisfy { $0.isFinite }, "\(v.name) produced non-finite output")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func presenceChangesOutput() throws {
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let low: [Float] = try render(v.make) { $0.presence = 0.0 }
|
||||
let high: [Float] = try render(v.make) { $0.presence = 1.0 }
|
||||
#expect(windowedSSD(low, high) > 0, "\(v.name) Presence had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func brightSwitchChangesOutput() throws {
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let flat: [Float] = try render(v.make) { $0.bright = 0.0 }
|
||||
let bright: [Float] = try render(v.make) { $0.bright = 1.0 }
|
||||
#expect(windowedSSD(flat, bright) > 0, "\(v.name) Bright had no effect")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func areMarshallVoicedNonMaster() throws {
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let pedal: BritishComboAmpPedal = v.make()
|
||||
#expect(pedal.toneStackModel == .marshall, "\(v.name) tone stack")
|
||||
// Non-master: no "Master" knob (that is the separate BritishAmpPedal voice).
|
||||
#expect(!pedal.effectKnobs.map { $0.label }.contains("Master"), "\(v.name) should be non-master")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func plexiAndJTMExposePresenceAndBright() throws {
|
||||
for pedal: BritishComboAmpPedal in [BritishPlexiAmpPedal(), BritishJTMAmpPedal()] {
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright"])
|
||||
}
|
||||
}
|
||||
|
||||
@Test func voicesDifferFromEachOther() throws {
|
||||
let cfg: (BritishComboAmpPedal) -> Void = { $0.gain = 6.0 }
|
||||
let plexi: [Float] = try render({ BritishPlexiAmpPedal() }, configure: cfg)
|
||||
let jtm: [Float] = try render({ BritishJTMAmpPedal() }, configure: cfg)
|
||||
#expect(windowedSSD(plexi, jtm) > 0, "Plexi and JTM should voice differently")
|
||||
}
|
||||
|
||||
// MARK: - Bluesbreaker tremolo
|
||||
|
||||
@Test func bluesbreakerExposesTremolo() throws {
|
||||
let pedal: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Speed", "Intensity"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Bright", "Tremolo"])
|
||||
#expect(pedal.widthUnits == 3)
|
||||
}
|
||||
|
||||
@Test func bluesbreakerTremoloIntensityChangesOutput() throws {
|
||||
let off: [Float] = try render({ BritishBluesbreakerAmpPedal() }) { $0.intensity = 0.0 }
|
||||
let on: [Float] = try render({ BritishBluesbreakerAmpPedal() }) { $0.intensity = 1.0; $0.speed = 6.0 }
|
||||
#expect(windowedSSD(off, on) > 0, "Bluesbreaker tremolo had no effect")
|
||||
}
|
||||
|
||||
@Test func bluesbreakerTremoloFootswitchBypassesToIdentity() throws {
|
||||
let bypassed: [Float] = try render({ BritishBluesbreakerAmpPedal() }) {
|
||||
$0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 0.0
|
||||
}
|
||||
let noTremolo: [Float] = try render({ BritishBluesbreakerAmpPedal() }) { $0.intensity = 0.0 }
|
||||
#expect(windowedSSD(bypassed, noTremolo) == 0.0, "tremolo footswitch off should be identity")
|
||||
}
|
||||
|
||||
@Test func stayWithinCeilingAtMaxGain() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
for v: (name: String, make: () -> BritishComboAmpPedal) in voices {
|
||||
let hot: [Float] = try render(v.make) { (pedal: BritishComboAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.presence = 1.0
|
||||
pedal.bright = 1.0
|
||||
}
|
||||
let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) }
|
||||
#expect(peak <= 1.0 + ceilingEpsilon, "\(v.name) peak \(peak) exceeds the ±1 ceiling")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func roundTripsThroughState() throws {
|
||||
let pedal: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||
pedal.presence = 0.7
|
||||
pedal.bright = 1.0
|
||||
pedal.intensity = 0.5
|
||||
pedal.tremoloEnabled = 0.0
|
||||
pedal.cab = 2.0
|
||||
let restored: BritishBluesbreakerAmpPedal = BritishBluesbreakerAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.presence == 0.7 && restored.bright == 1.0)
|
||||
#expect(restored.intensity == 0.5 && restored.tremoloEnabled == 0.0 && restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "British Plexi") is BritishPlexiAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "British JTM") is BritishJTMAmpPedal)
|
||||
#expect(PedalRegistry.makePedal(type: "British Bluesbreaker") is BritishBluesbreakerAmpPedal)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user