prep for 1.2.0 release updates
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
// LFLineNoiseAudioGenFreqTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
@MainActor
|
||||
@Suite("LFLineNoise.Audio generator freq")
|
||||
struct LFLineNoiseAudioGenFreqTests {
|
||||
|
||||
@Test func generatorFreqDoesNotCrash() throws {
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 64)
|
||||
try engine.start()
|
||||
defer { engine.stop() }
|
||||
|
||||
let freqNode: ParameterNode = ParameterNode(2.0)
|
||||
let noise: LFLineNoise.Audio = LFLineNoise.Audio(freq: freqNode)
|
||||
|
||||
let g: SynthGraph = makeSynthGraph(engine: engine)
|
||||
let out: [[Double]] = noise.calculatedSamples(graph: g, count: 64)
|
||||
let samples: [Double] = Array((out.first ?? []).prefix(64))
|
||||
#expect(samples.allSatisfy { $0.isFinite }, "LFLineNoise.Audio output must be finite")
|
||||
#expect(samples.allSatisfy { abs($0) <= 1.0 + 1e-6 }, "LFLineNoise.Audio output must be in [-1, 1]")
|
||||
}
|
||||
|
||||
@Test func generatorFreqRampChangesOutput() throws {
|
||||
// Block 1: freq=0 (frozen interpolation). Block 2: freq ramps to high value.
|
||||
let engine: SynthesisEngine = makeTestEngine(blockSize: 64, sampleRate: 44100)
|
||||
try engine.start()
|
||||
defer { engine.stop() }
|
||||
|
||||
let freqNode: ParameterNode = ParameterNode(0.0)
|
||||
let noise: LFLineNoise.Audio = LFLineNoise.Audio(freq: freqNode, seed: 99)
|
||||
|
||||
let g1: SynthGraph = makeSynthGraph(engine: engine)
|
||||
_ = noise.calculatedSamples(graph: g1, count: 64)
|
||||
advanceBlock(engine)
|
||||
|
||||
freqNode.value = 3000.0
|
||||
let g2: SynthGraph = makeSynthGraph(engine: engine)
|
||||
let out2: [[Double]] = noise.calculatedSamples(graph: g2, count: 64)
|
||||
|
||||
let samples2: [Double] = Array((out2.first ?? []).prefix(64))
|
||||
#expect(samples2.allSatisfy { $0.isFinite }, "LFLineNoise.Audio output finite after freq ramp")
|
||||
// With high freq, the output should be moving (not constant).
|
||||
let range: Double = (samples2.max() ?? 0) - (samples2.min() ?? 0)
|
||||
#expect(range > 1e-6, "LFLineNoise.Audio with high freq should have non-constant output")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user