40 lines
1.4 KiB
Swift
40 lines
1.4 KiB
Swift
// TestLoopSourceTests.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("TestLoopSource")
|
|
struct TestLoopSourceTests {
|
|
|
|
@Test func buildsAndProducesNonSilentOutput() throws {
|
|
let renderDuration: Double = 0.1
|
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: renderDuration)
|
|
defer { try? FileManager.default.removeItem(at: url) }
|
|
|
|
// Allocate a scratch bus for the source to write to, then read back via Pan2→output.
|
|
let scratchBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
|
defer { engine.busAllocator.releaseAudioBus(scratchBus) }
|
|
|
|
let source: TestLoopSource = TestLoopSource(targetBus: scratchBus.index)
|
|
try engine.add(source)
|
|
|
|
// A simple master synth to route the scratch bus to hardware output.
|
|
let master: TestRouteMaster = TestRouteMaster(inputBusIndex: scratchBus.index)
|
|
try engine.add(master, position: NodePosition.after(source))
|
|
|
|
try engine.start()
|
|
|
|
let samples: [Float] = readStereoCAF(url: url)
|
|
#expect(!samples.isEmpty, "NRT render produced no samples")
|
|
#expect(hasNonSilentOutput(samples), "TestLoopSource produced silence")
|
|
}
|
|
}
|