c9795f7305
- AmpVoicePedal class doc lists Fullerton Reverb as a subclass. - Ceiling test exercises the tremolo path (intensity/speed set). - amp-modeling-2.0-plan S2 notes the Fullerton Reverb full-surface block. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
132 lines
5.3 KiB
Swift
132 lines
5.3 KiB
Swift
// 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
|
|
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: 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)
|
|
}
|
|
}
|