34 lines
971 B
Swift
34 lines
971 B
Swift
// DSLTestSupport.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import LyrebirdSynth
|
|
import LyrebirdGraphDSL
|
|
|
|
/// Shared offline engine for DSL round-trip tests.
|
|
@MainActor
|
|
func makeDSLTestEngine() -> SynthesisEngine {
|
|
SynthesisEngine(
|
|
blockSize: 16,
|
|
controlBlockSize: 16,
|
|
sampleRate: 48_000,
|
|
numOutputChannels: 2,
|
|
numInputChannels: 0,
|
|
numAudioBuses: 16,
|
|
numControlBuses: 16,
|
|
eventQueueCapacity: lyrebirdDefaultEventQueueCapacity,
|
|
driver: OfflineDriver()
|
|
)
|
|
}
|
|
|
|
/// `true` when any sample in bus `bus` of `engine` is non-zero.
|
|
@MainActor
|
|
func busHasSignal(_ engine: SynthesisEngine, bus: Int) -> Bool {
|
|
(0..<engine.blockSize).contains { engine.audioBuses[bus][$0] != 0.0 }
|
|
}
|
|
|
|
/// Wrap a signal value as a `DSLValue` for direct `DSLBuiltin.make` calls.
|
|
func sig(_ value: any ValidGeneratorInput) -> DSLValue { .signal(value) }
|