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>
84 lines
3.1 KiB
Swift
84 lines
3.1 KiB
Swift
// PlateReverbPedalTests.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("PlateReverbPedal")
|
|
struct PlateReverbPedalTests {
|
|
|
|
private func render(configure: (PlateReverbPedal) -> 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: PlateReverbPedal = PlateReverbPedal(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), "plate reverb output was silent")
|
|
}
|
|
|
|
@Test func toneChangesOutput() throws {
|
|
// `tone` (input bandwidth) alters the signal immediately, unlike `decay` whose effect lives
|
|
// in the recirculating tail beyond this short render window.
|
|
let dark: [Float] = try render { pedal in pedal.tone = 0.1; pedal.mix = 1.0 }
|
|
let bright: [Float] = try render { pedal in pedal.tone = 1.0; pedal.mix = 1.0 }
|
|
#expect(hasNonSilentOutput(bright), "bright plate was silent")
|
|
#expect(totalSSD(dark, bright) > 0, "changing tone did not change the output")
|
|
}
|
|
|
|
@Test func exposesDecayToneDampModKnobs() throws {
|
|
let pedal: PlateReverbPedal = PlateReverbPedal()
|
|
#expect(pedal.effectKnobs.map { $0.label } == ["Decay", "Tone", "Damp", "Mod"])
|
|
}
|
|
|
|
@Test func presetRoundTripPreservesKnobs() throws {
|
|
let pedal: PlateReverbPedal = PlateReverbPedal()
|
|
pedal.decay = 0.5
|
|
pedal.mod = 0.25
|
|
let state: PedalState = pedal.captureState()
|
|
|
|
let restored: PlateReverbPedal = PlateReverbPedal()
|
|
restored.applyState(state)
|
|
#expect(restored.decay == 0.5)
|
|
#expect(restored.mod == 0.25)
|
|
}
|
|
|
|
@Test func registeredInBuiltInRegistry() throws {
|
|
#expect(PedalRegistry.makePedal(type: "Plate Reverb") is PlateReverbPedal)
|
|
}
|
|
}
|