64 lines
2.2 KiB
Swift
64 lines
2.2 KiB
Swift
// PanXYParameterRampingTests.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Testing
|
|
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
|
|
|
@Suite("PanXY parameter ramping")
|
|
struct PanXYParameterRampingTests {
|
|
|
|
@Test func xRampIsApplied() throws {
|
|
let engine: SynthesisEngine = makeTestEngine(blockSize: 64)
|
|
try engine.start()
|
|
defer { engine.stop() }
|
|
|
|
let lastSampleIdx: Int = engine.blockSize - 1
|
|
|
|
let pan: PanXY = PanXY(input: ConstantGeneratorInput(1.0))
|
|
pan.x = 0.0
|
|
pan.y = 1.0
|
|
|
|
// Block 1: settle x=0, y=+1.
|
|
let g1: SynthGraph = makeSynthGraph(engine: engine)
|
|
_ = pan.calculatedSamples(graph: g1, count: 64)
|
|
advanceBlock(engine)
|
|
|
|
// Block 2: change x to +1; should ramp within block.
|
|
pan.x = 1.0
|
|
let g2: SynthGraph = makeSynthGraph(engine: engine)
|
|
let out2: [[Double]] = pan.calculatedSamples(graph: g2, count: 64)
|
|
let ch0Last: Double = abs(out2[0][lastSampleIdx])
|
|
let ch1Last: Double = abs(out2[1][lastSampleIdx])
|
|
#expect(ch0Last < 1e-4, "After x=1 ramp: LF (ch0) should be near 0 at last sample")
|
|
#expect(ch1Last > 0.5, "After x=1 ramp: RF (ch1) should dominate")
|
|
}
|
|
|
|
@Test func yRampIsApplied() throws {
|
|
let engine: SynthesisEngine = makeTestEngine(blockSize: 64)
|
|
try engine.start()
|
|
defer { engine.stop() }
|
|
|
|
let lastSampleIdx: Int = engine.blockSize - 1
|
|
|
|
let pan: PanXY = PanXY(input: ConstantGeneratorInput(1.0))
|
|
pan.x = 0.0
|
|
pan.y = 1.0
|
|
|
|
let g1: SynthGraph = makeSynthGraph(engine: engine)
|
|
_ = pan.calculatedSamples(graph: g1, count: 64)
|
|
advanceBlock(engine)
|
|
|
|
// Block 2: ramp y to -1 (full rear).
|
|
pan.y = -1.0
|
|
let g2: SynthGraph = makeSynthGraph(engine: engine)
|
|
let out2: [[Double]] = pan.calculatedSamples(graph: g2, count: 64)
|
|
let ch0Last: Double = abs(out2[0][lastSampleIdx])
|
|
let ch3Last: Double = abs(out2[3][lastSampleIdx])
|
|
#expect(ch0Last < 1e-4, "After y=-1 ramp: LF (ch0) should be near 0")
|
|
#expect(ch3Last > 0.5, "After y=-1 ramp: LR (ch3) should dominate")
|
|
}
|
|
}
|