fixes for Swift 6 and threading concerns
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AUInput.Audio") struct AUInputAudioTests {
|
||||
|
||||
@Test func channelMustBeNonNegative() {
|
||||
|
||||
@@ -88,9 +88,11 @@ private struct ABLFixture {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("AUv3Driver") struct AUv3DriverTests {
|
||||
|
||||
@Test func returnsUninitializedBeforeSetup() {
|
||||
defer { lyrebirdClearRTMarkAfterTestRender() }
|
||||
let driver: AUv3Driver = AUv3Driver()
|
||||
let fixture: ABLFixture = ABLFixture(channels: 2, frames: 64)
|
||||
defer { fixture.deallocate() }
|
||||
@@ -99,6 +101,7 @@ private struct ABLFixture {
|
||||
}
|
||||
|
||||
@Test func rejectsFrameCountAboveMax() throws {
|
||||
defer { lyrebirdClearRTMarkAfterTestRender() }
|
||||
let driver: AUv3Driver = AUv3Driver(maxFramesToRender: 256)
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: 128, sampleRate: 44100,
|
||||
@@ -114,6 +117,7 @@ private struct ABLFixture {
|
||||
}
|
||||
|
||||
@Test func smallHostFrameCountDrivesMultipleEngineBlocks() throws {
|
||||
defer { lyrebirdClearRTMarkAfterTestRender() }
|
||||
// Engine block 128; host requests 64 per call — two calls per engine block.
|
||||
let driver: AUv3Driver = AUv3Driver(maxFramesToRender: 64)
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
@@ -156,6 +160,7 @@ private struct ABLFixture {
|
||||
}
|
||||
|
||||
@Test func largeHostFrameCountPullsMultipleEngineBlocks() throws {
|
||||
defer { lyrebirdClearRTMarkAfterTestRender() }
|
||||
// Host wants 1024 per call but engine block is 256 — 4 engine blocks per
|
||||
// render call.
|
||||
let driver: AUv3Driver = AUv3Driver(maxFramesToRender: 1024)
|
||||
@@ -182,6 +187,7 @@ private struct ABLFixture {
|
||||
}
|
||||
|
||||
@Test func alternatingFrameCountsPreserveContinuity() throws {
|
||||
defer { lyrebirdClearRTMarkAfterTestRender() }
|
||||
// Hosts may switch frame counts mid-stream; the ring must keep sample
|
||||
// continuity intact.
|
||||
let driver: AUv3Driver = AUv3Driver(maxFramesToRender: 1024)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AUv3RingBuffer") struct AUv3RingBufferTests {
|
||||
|
||||
@Test func capacityRoundsUpToPowerOfTwo() {
|
||||
|
||||
@@ -32,6 +32,7 @@ private final class InheritedParamSynth: ParamSynth {
|
||||
|
||||
// MARK: - Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAUParameterMapping discovery") struct LyrebirdAUParameterDiscoveryTests {
|
||||
|
||||
@Test func discoversAllLiveParamsInDeclarationOrder() {
|
||||
@@ -70,6 +71,7 @@ private final class InheritedParamSynth: ParamSynth {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAUParameterMapping tree") struct LyrebirdAUParameterTreeTests {
|
||||
|
||||
@Test func buildsOneAUParameterPerSlot() {
|
||||
|
||||
@@ -43,6 +43,7 @@ private final class FixturePresetGen: GeneratorBase, AudioGenerator, LyrebirdAUP
|
||||
func floatValue(graph: SynthGraph) -> Double { _amp }
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAUPresetSourceRegistry") struct LyrebirdAUPresetRegistryTests {
|
||||
|
||||
@Test func registerAndMakeRoundTrip() {
|
||||
|
||||
@@ -15,6 +15,7 @@ private final class TestVoice: SynthesizerBase {
|
||||
override func build() { output(bus: 0, source: $freq * $amp * $gate) }
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAUVoicePoolBinding") struct LyrebirdAUVoicePoolBindingTests {
|
||||
|
||||
@Test func noteOnAllocatesVoiceAndConfigures() throws {
|
||||
|
||||
@@ -21,7 +21,7 @@ private final class PassthroughSynth: SynthesizerBase {
|
||||
|
||||
private final class PassthroughEffectAU: LyrebirdAudioUnit {
|
||||
public override class func makeSynthesizer() -> SynthesizerBase {
|
||||
PassthroughSynth()
|
||||
MainActor.assumeIsolated { PassthroughSynth() }
|
||||
}
|
||||
public override class var lyrebirdInputChannels: Int { 2 }
|
||||
public override class var lyrebirdOutputChannels: Int { 2 }
|
||||
@@ -37,6 +37,7 @@ private func makeEffectDescription() -> AudioComponentDescription {
|
||||
)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAudioUnit effect") struct LyrebirdAudioUnitEffectTests {
|
||||
|
||||
@Test func effectAUDeclaresInputAndOutputBuses() throws {
|
||||
@@ -62,7 +63,7 @@ private func makeEffectDescription() -> AudioComponentDescription {
|
||||
override func build() { output(bus: 0, source: 0.0) }
|
||||
}
|
||||
final class StubInstrumentAU: LyrebirdAudioUnit {
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { StubSynth() }
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { MainActor.assumeIsolated { StubSynth() } }
|
||||
}
|
||||
let desc: AudioComponentDescription = AudioComponentDescription(
|
||||
componentType: kAudioUnitType_MusicDevice,
|
||||
|
||||
@@ -10,6 +10,7 @@ import AudioToolbox
|
||||
import AVFoundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAudioUnit MIDI dispatch") struct LyrebirdAudioUnitMIDITests {
|
||||
|
||||
@Test func dispatchHandlesNilHeadGracefully() {
|
||||
|
||||
@@ -26,7 +26,7 @@ private final class StemRenderSynth: SynthesizerBase {
|
||||
}
|
||||
|
||||
private final class StemRenderAU: LyrebirdAudioUnit {
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { StemRenderSynth() }
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { MainActor.assumeIsolated { StemRenderSynth() } }
|
||||
public override class var lyrebirdOutputBusses: [LyrebirdAUBusSpec] {
|
||||
[
|
||||
.init(name: "Main", channelCount: 2),
|
||||
@@ -48,7 +48,7 @@ private final class SidechainPassthrough: SynthesizerBase {
|
||||
}
|
||||
|
||||
private final class SidechainAU: LyrebirdAudioUnit {
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { SidechainPassthrough() }
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { MainActor.assumeIsolated { SidechainPassthrough() } }
|
||||
public override class var lyrebirdOutputBusses: [LyrebirdAUBusSpec] {
|
||||
[.init(name: "Output", channelCount: 2)]
|
||||
}
|
||||
@@ -67,7 +67,7 @@ private final class SingleBusSynth: SynthesizerBase {
|
||||
}
|
||||
|
||||
private final class SingleBusAU: LyrebirdAudioUnit {
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { SingleBusSynth() }
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { MainActor.assumeIsolated { SingleBusSynth() } }
|
||||
// No bus-spec overrides — must keep the default single-bus behaviour.
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ private func makeAUDesc(subtype: UInt32) -> AudioComponentDescription {
|
||||
)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAudioUnit multi-bus — defaults") struct LyrebirdAudioUnitMultiBusDefaultTests {
|
||||
|
||||
@Test func singleBusAUKeeps104aShape() throws {
|
||||
@@ -97,6 +98,7 @@ private func makeAUDesc(subtype: UInt32) -> AudioComponentDescription {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAudioUnit multi-bus — multi-output") struct LyrebirdAudioUnitMultiOutputBusTests {
|
||||
|
||||
@Test func twoOutputBussesAreExposed() throws {
|
||||
@@ -120,6 +122,7 @@ private func makeAUDesc(subtype: UInt32) -> AudioComponentDescription {
|
||||
}
|
||||
|
||||
@Test func asymmetricBusPullsDoNotCrash() throws {
|
||||
defer { lyrebirdClearRTMarkAfterTestRender() }
|
||||
// AU spec lets a host pull bus 0 repeatedly without pulling bus 1.
|
||||
// Without the driver's saturation guard this would overflow bus 1's
|
||||
// ring buffer after `capacity / blockSize` engine advances.
|
||||
@@ -157,6 +160,7 @@ private func makeAUDesc(subtype: UInt32) -> AudioComponentDescription {
|
||||
}
|
||||
|
||||
@Test func renderingRoutesEachBusIndependently() throws {
|
||||
defer { lyrebirdClearRTMarkAfterTestRender() }
|
||||
let au: StemRenderAU = try StemRenderAU(componentDescription: makeAUDesc(subtype: 0x534D4F44))
|
||||
try au.allocateRenderResources()
|
||||
defer { au.deallocateRenderResources() }
|
||||
@@ -199,6 +203,7 @@ private func makeAUDesc(subtype: UInt32) -> AudioComponentDescription {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAudioUnit multi-bus — sidechain input") struct LyrebirdAudioUnitSidechainTests {
|
||||
|
||||
@Test func twoInputBussesAreExposed() throws {
|
||||
@@ -219,6 +224,7 @@ private func makeAUDesc(subtype: UInt32) -> AudioComponentDescription {
|
||||
}
|
||||
|
||||
@Test func renderLoopDispatchesPerInputBusPullBlock() throws {
|
||||
defer { lyrebirdClearRTMarkAfterTestRender() }
|
||||
// Drive the full internalRenderBlock → driver → _fillInputStagingFromHost
|
||||
// path with a synthetic pullInputBlock that fills bus 0 ABL with +1.0
|
||||
// and bus 1 ABL with -1.0. Verify the AU passes bus 0 samples through
|
||||
|
||||
@@ -17,7 +17,7 @@ private final class PresetSynth: SynthesizerBase {
|
||||
}
|
||||
|
||||
private final class PresetAU: LyrebirdAudioUnit {
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { PresetSynth() }
|
||||
public override class func makeSynthesizer() -> SynthesizerBase { MainActor.assumeIsolated { PresetSynth() } }
|
||||
public override class func factoryPresetsForLyrebird() -> [LyrebirdAUFactoryPreset] {
|
||||
[
|
||||
.init(name: "Bright", scalarValues: ["freq": 880, "amp": 0.8]),
|
||||
@@ -36,6 +36,7 @@ private func makeDesc() -> AudioComponentDescription {
|
||||
)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAudioUnit factory presets") struct LyrebirdAudioUnitFactoryPresetsTests {
|
||||
|
||||
@Test func factoryPresetsExposeAllNames() throws {
|
||||
|
||||
@@ -22,7 +22,7 @@ private final class TestFMSynth: SynthesizerBase {
|
||||
|
||||
private final class TestFMSynthAudioUnit: LyrebirdAudioUnit {
|
||||
public override class func makeSynthesizer() -> SynthesizerBase {
|
||||
TestFMSynth()
|
||||
MainActor.assumeIsolated { TestFMSynth() }
|
||||
}
|
||||
public override class func parameterMetadata() -> [String: LyrebirdAUParameterInfo] {
|
||||
[
|
||||
@@ -44,6 +44,7 @@ private func makeDescription() -> AudioComponentDescription {
|
||||
|
||||
// MARK: - Init / parameter tree
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAudioUnit init") struct LyrebirdAudioUnitInitTests {
|
||||
|
||||
@Test func initSucceedsAndPopulatesParameterTree() throws {
|
||||
@@ -94,6 +95,7 @@ private func makeDescription() -> AudioComponentDescription {
|
||||
|
||||
// MARK: - Resource lifecycle
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAudioUnit render resources") struct LyrebirdAudioUnitRenderResourceTests {
|
||||
|
||||
@Test func allocateAndDeallocateLifecycle() throws {
|
||||
@@ -127,6 +129,7 @@ private func makeDescription() -> AudioComponentDescription {
|
||||
}
|
||||
|
||||
@Test func renderProducesNonzeroOutputAfterAllocate() throws {
|
||||
defer { lyrebirdClearRTMarkAfterTestRender() }
|
||||
let au: TestFMSynthAudioUnit = try TestFMSynthAudioUnit(componentDescription: makeDescription())
|
||||
try au.allocateRenderResources()
|
||||
defer { au.deallocateRenderResources() }
|
||||
@@ -175,6 +178,7 @@ private func makeDescription() -> AudioComponentDescription {
|
||||
|
||||
// MARK: - fullState save / restore
|
||||
|
||||
@MainActor
|
||||
@Suite("LyrebirdAudioUnit fullState") struct LyrebirdAudioUnitFullStateTests {
|
||||
|
||||
@Test func fullStateRoundTripPreservesScalarLiveParams() throws {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AdditiveSynthesizer")
|
||||
struct AdditiveSynthesizerTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AmbiAFormat conversion (B↔A)")
|
||||
struct AmbiAFormatConversionTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AmbiDecoderMono")
|
||||
struct AmbiDecoderMonoTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AmbiDecoderStereo")
|
||||
struct AmbiDecoderStereoTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AmbiDecoderUHJ")
|
||||
struct AmbiDecoderUHJTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AmbiEncoder1 parameter ramping")
|
||||
struct AmbiEncoder1ParameterRampingTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AmbiEncoderStereo")
|
||||
struct AmbiEncoderStereoTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AmbiEncoderUHJ")
|
||||
struct AmbiEncoderUHJTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AmbiSpeakerLayout")
|
||||
struct AmbiSpeakerLayoutTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("AmplitudeFollower parameter ramping")
|
||||
struct AmplitudeFollowerParameterRampingTests {
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ private func collectSamples(
|
||||
|
||||
// MARK: - AudioRateInput suite
|
||||
|
||||
@MainActor
|
||||
@Suite("AudioRateInput")
|
||||
struct AudioRateInputTests {
|
||||
|
||||
@@ -233,6 +234,7 @@ struct AudioRateInputTests {
|
||||
|
||||
// MARK: - FMSynthesis suite
|
||||
|
||||
@MainActor
|
||||
@Suite("FMSynthesis")
|
||||
struct FMSynthesisTests {
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ fileprivate final class QuadConstantGen: GeneratorBase, AudioGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("BinaryOpGenerator")
|
||||
struct BinaryOpGeneratorTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 8)
|
||||
@@ -137,6 +138,7 @@ struct BinaryOpGeneratorTests {
|
||||
|
||||
// MARK: - Multi-channel broadcast
|
||||
|
||||
@MainActor
|
||||
@Suite("BinaryOpGenerator multi-channel broadcast")
|
||||
struct BinaryOpGeneratorMultiChannelTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 8)
|
||||
@@ -323,6 +325,7 @@ struct BinaryOpGeneratorMultiChannelTests {
|
||||
|
||||
// MARK: - Existential operator overloads (any ValidGeneratorInput op any ValidGeneratorInput)
|
||||
|
||||
@MainActor
|
||||
@Suite("BinaryOpGenerator existential operators")
|
||||
struct BinaryOpGeneratorExistentialTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 8)
|
||||
@@ -421,6 +424,7 @@ struct BinaryOpGeneratorExistentialTests {
|
||||
|
||||
// MARK: - ConstantGeneratorInput
|
||||
|
||||
@MainActor
|
||||
@Suite("ConstantGeneratorInput")
|
||||
struct ConstantGeneratorInputTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 8)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("BowedString")
|
||||
struct BowedStringTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("BufferRead")
|
||||
struct BufferReadTests {
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import Testing
|
||||
/// Per-generator tests verify (1) swap takes effect on the next block, (2) swap to nil
|
||||
/// silences output, (3) the previously installed buffer is released after the engine's
|
||||
/// freeQueue drains.
|
||||
@MainActor
|
||||
@Suite("BufferSlot adoption — Phase C")
|
||||
struct BufferSlotAdoptionTests {
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ private func makeMinimalLBHR(
|
||||
|
||||
// MARK: - Suite
|
||||
|
||||
@MainActor
|
||||
@Suite("HRIRFile")
|
||||
struct HRIRFileTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("BusAllocator")
|
||||
struct BusAllocatorTests {
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ private final class ControlInputRoutingSynth: SynthesizerBase {
|
||||
|
||||
// MARK: - Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("Bus Ergonomics — SynthesizerBase convenience helpers")
|
||||
struct BusErgonomicsTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 16)
|
||||
|
||||
@@ -29,6 +29,7 @@ private func rms(_ samples: [Double]) -> Double {
|
||||
|
||||
// MARK: - ButterworthFilterTests
|
||||
|
||||
@MainActor
|
||||
@Suite("ButterworthFilters")
|
||||
struct ButterworthFilterTests {
|
||||
|
||||
@@ -292,6 +293,7 @@ struct ButterworthFilterTests {
|
||||
|
||||
// MARK: - ButterworthBandPassTests
|
||||
|
||||
@MainActor
|
||||
@Suite("ButterworthBandPass")
|
||||
struct ButterworthBandPassTests {
|
||||
|
||||
@@ -438,6 +440,7 @@ struct ButterworthBandPassTests {
|
||||
|
||||
// MARK: - ButterworthBandRejectTests
|
||||
|
||||
@MainActor
|
||||
@Suite("ButterworthBandReject")
|
||||
struct ButterworthBandRejectTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("CPU Statistics")
|
||||
final class CPUStatsTests {
|
||||
|
||||
@@ -17,7 +18,7 @@ final class CPUStatsTests {
|
||||
try engine.start()
|
||||
}
|
||||
|
||||
deinit {
|
||||
isolated deinit {
|
||||
engine.stop()
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("ChannelSelect")
|
||||
struct ChannelSelectTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Chorus")
|
||||
struct ChorusTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Clarinet")
|
||||
struct ClarinetTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("CollectionRandomPick")
|
||||
struct CollectionRandomPickTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Compressor parameter ramping")
|
||||
struct CompressorParameterRampingTests {
|
||||
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
// Phase201IsolationGuardTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
import Foundation
|
||||
@testable import LyrebirdSynth
|
||||
|
||||
/// Phase 201/202 isolation guards.
|
||||
///
|
||||
/// These tests protect the main-actor isolation model against silent regression:
|
||||
///
|
||||
/// 1. **Off-main bridge** — `lyrebirdRunMainActorMutation` must run a `@MainActor`
|
||||
/// mutation correctly when invoked from a background thread (synchronous hop to
|
||||
/// main), without trapping. This path is exercised in production by the NRT inline
|
||||
/// dispatcher (`LyrebirdMessageContext(nrtEngine:)`) and by AUv3 off-main hosts. The
|
||||
/// rest of the suite runs `@MainActor` (node-tree mutation is a main-thread API), so
|
||||
/// these specific tests are deliberately **nonisolated** to drive the off-main path.
|
||||
///
|
||||
/// 2. **RT-layer purity** — Generator hot-path sources must never reference actor-hop
|
||||
/// machinery (`MainActor`, `assumeIsolated`, `DispatchQueue`, `Task {`). Under the
|
||||
/// Swift 6 language mode such a call would compile silently but violate the
|
||||
/// `nonisolated` RT render contract. This is a source-text lint.
|
||||
@Suite("Phase 201/202 isolation guards")
|
||||
struct Phase201IsolationGuardTests {
|
||||
|
||||
// MARK: - Guard A: off-main bridge
|
||||
|
||||
/// The bridge runs inline when already on the main thread.
|
||||
@Test @MainActor func bridgeRunsInlineOnMain() {
|
||||
var ran: Bool = false
|
||||
lyrebirdRunMainActorMutation { ran = true }
|
||||
#expect(ran)
|
||||
}
|
||||
|
||||
/// The bridge hops synchronously to main when called off-main — it must NOT trap
|
||||
/// (the regression that bare `MainActor.assumeIsolated` would have caused on the
|
||||
/// NRT inline / off-main AU-host paths).
|
||||
@Test func bridgeHopsFromBackgroundThreadWithoutTrapping() async {
|
||||
let done: DispatchSemaphore = DispatchSemaphore(value: 0)
|
||||
let ran: LockedBool = LockedBool()
|
||||
// Dispatch onto a background queue so the bridge takes its `main.sync` branch.
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
#expect(!Thread.isMainThread)
|
||||
lyrebirdRunMainActorMutation {
|
||||
// Body runs on the main actor.
|
||||
#expect(Thread.isMainThread)
|
||||
ran.set(true)
|
||||
}
|
||||
done.signal()
|
||||
}
|
||||
// Wait off the main thread (this test is nonisolated) so main is free to service
|
||||
// the bridge's synchronous hop.
|
||||
await withCheckedContinuation { (continuation: CheckedContinuation<Void, Never>) in
|
||||
DispatchQueue.global().async {
|
||||
_ = done.wait(timeout: .now() + 5)
|
||||
continuation.resume()
|
||||
}
|
||||
}
|
||||
#expect(ran.get())
|
||||
}
|
||||
|
||||
/// End-to-end: the NRT inline `LyrebirdMessageContext` dispatcher invoked from a
|
||||
/// background thread routes `ctx.add` through the bridge and the synth's `build()`
|
||||
/// runs (on main) — proving the off-main NRT add path does not trap.
|
||||
@Test func nrtInlineContextAddFromBackgroundThreadBuildsSynth() async {
|
||||
// No `engine.start()` here on purpose: `build()` runs at add time (in `prepareNode`),
|
||||
// before any render. Starting an NRT render would mark this pooled thread RT via
|
||||
// `RTThreadIdentity`; that marker persists and could false-trip
|
||||
// `_lyrebirdAssertNotOnRTThread` in a later `.compute()` test reusing the thread.
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 8, numAudioBuses: 4)
|
||||
let builtCount: LockedInt = LockedInt()
|
||||
final class ProbeSynth: SynthesizerBase, @unchecked Sendable {
|
||||
let onBuild: @Sendable () -> Void
|
||||
init(onBuild: @escaping @Sendable () -> Void) { self.onBuild = onBuild; super.init() }
|
||||
override func build() { onBuild() }
|
||||
}
|
||||
let ctx: LyrebirdMessageContext = LyrebirdMessageContext(nrtEngine: engine)
|
||||
// Synth construction is `@MainActor` (Phase 201); build it on main, then add from
|
||||
// a background thread to exercise the off-main bridge hop.
|
||||
let synth: ProbeSynth = await MainActor.run { ProbeSynth { builtCount.increment() } }
|
||||
let done: DispatchSemaphore = DispatchSemaphore(value: 0)
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
ctx.add(synth) // inline dispatcher → lyrebirdRunMainActorMutation off-main → main hop
|
||||
done.signal()
|
||||
}
|
||||
await withCheckedContinuation { (continuation: CheckedContinuation<Void, Never>) in
|
||||
DispatchQueue.global().async {
|
||||
_ = done.wait(timeout: .now() + 5)
|
||||
continuation.resume()
|
||||
}
|
||||
}
|
||||
#expect(builtCount.get() == 1)
|
||||
}
|
||||
|
||||
// MARK: - Guard B: RT-layer source purity
|
||||
|
||||
/// RT-DSP sources must not reference actor-isolation machinery. Under Swift 6 language
|
||||
/// mode an `@MainActor` / `assumeIsolated` call inside an RT-path source compiles
|
||||
/// silently but breaks the `nonisolated` RT render contract — this lint fails the build
|
||||
/// before that can ship.
|
||||
///
|
||||
/// Scope: the pure RT-DSP directories — `Generators/` (concrete units), `GeneratorCore/`
|
||||
/// (the Generator protocol layer + `MulAdd` + hot-loop helpers), `Oversampling/`,
|
||||
/// `Spectral/`, and `Math/`. `Engine/` and `NodeTree/` are intentionally NOT scanned:
|
||||
/// they legitimately host the language-side `@MainActor` surface (`SynthesizerBase`,
|
||||
/// the `MainActorMutationBridge`) whose `evaluate`/render entry points are separately
|
||||
/// `nonisolated`.
|
||||
///
|
||||
/// Only `MainActor` / `assumeIsolated` are banned — pure actor-isolation hooks with no
|
||||
/// legitimate place in an RT-DSP unit. `DispatchQueue` / `Task` are intentionally NOT
|
||||
/// banned: buffer generators (`DiskIn` / `DiskOut`) use a background queue for off-RT
|
||||
/// disk I/O (the RT side only touches a lock-free ring buffer).
|
||||
@Test func generatorSourcesContainNoActorHopMachinery() throws {
|
||||
let rtDspDirs: [String] = [
|
||||
"Sources/Lyrebird/Generators",
|
||||
"Sources/Lyrebird/GeneratorCore",
|
||||
"Sources/Lyrebird/Oversampling",
|
||||
"Sources/Lyrebird/Spectral",
|
||||
"Sources/Lyrebird/Math",
|
||||
]
|
||||
let forbidden: [String] = [
|
||||
"MainActor",
|
||||
"assumeIsolated",
|
||||
]
|
||||
let fm: FileManager = FileManager.default
|
||||
var violations: [String] = []
|
||||
for dir: String in rtDspDirs {
|
||||
let root: URL = Self.repoRoot.appendingPathComponent(dir, isDirectory: true)
|
||||
guard let enumerator: FileManager.DirectoryEnumerator =
|
||||
fm.enumerator(at: root, includingPropertiesForKeys: nil) else {
|
||||
Issue.record("Could not enumerate \(root.path)")
|
||||
continue
|
||||
}
|
||||
for case let url as URL in enumerator where url.pathExtension == "swift" {
|
||||
let text: String = (try? String(contentsOf: url, encoding: .utf8)) ?? ""
|
||||
for token: String in forbidden where text.contains(token) {
|
||||
violations.append("\(dir)/\(url.lastPathComponent): contains '\(token)'")
|
||||
}
|
||||
}
|
||||
}
|
||||
#expect(
|
||||
violations.isEmpty,
|
||||
"RT-DSP sources must not use actor-hop machinery (breaks the nonisolated RT contract): \(violations)"
|
||||
)
|
||||
}
|
||||
|
||||
/// Repo root, derived from this file's path:
|
||||
/// `<root>/Tests/LyrebirdTests/Concurrency/Phase201IsolationGuardTests.swift`.
|
||||
private static var repoRoot: URL {
|
||||
URL(fileURLWithPath: #filePath)
|
||||
.deletingLastPathComponent() // Concurrency/
|
||||
.deletingLastPathComponent() // LyrebirdTests/
|
||||
.deletingLastPathComponent() // Tests/
|
||||
.deletingLastPathComponent() // <root>
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Tiny thread-safe test helpers
|
||||
|
||||
private final class LockedBool: @unchecked Sendable {
|
||||
private let lock: NSLock = NSLock()
|
||||
private var value: Bool = false
|
||||
func set(_ v: Bool) { lock.lock(); value = v; lock.unlock() }
|
||||
func get() -> Bool { lock.lock(); defer { lock.unlock() }; return value }
|
||||
}
|
||||
|
||||
private final class LockedInt: @unchecked Sendable {
|
||||
private let lock: NSLock = NSLock()
|
||||
private var value: Int = 0
|
||||
func increment() { lock.lock(); value += 1; lock.unlock() }
|
||||
func get() -> Int { lock.lock(); defer { lock.unlock() }; return value }
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import Testing
|
||||
|
||||
// MARK: - OscSin.Control Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("OscSin.Control")
|
||||
struct OscSinControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -134,6 +135,7 @@ struct OscSinControlTests {
|
||||
|
||||
// MARK: - OscTableControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("OscTableControl")
|
||||
struct OscTableControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -217,6 +219,7 @@ struct OscTableControlTests {
|
||||
|
||||
// MARK: - ImpulseControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("ImpulseControl")
|
||||
struct ImpulseControlTests {
|
||||
// Use blockSize == sampleRate so 1 Hz fires exactly once per block.
|
||||
@@ -332,6 +335,7 @@ struct ImpulseControlTests {
|
||||
|
||||
// MARK: - WhiteNoiseControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("WhiteNoiseControl")
|
||||
struct WhiteNoiseControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -406,6 +410,7 @@ struct WhiteNoiseControlTests {
|
||||
|
||||
// MARK: - LFStepNoiseControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("LFStepNoiseControl")
|
||||
struct LFStepNoiseControlTests {
|
||||
// blockSize == sampleRate so 1 Hz fires exactly once per block.
|
||||
@@ -522,6 +527,7 @@ struct LFStepNoiseControlTests {
|
||||
|
||||
// MARK: - LFLineNoiseControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("LFLineNoiseControl")
|
||||
struct LFLineNoiseControlTests {
|
||||
let blockSize: Int = 100
|
||||
@@ -648,6 +654,7 @@ private final class CountingControl: GeneratorBase, ControlGenerator {
|
||||
|
||||
// MARK: - Sub-block control tests
|
||||
|
||||
@MainActor
|
||||
@Suite("ControlGenerator sub-block")
|
||||
struct ControlGeneratorSubBlockTests {
|
||||
|
||||
@@ -826,6 +833,7 @@ struct ControlGeneratorSubBlockTests {
|
||||
|
||||
// MARK: - PinkNoiseControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("PinkNoiseControl")
|
||||
struct PinkNoiseControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -901,6 +909,7 @@ struct PinkNoiseControlTests {
|
||||
|
||||
// MARK: - BrownNoiseControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("BrownNoiseControl")
|
||||
struct BrownNoiseControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -975,6 +984,7 @@ struct BrownNoiseControlTests {
|
||||
|
||||
// MARK: - GrayNoiseControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("GrayNoiseControl")
|
||||
struct GrayNoiseControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -1049,6 +1059,7 @@ struct GrayNoiseControlTests {
|
||||
|
||||
// MARK: - ClipNoiseControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("ClipNoiseControl")
|
||||
struct ClipNoiseControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -1124,6 +1135,7 @@ struct ClipNoiseControlTests {
|
||||
|
||||
// MARK: - DustControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("DustControl")
|
||||
struct DustControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -1200,6 +1212,7 @@ struct DustControlTests {
|
||||
|
||||
// MARK: - Dust2Control Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("Dust2Control")
|
||||
struct Dust2ControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -1276,6 +1289,7 @@ struct Dust2ControlTests {
|
||||
|
||||
// MARK: - CrackleControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("CrackleControl")
|
||||
struct CrackleControlTests {
|
||||
let blockSize: Int = 64
|
||||
@@ -1356,6 +1370,7 @@ struct CrackleControlTests {
|
||||
|
||||
// MARK: - LFCurveNoiseControl Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("LFCurveNoiseControl")
|
||||
struct LFCurveNoiseControlTests {
|
||||
let blockSize: Int = 100
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("ConvolutionReverb.Audio — partitioned overlap-save FFT convolution")
|
||||
struct ConvolutionReverbTests {
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import Testing
|
||||
|
||||
// MARK: - CoreAudioDriverOptions defaults
|
||||
|
||||
@MainActor
|
||||
@Suite("CoreAudioDriverOptions") struct CoreAudioDriverOptionsTests {
|
||||
@Test func defaultMatchDeviceSampleRateIsFalse() {
|
||||
let opts: CoreAudioDriverOptions = CoreAudioDriverOptions()
|
||||
@@ -23,6 +24,7 @@ import Testing
|
||||
|
||||
// MARK: - Sample rate validation (offline, no hardware required)
|
||||
|
||||
@MainActor
|
||||
@Suite("CoreAudioDriver sample rate validation") struct CoreAudioSampleRateValidationTests {
|
||||
@Test func doesNotThrowWhenRatesMatch() throws {
|
||||
let opts: CoreAudioDriverOptions = CoreAudioDriverOptions()
|
||||
@@ -73,6 +75,7 @@ import Testing
|
||||
|
||||
// MARK: - deviceSampleRate property
|
||||
|
||||
@MainActor
|
||||
@Suite("CoreAudioDriver deviceSampleRate") struct CoreAudioDeviceSampleRateTests {
|
||||
@Test func deviceSampleRateNilBeforeSetup() {
|
||||
let driver: CoreAudioDriver = CoreAudioDriver()
|
||||
@@ -82,6 +85,7 @@ import Testing
|
||||
|
||||
// MARK: - Lifecycle (no hardware required)
|
||||
|
||||
@MainActor
|
||||
@Suite("CoreAudioDriver lifecycle") struct CoreAudioDriverLifecycleTests {
|
||||
@Test func stopBeforeSetupIsNoop() {
|
||||
let driver: CoreAudioDriver = CoreAudioDriver()
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Decay2")
|
||||
struct Decay2Tests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Decay")
|
||||
struct DecayTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DelayLineFeedback parameter ramping")
|
||||
struct DelayLineFeedbackParameterRampingTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandBrownian")
|
||||
struct DemandBrownianTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandConcatenate")
|
||||
struct DemandConcatenateTests {
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import Testing
|
||||
|
||||
// MARK: - DemandSequence
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandSequence")
|
||||
struct DSequenceTests {
|
||||
|
||||
@@ -65,6 +66,7 @@ struct DSequenceTests {
|
||||
|
||||
// MARK: - DemandRandom
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandRandom")
|
||||
struct DRandomTests {
|
||||
|
||||
@@ -115,6 +117,7 @@ struct DRandomTests {
|
||||
|
||||
// MARK: - Demand.Audio
|
||||
|
||||
@MainActor
|
||||
@Suite("Demand.Audio")
|
||||
struct DemandAudioTests {
|
||||
|
||||
@@ -235,6 +238,7 @@ struct DemandAudioTests {
|
||||
|
||||
// MARK: - Demand.Control
|
||||
|
||||
@MainActor
|
||||
@Suite("Demand.Control")
|
||||
struct DemandControlTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandGeometric")
|
||||
struct DemandGeometricTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandNonRepeatingRandom")
|
||||
struct DemandNonRepeatingRandomTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandSeries")
|
||||
struct DemandSeriesTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandShuffle")
|
||||
struct DemandShuffleTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandStutter")
|
||||
struct DemandStutterTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandSwitch")
|
||||
struct DemandSwitchTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandUniformRandom")
|
||||
struct DemandUniformRandomTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("DemandWeightedRandom")
|
||||
struct DemandWeightedRandomTests {
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import Testing
|
||||
|
||||
// MARK: - denormalsToZero helper
|
||||
|
||||
@MainActor
|
||||
@Suite("denormalsToZero")
|
||||
struct DenormalsToZeroTests {
|
||||
|
||||
@@ -57,6 +58,7 @@ struct DenormalsToZeroTests {
|
||||
// any computation that would produce a subnormal result is flushed to zero by the
|
||||
// hardware, so filter outputs and delay-line writes must never be subnormal.
|
||||
|
||||
@MainActor
|
||||
@Suite("FirstOrderSection — no subnormals under FTZ")
|
||||
struct FirstOrderSectionFTZTests {
|
||||
|
||||
@@ -87,6 +89,7 @@ struct FirstOrderSectionFTZTests {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("SecondOrderSection — no subnormals under FTZ")
|
||||
struct SecondOrderSectionFTZTests {
|
||||
|
||||
@@ -115,6 +118,7 @@ struct SecondOrderSectionFTZTests {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("RBJBandPass — no subnormals under FTZ")
|
||||
struct RBJBandPassFTZTests {
|
||||
|
||||
@@ -141,6 +145,7 @@ struct RBJBandPassFTZTests {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("DelayLineFeedback — no subnormals under FTZ")
|
||||
struct DelayLineFeedbackFTZTests {
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import Testing
|
||||
import Foundation
|
||||
@testable import LyrebirdSynth
|
||||
|
||||
@Suite("LyrebirdMessageCenter")
|
||||
@MainActor
|
||||
@Suite("LyrebirdMessageCenter")
|
||||
struct LyrebirdMessageCenterTests {
|
||||
|
||||
@Test("post stores message at the given tier")
|
||||
|
||||
@@ -122,6 +122,7 @@ private func makeNRTEngine(outputURL: URL, duration: Double,
|
||||
|
||||
// MARK: - Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("DiskIn / DiskOut")
|
||||
struct DiskInOutTests {
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ private func collect2ch(
|
||||
|
||||
// MARK: - AmplitudeFollower Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("AmplitudeFollower")
|
||||
struct AmplitudeFollowerTests {
|
||||
|
||||
@@ -185,6 +186,7 @@ struct AmplitudeFollowerTests {
|
||||
|
||||
// MARK: - FreqTracker Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("FreqTracker")
|
||||
struct FreqTrackerTests {
|
||||
|
||||
@@ -287,6 +289,7 @@ struct FreqTrackerTests {
|
||||
|
||||
// MARK: - LookAheadLimiter Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("LookAheadLimiter")
|
||||
struct LookAheadLimiterTests {
|
||||
|
||||
@@ -432,6 +435,7 @@ struct LookAheadLimiterTests {
|
||||
|
||||
// MARK: - Compressor Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("Compressor")
|
||||
struct CompressorTests {
|
||||
|
||||
@@ -570,6 +574,7 @@ struct CompressorTests {
|
||||
|
||||
// MARK: - Expander Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("Expander")
|
||||
struct ExpanderTests {
|
||||
|
||||
|
||||
@@ -8,7 +8,29 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
/// NRT `build`-closure shim (Phase 201).
|
||||
///
|
||||
/// `NRTJob.build` is a non-isolated `@Sendable (SynthesisEngine) throws -> Void`
|
||||
/// that `EngineHost._executeJob` runs on a background task — *not* the main actor.
|
||||
/// `SynthesisEngine.add(_:)` is `@MainActor` (Phase 201), so it cannot be invoked
|
||||
/// directly from inside the off-main build closure. The build closure runs *before*
|
||||
/// `engine.start()`, so the engine is not yet rendering and nothing else touches it
|
||||
/// concurrently; hopping the add onto the main actor synchronously is therefore safe
|
||||
/// in this narrow window. The `nonisolated(unsafe)` captures move the non-`Sendable`
|
||||
/// engine/synth across the hop — sound because of that exclusivity.
|
||||
private func nrtBuildAdd(_ engine: SynthesisEngine, _ makeSynth: @escaping @MainActor () -> any Synthesizer) throws {
|
||||
nonisolated(unsafe) let e: SynthesisEngine = engine
|
||||
var thrown: (any Error)? = nil
|
||||
DispatchQueue.main.sync {
|
||||
MainActor.assumeIsolated {
|
||||
do { try e.add(makeSynth()) } catch { thrown = error }
|
||||
}
|
||||
}
|
||||
if let thrown: any Error = thrown { throw thrown }
|
||||
}
|
||||
|
||||
/// Phase 197 — `EngineHost` facade coverage.
|
||||
@MainActor
|
||||
@Suite("EngineHost (Phase 197)")
|
||||
struct EngineHostTests {
|
||||
|
||||
@@ -240,7 +262,7 @@ struct EngineHostTests {
|
||||
sampleRate: 44100,
|
||||
numOutputChannels: 2
|
||||
) { engine in
|
||||
try engine.add(ConstSynth(value: 0.1 * Double(i + 1)))
|
||||
try nrtBuildAdd(engine) { ConstSynth(value: 0.1 * Double(i + 1)) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +301,7 @@ struct EngineHostTests {
|
||||
sampleRate: 44100,
|
||||
numOutputChannels: 2
|
||||
) { engine in
|
||||
try engine.add(ConstSynth(value: 0.1))
|
||||
try nrtBuildAdd(engine) { ConstSynth(value: 0.1) }
|
||||
},
|
||||
NRTJob(
|
||||
outputURL: dir.appendingPathComponent("fail.caf"),
|
||||
@@ -359,7 +381,7 @@ struct EngineHostTests {
|
||||
sampleRate: 44100,
|
||||
numOutputChannels: 2
|
||||
) { engine in
|
||||
try engine.add(ConstSynth(value: 0.1))
|
||||
try nrtBuildAdd(engine) { ConstSynth(value: 0.1) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +419,7 @@ struct EngineHostTests {
|
||||
sampleRate: 44100,
|
||||
numOutputChannels: 2
|
||||
) { engine in
|
||||
try engine.add(ConstSynth(value: 0.1))
|
||||
try nrtBuildAdd(engine) { ConstSynth(value: 0.1) }
|
||||
}
|
||||
]
|
||||
var count: Int = 0
|
||||
|
||||
@@ -38,6 +38,7 @@ private final class ControlBusStamper: Synthesizer {
|
||||
|
||||
// MARK: -
|
||||
|
||||
@MainActor
|
||||
@Suite("EngineMainGroup")
|
||||
struct EngineMainGroupTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Engine node counts")
|
||||
struct EngineNodeCountTests {
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import AudioToolbox
|
||||
import Synchronization
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("SynthesizerBase autoFreeOnDone")
|
||||
struct AutoFreeOnDoneTests {
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import Foundation
|
||||
/// One-off verification of `EnvelopeGen.{Audio,Control}` timeScale behavior
|
||||
/// — reproduces the MyPiece scenario: envelope durations [0.2, 0.6, 0.2]
|
||||
/// (sum 1.0), timeScale 8.0 → expected total 8 seconds.
|
||||
@MainActor
|
||||
@Suite("EnvelopeGen timeScale verification")
|
||||
struct EnvelopeTimeScaleVerificationTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("EuclideanRhythm")
|
||||
struct EuclideanRhythmTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Expander parameter ramping")
|
||||
struct ExpanderParameterRampingTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Foundation
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("ExponentialLine")
|
||||
struct ExponentialLineTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("FFT Infrastructure")
|
||||
struct FFTTests {
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import Testing
|
||||
/// generators within the same engine segment (same `segmentSerial`), its `_computeSamples`
|
||||
/// is invoked exactly once and the cached result is shared. This prevents the "double phase
|
||||
/// advance" artefact that one oscillator feeding two `Out` generators would otherwise produce.
|
||||
@MainActor
|
||||
@Suite("Fan-out caching")
|
||||
struct FanOutCachingTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Flanger")
|
||||
struct FlangerTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Flute")
|
||||
struct FluteTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("FormantGrain")
|
||||
struct FormantGrainTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Fraction — exact rational arithmetic for Score")
|
||||
struct FractionTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("FreeVerb — stereo reverb")
|
||||
struct FreeVerbTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("FrequencyShifter")
|
||||
struct FrequencyShifterTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("GVerb — Griesinger algorithmic stereo reverb")
|
||||
struct GVerbTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Gate.Audio")
|
||||
struct GateAudioTests {
|
||||
|
||||
@@ -88,6 +89,7 @@ struct GateAudioTests {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("Gate.Control")
|
||||
struct GateControlTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("GatedKarplusStrong")
|
||||
struct GatedKarplusStrongTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Gendy1")
|
||||
struct Gendy1Tests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Gendy2")
|
||||
struct Gendy2Tests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Gendy3")
|
||||
struct Gendy3Tests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("GeneratorArray")
|
||||
struct GeneratorArrayTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 8)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("GeneratorInputProvider")
|
||||
struct GeneratorInputProviderTests {
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ final class MutableControlGen: GeneratorBase, ControlGenerator {
|
||||
func floatValue(graph: SynthGraph) -> Double { target }
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("ProcessingRate")
|
||||
struct ProcessingRateTests {
|
||||
@Test func audioRateExists() {
|
||||
@@ -70,6 +71,7 @@ struct ProcessingRateTests {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("Generator protocol")
|
||||
struct GeneratorProtocolTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 8)
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("BufferGrain")
|
||||
struct GranularTests {
|
||||
|
||||
@@ -372,6 +373,7 @@ struct GranularTests {
|
||||
|
||||
// MARK: - SineGrain
|
||||
|
||||
@MainActor
|
||||
@Suite("SineGrain")
|
||||
struct SineGrainTests {
|
||||
|
||||
@@ -599,6 +601,7 @@ struct SineGrainTests {
|
||||
|
||||
// MARK: - FMGrain
|
||||
|
||||
@MainActor
|
||||
@Suite("FMGrain")
|
||||
struct FMGrainTests {
|
||||
|
||||
@@ -826,6 +829,7 @@ struct FMGrainTests {
|
||||
|
||||
// MARK: - InputGrain
|
||||
|
||||
@MainActor
|
||||
@Suite("InputGrain")
|
||||
struct InputGrainTests {
|
||||
|
||||
@@ -1051,6 +1055,7 @@ struct InputGrainTests {
|
||||
|
||||
// MARK: - TimeStretch
|
||||
|
||||
@MainActor
|
||||
@Suite("TimeStretch")
|
||||
struct TimeStretchTests {
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ final class NoGateSynth: Synthesizer {
|
||||
|
||||
// MARK: -
|
||||
|
||||
@MainActor
|
||||
@Suite("Group Semantics")
|
||||
struct GroupSemanticsTests {
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import Testing
|
||||
// Synthesizer values in PreparedNode(_:) at the call site — mirroring what
|
||||
// SynthesisEngine.schedule does on the main thread.
|
||||
|
||||
@MainActor
|
||||
@Suite("Group")
|
||||
struct GroupTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("HalfbandDownsampler2x")
|
||||
struct HalfbandDownsampler2xTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("HalfbandFIR coefficients")
|
||||
struct HalfbandFIRTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Halfband oversampling round-trip")
|
||||
struct HalfbandRoundTripTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("HalfbandUpsampler2x")
|
||||
struct HalfbandUpsampler2xTests {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import Testing
|
||||
import Foundation
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Hilbert")
|
||||
struct HilbertTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("In (audio bus)")
|
||||
struct InGeneratorTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 64)
|
||||
@@ -78,6 +79,7 @@ struct InGeneratorTests {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Suite("ControlIn")
|
||||
struct ControlInTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 64)
|
||||
@@ -137,6 +139,7 @@ struct ControlInTests {
|
||||
|
||||
// MARK: - Multi-channel In.Audio
|
||||
|
||||
@MainActor
|
||||
@Suite("In.Audio multi-channel")
|
||||
struct InAudioMultiChannelTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 64)
|
||||
@@ -198,6 +201,7 @@ struct InAudioMultiChannelTests {
|
||||
|
||||
// MARK: - Multi-channel In.Control
|
||||
|
||||
@MainActor
|
||||
@Suite("In.Control multi-channel")
|
||||
struct InControlMultiChannelTests {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 64)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("Jitter")
|
||||
struct JitterTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("KarplusStrong")
|
||||
struct KarplusStrongTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("LFCurveNoise.Audio generator freq")
|
||||
struct LFCurveNoiseAudioGenFreqTests {
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import Testing
|
||||
|
||||
// MARK: - LFDutyCycle Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("LFDutyCycle")
|
||||
struct LFDutyCycleTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("LFLineNoise.Audio generator freq")
|
||||
struct LFLineNoiseAudioGenFreqTests {
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import Testing
|
||||
|
||||
// MARK: - LFSawtooth Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("LFSawtooth")
|
||||
struct LFSawtoothTests {
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import Testing
|
||||
|
||||
// MARK: - LFSquare Tests
|
||||
|
||||
@MainActor
|
||||
@Suite("LFSquare")
|
||||
struct LFSquareTests {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("LFStepNoise.Audio generator freq")
|
||||
struct LFStepNoiseAudioGenFreqTests {
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user