1.0.0 release
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// Pan2ParameterRampingTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@Suite("Pan2 parameter ramping")
|
||||
struct Pan2ParameterRampingTests {
|
||||
|
||||
@Test func generatorPanInputAffectsOutput() throws {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 64)
|
||||
try engine.start()
|
||||
defer { engine.stop() }
|
||||
|
||||
let lastSampleIdx: Int = engine.blockSize - 1
|
||||
|
||||
// Wire a ParameterNode as the pan input — it will ramp if changed.
|
||||
let panNode: ParameterNode = ParameterNode(0.0)
|
||||
let src: OscSin.Audio = OscSin.Audio(freq: 440.0)
|
||||
let pan: Pan2 = Pan2(input: src, pan: panNode)
|
||||
|
||||
// Block 1: pan = 0 (center) — both channels equal.
|
||||
let g1: SynthGraph = makeSynthGraph(engine: engine)
|
||||
let out1: [[Double]] = pan.calculatedSamples(graph: g1, count: 64)
|
||||
let leftFirst: Double = out1[0][0]
|
||||
let rightFirst: Double = out1[1][0]
|
||||
#expect(abs(leftFirst - rightFirst) < 1e-4,
|
||||
"Center pan: L and R should be equal at sample 0")
|
||||
advanceBlock(engine)
|
||||
|
||||
// Block 2: pan = 1.0 (hard right) — ramp plays out over the block.
|
||||
panNode.value = 1.0
|
||||
let g2: SynthGraph = makeSynthGraph(engine: engine)
|
||||
let out2: [[Double]] = pan.calculatedSamples(graph: g2, count: 64)
|
||||
// At the last sample the ramp has reached the target (hard right).
|
||||
// Right channel should be much larger than left.
|
||||
let leftLast: Double = abs(out2[0][lastSampleIdx])
|
||||
let rightLast: Double = abs(out2[1][lastSampleIdx])
|
||||
#expect(rightLast > leftLast + 0.1,
|
||||
"After pan=1.0 ramp: right channel should exceed left at last sample")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user