// PortableTestSupport.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import Testing @_spi(LyrebirdExtensions) import LyrebirdSynth // Local copies of the engine/collect helpers used by `LyrebirdTests`. SwiftPM // test targets cannot share sources, and this target is deliberately limited to // the public (+ extension-SPI) surface — part of what is being proven is that // the portable surface is reachable and correct off Apple. /// Offline engine for deterministic block-by-block generator evaluation. func makePortableTestEngine( blockSize: Int = 64, sampleRate: Double = 44100 ) -> SynthesisEngine { SynthesisEngine( blockSize: blockSize, sampleRate: sampleRate, numOutputChannels: 2, numInputChannels: 2, driver: OfflineDriver() ) } /// Drive a generator for `blocks` blocks and return `blockSize` samples per block. func collectPortableBlocks( _ gen: any Generator, engine: SynthesisEngine, blocks: Int, channel: Int = 0 ) -> [Double] { let bs: Int = engine.blockSize var out: [Double] = [] out.reserveCapacity(blocks * bs) for _ in 0..= golden.count, "\(label): produced \(actual.count) samples, golden has \(golden.count)", sourceLocation: sourceLocation) guard actual.count >= golden.count else { return } for i: Int in 0..