Add Plate, Room, and Spring reverb pedals
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>
This commit is contained in:
@@ -85,6 +85,9 @@ public extension PedalType {
|
||||
static let reverseDelay = PedalType("Reverse Delay")
|
||||
static let reverb = PedalType("Reverb")
|
||||
static let shimmerReverb = PedalType("Shimmer Reverb")
|
||||
static let plateReverb = PedalType("Plate Reverb")
|
||||
static let roomReverb = PedalType("Room Reverb")
|
||||
static let springReverb = PedalType("Spring Reverb")
|
||||
|
||||
// Pitch & octave
|
||||
static let octaveSplitter = PedalType("Octave Splitter")
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
// PlateReverbPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Plate reverb pedal: a Dattorro figure-of-eight plate, folded to mono.
|
||||
///
|
||||
/// Signal chain (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → PlateReverb.Audio(mix: 1.0, decay:, bandwidth:, damping:, modDepth:) → stereo (2 ch)
|
||||
/// → SumChannels.Audio(mul: 0.5) → mono (fold)
|
||||
/// ```
|
||||
///
|
||||
/// `PlateReverb` runs at `mix: 1.0` (pure wet); the base `Pedal` handles the wet/dry blend via its
|
||||
/// own `mix` parameter. The native-stereo plate output is summed to mono with a ×0.5 gain to
|
||||
/// compensate for the channel doubling.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - decay: Tail length (tank feedback) in [0, 0.9]. Higher = longer tail. Defaults to `0.7`.
|
||||
/// - tone: Input brightness (bandwidth) in [0, 1]. `1` = fully bright. Defaults to `0.9`.
|
||||
/// - damp: High-frequency damping in the tail in [0, 1]. Higher = darker. Defaults to `0.2`.
|
||||
/// - mod: Tank modulation depth in [0, 1] — subtle movement/chorusing. Defaults to `0.5`.
|
||||
public final class PlateReverbPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Warm, dense plate reverb with gentle modulation — a lush, classic studio ambience."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Tail length (tank feedback) in [0, 0.9]. Higher = longer tail.
|
||||
@UIParam public var decay: Double = 0.7
|
||||
|
||||
/// Input brightness (bandwidth) in [0, 1]. `1` = fully bright.
|
||||
@UIParam public var tone: Double = 0.9
|
||||
|
||||
/// High-frequency damping in the tail, in [0, 1]. Higher = darker.
|
||||
@UIParam public var damp: Double = 0.2
|
||||
|
||||
/// Tank modulation depth in [0, 1] — subtle movement.
|
||||
@UIParam public var mod: Double = 0.5
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Plate mix value. `1.0` = pure wet; the base `Pedal` handles dry/wet blending.
|
||||
private let plateWetMix: Double = 1.0
|
||||
|
||||
/// Gain applied to the summed stereo→mono fold, compensating for channel doubling.
|
||||
private let stereoSumGain: Double = 0.5
|
||||
|
||||
/// Default wet/dry blend — a partial mix so the dry signal stays up front.
|
||||
private static let defaultMix: Double = 0.3
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let decayRange: ClosedRange<Double> = 0.0 ... 0.9
|
||||
private let normalizedRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Decay", node: $decay, range: decayRange),
|
||||
PedalKnob(label: "Tone", node: $tone, range: normalizedRange),
|
||||
PedalKnob(label: "Damp", node: $damp, range: normalizedRange),
|
||||
PedalKnob(label: "Mod", node: $mod, range: normalizedRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a plate reverb pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Plate Reverb",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: PlateReverbPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// PlateReverb produces a 2-channel stereo output.
|
||||
let stereoPlate: PlateReverb.Audio = PlateReverb.Audio(
|
||||
input: dry,
|
||||
decay: $decay,
|
||||
bandwidth: $tone,
|
||||
damping: $damp,
|
||||
modDepth: $mod,
|
||||
mix: plateWetMix,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
// Sum stereo → mono with ×0.5 to avoid level doubling.
|
||||
return SumChannels.Audio(
|
||||
input: stereoPlate,
|
||||
mul: stereoSumGain
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
// RoomReverbPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Room reverb pedal: the GVerb FDN room/hall algorithm, folded to mono.
|
||||
///
|
||||
/// Signal chain (inside `effect(_:)`):
|
||||
/// ```
|
||||
/// dry → GVerb.Audio(dryLevel: 0, roomSize:, reverbTime:, damping:, tailLevel:) → stereo (2 ch)
|
||||
/// → SumChannels.Audio(mul: 0.5) → mono (fold)
|
||||
/// ```
|
||||
///
|
||||
/// `GVerb` runs with `dryLevel: 0` (pure wet); the base `Pedal` handles the wet/dry blend via its
|
||||
/// own `mix` parameter. The native-stereo output is summed to mono with a ×0.5 gain.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - size: Room size in metres, in [1, 100]. Larger = bigger space. Defaults to `30`.
|
||||
/// - decay: Reverb time (T60) in seconds, in [0.2, 12]. Defaults to `3`.
|
||||
/// - damp: High-frequency damping in [0, 1]. Higher = darker tail. Defaults to `0.5`.
|
||||
/// - tail: Late-reverb level in [0, 1] — how present the room tail sits. Defaults to `0.6`.
|
||||
public final class RoomReverbPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Parametric room and hall reverb — dial the space in metres and its decay time."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Room size in metres, in [1, 100]. Larger = bigger space.
|
||||
@UIParam public var size: Double = 30.0
|
||||
|
||||
/// Reverb time (T60) in seconds, in [0.2, 12].
|
||||
@UIParam public var decay: Double = 3.0
|
||||
|
||||
/// High-frequency damping in [0, 1]. Higher = darker tail.
|
||||
@UIParam public var damp: Double = 0.5
|
||||
|
||||
/// Late-reverb level in [0, 1] — how present the room tail sits.
|
||||
@UIParam public var tail: Double = 0.6
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// GVerb dry level. `0` = pure wet; the base `Pedal` handles dry/wet blending.
|
||||
private let gverbDryLevel: Double = 0.0
|
||||
|
||||
/// Gain applied to the summed stereo→mono fold, compensating for channel doubling.
|
||||
private let stereoSumGain: Double = 0.5
|
||||
|
||||
/// Default wet/dry blend — a partial mix so the dry signal stays up front.
|
||||
private static let defaultMix: Double = 0.3
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let sizeRange: ClosedRange<Double> = 1.0 ... 100.0
|
||||
private let decayRange: ClosedRange<Double> = 0.2 ... 12.0
|
||||
private let normalizedRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Size", node: $size, range: sizeRange),
|
||||
PedalKnob(label: "Decay", node: $decay, range: decayRange),
|
||||
PedalKnob(label: "Damp", node: $damp, range: normalizedRange),
|
||||
PedalKnob(label: "Tail", node: $tail, range: normalizedRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a room reverb pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Room Reverb",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: RoomReverbPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// GVerb produces a 2-channel stereo output.
|
||||
let stereoRoom: GVerb.Audio = GVerb.Audio(
|
||||
source: dry,
|
||||
roomSize: $size,
|
||||
reverbTime: $decay,
|
||||
damping: $damp,
|
||||
tailLevel: $tail,
|
||||
dryLevel: gverbDryLevel,
|
||||
sampleRate: sampleRate
|
||||
)
|
||||
// Sum stereo → mono with ×0.5 to avoid level doubling.
|
||||
return SumChannels.Audio(
|
||||
input: stereoRoom,
|
||||
mul: stereoSumGain
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
// SpringReverbPedal.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
|
||||
/// Spring reverb pedal: a Schroeder spring-tank, the classic surf/amp reverb voice.
|
||||
///
|
||||
/// Runs `SpringReverb` in mono (`stereo: false`) so no channel fold is needed. The generator is
|
||||
/// driven at `mix: 1.0` (pure wet); the base `Pedal` handles the wet/dry blend via its own `mix`.
|
||||
///
|
||||
/// ## Parameters
|
||||
///
|
||||
/// Inherits `mix`, `bypass`, and `level` from `Pedal`, plus:
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - decay: Tail length (RT60) in seconds, in [0.1, 5]. Defaults to `2`.
|
||||
/// - tension: Spring dispersion/chirp in [0, 1] — the boingy spring character. Defaults to `0.5`.
|
||||
/// - damp: High-frequency damping in [0, 1]. Higher = darker. Defaults to `0.3`.
|
||||
public final class SpringReverbPedal: Pedal {
|
||||
|
||||
/// One-line description shown in the picker and info panel.
|
||||
public override var summary: String {
|
||||
"Vintage spring-tank reverb — drippy, boingy surf and amp-style ambience."
|
||||
}
|
||||
|
||||
// MARK: - Parameters
|
||||
|
||||
/// Tail length (RT60) in seconds, in [0.1, 5].
|
||||
@UIParam public var decay: Double = 2.0
|
||||
|
||||
/// Spring dispersion/chirp in [0, 1] — the boingy spring character.
|
||||
@UIParam public var tension: Double = 0.5
|
||||
|
||||
/// High-frequency damping in [0, 1]. Higher = darker.
|
||||
@UIParam public var damp: Double = 0.3
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Spring mix value. `1.0` = pure wet; the base `Pedal` handles dry/wet blending.
|
||||
private let springWetMix: Double = 1.0
|
||||
|
||||
/// Default wet/dry blend — a partial mix so the dry signal stays up front.
|
||||
private static let defaultMix: Double = 0.3
|
||||
|
||||
// MARK: - Ranges
|
||||
|
||||
private let decayRange: ClosedRange<Double> = 0.1 ... 5.0
|
||||
private let normalizedRange: ClosedRange<Double> = 0.0 ... 1.0
|
||||
|
||||
// MARK: - UI knobs
|
||||
|
||||
public override var effectKnobs: [PedalKnob] {
|
||||
[
|
||||
PedalKnob(label: "Decay", node: $decay, range: decayRange),
|
||||
PedalKnob(label: "Tension", node: $tension, range: normalizedRange),
|
||||
PedalKnob(label: "Damp", node: $damp, range: normalizedRange),
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a spring reverb pedal.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||||
public init(
|
||||
inputBus: Int = 0,
|
||||
outputBus: Int = 0
|
||||
) {
|
||||
super.init(
|
||||
name: "Spring Reverb",
|
||||
inputBus: inputBus,
|
||||
outputBus: outputBus,
|
||||
initialMix: SpringReverbPedal.defaultMix
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Effect
|
||||
|
||||
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||||
// Mono spring tank — no channel fold needed.
|
||||
SpringReverb.Audio(
|
||||
input: dry,
|
||||
decay: $decay,
|
||||
tension: $tension,
|
||||
damping: $damp,
|
||||
mix: springWetMix,
|
||||
sampleRate: sampleRate,
|
||||
stereo: false
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,9 @@ public enum PedalRegistry {
|
||||
"Ping-Pong": { PingPongDelayPedal() },
|
||||
"Reverse Delay": { ReverseDelayPedal() },
|
||||
"Shimmer Reverb": { ShimmerReverbPedal() },
|
||||
"Plate Reverb": { PlateReverbPedal() },
|
||||
"Room Reverb": { RoomReverbPedal() },
|
||||
"Spring Reverb": { SpringReverbPedal() },
|
||||
"Limiter": { LimiterPedal() },
|
||||
"Noise Gate": { NoiseGatePedal() },
|
||||
"Graphic EQ": { GraphicEQPedal() },
|
||||
|
||||
@@ -51,6 +51,7 @@ enum PedalCategory: String, CaseIterable, Identifiable {
|
||||
"Delay": .delay, "Feedback Delay": .delay, "Multi-Tap Delay": .delay, "Ping-Pong": .delay,
|
||||
"Reverse Delay": .delay,
|
||||
"Reverb": .reverb, "Shimmer Reverb": .reverb,
|
||||
"Plate Reverb": .reverb, "Room Reverb": .reverb, "Spring Reverb": .reverb,
|
||||
"Diffuser": .texture, "Bitcrusher": .texture, "Granulator": .texture, "Auto Granulator": .texture,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public struct PedalPaletteView: View {
|
||||
"Auto-Wah", "Wah", "Mutant", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator",
|
||||
"Auto Granulator", "Bass Octaver", "Octave Splitter", "Harmonizer",
|
||||
"Delay", "Feedback Delay", "Multi-Tap Delay", "Ping-Pong", "Reverse Delay", "Reverb",
|
||||
"Shimmer Reverb",
|
||||
"Shimmer Reverb", "Plate Reverb", "Room Reverb", "Spring Reverb",
|
||||
]
|
||||
|
||||
/// Routing/branching topologies the user can insert into the board.
|
||||
|
||||
@@ -21,6 +21,9 @@ private func enclosureColor(for displayName: String) -> Color {
|
||||
case "Delay": return Color(red: 0.10, green: 0.55, blue: 0.55) // teal
|
||||
case "Reverb": return Color(red: 0.30, green: 0.18, blue: 0.65) // indigo
|
||||
case "Shimmer Reverb": return Color(red: 0.46, green: 0.52, blue: 0.78) // icy periwinkle
|
||||
case "Plate Reverb": return Color(red: 0.26, green: 0.30, blue: 0.60) // deep slate blue
|
||||
case "Room Reverb": return Color(red: 0.24, green: 0.40, blue: 0.66) // ocean blue
|
||||
case "Spring Reverb": return Color(red: 0.20, green: 0.46, blue: 0.64) // steel cyan
|
||||
case "Modulation": return Color(red: 0.12, green: 0.58, blue: 0.22) // green
|
||||
case "Fuzz": return Color(red: 0.55, green: 0.10, blue: 0.10) // deep crimson
|
||||
case "Tremolo": return Color(red: 0.20, green: 0.38, blue: 0.72) // cobalt blue
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// RoomReverbPedalTests.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("RoomReverbPedal")
|
||||
struct RoomReverbPedalTests {
|
||||
|
||||
private func render(configure: (RoomReverbPedal) -> 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: RoomReverbPedal = RoomReverbPedal(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), "room reverb output was silent")
|
||||
}
|
||||
|
||||
@Test func sizeChangesOutput() throws {
|
||||
let small: [Float] = try render { pedal in pedal.size = 5.0; pedal.mix = 1.0 }
|
||||
let large: [Float] = try render { pedal in pedal.size = 90.0; pedal.mix = 1.0 }
|
||||
#expect(hasNonSilentOutput(large), "large-room reverb was silent")
|
||||
#expect(totalSSD(small, large) > 0, "changing size did not change the output")
|
||||
}
|
||||
|
||||
@Test func exposesSizeDecayDampTailKnobs() throws {
|
||||
let pedal: RoomReverbPedal = RoomReverbPedal()
|
||||
#expect(pedal.effectKnobs.map { $0.label } == ["Size", "Decay", "Damp", "Tail"])
|
||||
}
|
||||
|
||||
@Test func presetRoundTripPreservesKnobs() throws {
|
||||
let pedal: RoomReverbPedal = RoomReverbPedal()
|
||||
pedal.size = 50.0
|
||||
pedal.decay = 6.0
|
||||
let state: PedalState = pedal.captureState()
|
||||
|
||||
let restored: RoomReverbPedal = RoomReverbPedal()
|
||||
restored.applyState(state)
|
||||
#expect(restored.size == 50.0)
|
||||
#expect(restored.decay == 6.0)
|
||||
}
|
||||
|
||||
@Test func registeredInBuiltInRegistry() throws {
|
||||
#expect(PedalRegistry.makePedal(type: "Room Reverb") is RoomReverbPedal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user