47 lines
1.7 KiB
Swift
47 lines
1.7 KiB
Swift
// ReplaceOutControlGeneratorTests.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Testing
|
|
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
|
|
|
@Suite("ReplaceOut.Control")
|
|
struct ReplaceOutControlGeneratorTests {
|
|
let engine: SynthesisEngine = makeTestEngine(blockSize: 16)
|
|
|
|
init() throws {
|
|
try engine.start()
|
|
}
|
|
|
|
@Test func rateIsControl() {
|
|
let gen: ReplaceOut.Control = ReplaceOut.Control(bus: 0, source: 0.3 as Double)
|
|
#expect(gen.rate == .control)
|
|
}
|
|
|
|
@Test func overwritesControlBus() {
|
|
let gen: ReplaceOut.Control = ReplaceOut.Control(bus: 0, source: 0.3 as Double)
|
|
let graph: SynthGraph = makeSynthGraph(engine: engine)
|
|
_ = gen.calculatedSamples(graph: graph, count: 8)
|
|
#expect(abs(engine.controlBuses[0] - 0.3) < 1e-6)
|
|
}
|
|
|
|
@Test func wipesPriorAdditiveControlWrite() {
|
|
let outGen: Out.Control = Out.Control(bus: 0, source: 0.4 as Double)
|
|
let repGen: ReplaceOut.Control = ReplaceOut.Control(bus: 0, source: 0.9 as Double)
|
|
let graph: SynthGraph = makeSynthGraph(engine: engine)
|
|
_ = outGen.calculatedSamples(graph: graph, count: 8)
|
|
_ = repGen.calculatedSamples(graph: graph, count: 8)
|
|
#expect(abs(engine.controlBuses[0] - 0.9) < 1e-6)
|
|
}
|
|
|
|
@Test func writesToCorrectBus() {
|
|
let gen: ReplaceOut.Control = ReplaceOut.Control(bus: 5, source: 1.2 as Double)
|
|
let graph: SynthGraph = makeSynthGraph(engine: engine)
|
|
_ = gen.calculatedSamples(graph: graph, count: 8)
|
|
#expect(abs(engine.controlBuses[5] - 1.2) < 1e-6)
|
|
#expect(engine.controlBuses[0] == 0.0)
|
|
}
|
|
}
|