feat(amps): Chime Top Boost — full Vox-style control surface
Full-surface counterpart to the basic Chime voice, modeling the AC-style top-boost combo. Reuses the AmpVoicePedal hooks: - inputShaping: Brilliant switch (pre-preamp treble shelf, identity when off). - onboardEffects: tremolo (Speed/Intensity), gated by a Tremolo footswitch. No onboard reverb (always outboard on these amps). - shapeVoice: the Cut control (post-power-amp low-pass swept 9k→2.5k). ChimeTopBoostAmpPedal (.vox): Gain/Bass/Mid/Treble + Cut/Speed/Intensity knobs, Brilliant + Tremolo switches, Cab selector (defaults to Bright 1×12); widthUnits 3. Registered across registry/type/category/palette/enclosure; Help acknowledgment lists its tone stack. 10 tests (Cut, tremolo intensity/speed, brilliant, tremolo footswitch bit-exact bypass, ceiling with FX, control surface, round-trip, registry). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
// ChimeTopBoostAmpPedalTests.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("ChimeTopBoostAmpPedal")
|
||||
struct ChimeTopBoostAmpPedalTests {
|
||||
|
||||
private let sampleRate: Double = 48000.0
|
||||
|
||||
private func render(configure: (ChimeTopBoostAmpPedal) -> 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: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal(
|
||||
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), "Chime Top Boost produced silence")
|
||||
#expect(samples.allSatisfy { $0.isFinite }, "Chime Top Boost produced non-finite output")
|
||||
}
|
||||
|
||||
@Test func cutChangesOutput() throws {
|
||||
let open: [Float] = try render { $0.cut = 0.0 }
|
||||
let dark: [Float] = try render { $0.cut = 1.0 }
|
||||
#expect(windowedSSD(open, dark) > 0, "Cut 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 brilliantSwitchChangesOutput() throws {
|
||||
let flat: [Float] = try render { $0.brilliant = 0.0 }
|
||||
let bright: [Float] = try render { $0.brilliant = 1.0 }
|
||||
#expect(windowedSSD(flat, bright) > 0, "brilliant switch had no effect")
|
||||
}
|
||||
|
||||
@Test func tremoloFootswitchBypassesToIdentity() throws {
|
||||
// Footswitch off with Intensity up must equal no tremolo (Intensity 0), and differ from on.
|
||||
// The differing `speed` is harmless: with depth gated to 0 the LFO is a constant 1.0.
|
||||
let bypassed: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 0.0 }
|
||||
let noTremolo: [Float] = try render { $0.intensity = 0.0 }
|
||||
#expect(windowedSSD(bypassed, noTremolo) == 0.0, "tremolo footswitch off should be identity")
|
||||
let engaged: [Float] = try render { $0.intensity = 1.0; $0.speed = 6.0; $0.tremoloEnabled = 1.0 }
|
||||
#expect(windowedSSD(bypassed, engaged) > 0, "tremolo footswitch had no effect")
|
||||
}
|
||||
|
||||
@Test func outputStaysWithinCeilingWithFXEngaged() throws {
|
||||
let ceilingEpsilon: Double = 1.0e-4
|
||||
let hot: [Float] = try render { (pedal: ChimeTopBoostAmpPedal) in
|
||||
pedal.gain = 30.0
|
||||
pedal.bass = 1.0
|
||||
pedal.treble = 1.0
|
||||
pedal.brilliant = 1.0
|
||||
pedal.intensity = 1.0
|
||||
pedal.speed = 6.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: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label }
|
||||
== ["Gain", "Bass", "Mid", "Treble", "Cut", "Speed", "Intensity"])
|
||||
#expect(pedal.effectSwitches.map { $0.label } == ["Brilliant", "Tremolo"])
|
||||
#expect(pedal.effectSelectors.map { $0.label } == ["Cab"])
|
||||
#expect(pedal.effectSelectors.first?.rebuildsOnChange == true)
|
||||
#expect(pedal.widthUnits == 3)
|
||||
#expect(pedal.showsMixControl == false)
|
||||
#expect(pedal.toneStackModel == .vox)
|
||||
}
|
||||
|
||||
@Test func controlsRoundTripThroughState() throws {
|
||||
let pedal: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal()
|
||||
pedal.gain = 7.0
|
||||
pedal.cut = 0.6
|
||||
pedal.speed = 9.0
|
||||
pedal.intensity = 0.5
|
||||
pedal.brilliant = 1.0
|
||||
pedal.tremoloEnabled = 0.0
|
||||
pedal.cab = 2.0
|
||||
let restored: ChimeTopBoostAmpPedal = ChimeTopBoostAmpPedal()
|
||||
restored.applyState(pedal.captureState())
|
||||
#expect(restored.gain == 7.0)
|
||||
#expect(restored.cut == 0.6)
|
||||
#expect(restored.speed == 9.0)
|
||||
#expect(restored.intensity == 0.5)
|
||||
#expect(restored.brilliant == 1.0)
|
||||
#expect(restored.tremoloEnabled == 0.0)
|
||||
#expect(restored.cab == 2.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "Chime Top Boost") is ChimeTopBoostAmpPedal)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user