1.0 release
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// PedalBoardTests.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("PedalBoard")
|
||||
struct PedalBoardTests {
|
||||
|
||||
@Test func twoPedalBoardRendersNonSilent() throws {
|
||||
// Verify that a two-pedal chain produces non-silent output and that the second
|
||||
// pedal receives the first pedal's output (the chain is wired correctly).
|
||||
let renderDuration: Double = 0.2
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: renderDuration,
|
||||
numAudioBuses: 64
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
let board: PedalBoard = try PedalBoard(engine: engine)
|
||||
|
||||
// Add the test loop source writing to the board head bus.
|
||||
let source: TestLoopSource = TestLoopSource(targetBus: board.headBus.index)
|
||||
try engine.add(source)
|
||||
|
||||
// Add two pedals to the chain.
|
||||
// Pass `after: source` for the first pedal so it evaluates after the source in the
|
||||
// node tree (source writes headBus → overdrive reads it → reverb reads overdrive out).
|
||||
let overdrive: OverdrivePedal = OverdrivePedal()
|
||||
let reverb: ReverbPedal = ReverbPedal()
|
||||
try board.add(overdrive, after: source)
|
||||
try board.add(reverb)
|
||||
|
||||
// Verify that the board tracks both pedals.
|
||||
#expect(board.pedals.count == 2)
|
||||
|
||||
// A master to route the board output to hardware output.
|
||||
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: board.outputBus.index)
|
||||
try engine.add(master, position: NodePosition.after(reverb))
|
||||
|
||||
try engine.start()
|
||||
|
||||
let samples: [Float] = readStereoCAF(url: url)
|
||||
#expect(!samples.isEmpty, "Two-pedal board produced no samples")
|
||||
#expect(hasNonSilentOutput(samples), "Two-pedal board produced silence")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user