9cb8788cc0
Wrap three Lyrebird 1.2.0 reverb algorithms as pedals, mirroring ReverbPedal (run the generator pure-wet, let the base Pedal mix blend): - Plate Reverb — PlateReverb.Audio (Dattorro plate), stereo folded to mono. Knobs: Decay, Tone, Damp, Mod. - Room Reverb — GVerb.Audio (FDN room/hall), stereo folded to mono. Knobs: Size (m), Decay (T60 s), Damp, Tail. - Spring Reverb — SpringReverb.Audio in mono (stereo:false, no fold). Knobs: Decay, Tension, Damp. Each registered across the six touchpoints (type, registry, category .reverb, palette order, enclosure colour) with a test suite (build+render, param changes output, knob labels, preset round-trip, registry membership). 339 tests pass; both app targets build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
82 lines
2.9 KiB
Swift
82 lines
2.9 KiB
Swift
// SpringReverbPedalTests.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("SpringReverbPedal")
|
|
struct SpringReverbPedalTests {
|
|
|
|
private func render(configure: (SpringReverbPedal) -> Void) throws -> [Float] {
|
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.2, 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: SpringReverbPedal = SpringReverbPedal(inputBus: srcBus.index, outputBus: dstBus.index)
|
|
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)
|
|
}
|
|
|
|
private func totalSSD(_ a: [Float], _ b: [Float]) -> Double {
|
|
zip(a, b).reduce(0.0) { acc, pair in
|
|
let diff: Double = Double(pair.0 - pair.1)
|
|
return acc + diff * diff
|
|
}
|
|
}
|
|
|
|
@Test func buildsAndProducesNonSilentOutput() throws {
|
|
let samples: [Float] = try render { _ in }
|
|
#expect(!samples.isEmpty)
|
|
#expect(hasNonSilentOutput(samples), "spring reverb output was silent")
|
|
}
|
|
|
|
@Test func tensionChangesOutput() throws {
|
|
let low: [Float] = try render { pedal in pedal.tension = 0.1; pedal.mix = 1.0 }
|
|
let high: [Float] = try render { pedal in pedal.tension = 0.9; pedal.mix = 1.0 }
|
|
#expect(hasNonSilentOutput(high), "high-tension spring was silent")
|
|
#expect(totalSSD(low, high) > 0, "changing tension did not change the output")
|
|
}
|
|
|
|
@Test func exposesDecayTensionDampKnobs() throws {
|
|
let pedal: SpringReverbPedal = SpringReverbPedal()
|
|
#expect(pedal.effectKnobs.map { $0.label } == ["Decay", "Tension", "Damp"])
|
|
}
|
|
|
|
@Test func presetRoundTripPreservesKnobs() throws {
|
|
let pedal: SpringReverbPedal = SpringReverbPedal()
|
|
pedal.decay = 3.0
|
|
pedal.tension = 0.2
|
|
let state: PedalState = pedal.captureState()
|
|
|
|
let restored: SpringReverbPedal = SpringReverbPedal()
|
|
restored.applyState(state)
|
|
#expect(restored.decay == 3.0)
|
|
#expect(restored.tension == 0.2)
|
|
}
|
|
|
|
@Test func registeredInBuiltInRegistry() throws {
|
|
#expect(PedalRegistry.makePedal(type: "Spring Reverb") is SpringReverbPedal)
|
|
}
|
|
}
|