prep for 1.2.0 release updates
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
// DelayLineFeedbackCubicTests.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable @_spi(LyrebirdExtensions) import LyrebirdSynth
|
||||
|
||||
// MARK: - DelayLineFeedbackCubicTests
|
||||
|
||||
@MainActor
|
||||
@Suite("DelayLineFeedback cubic")
|
||||
struct DelayLineFeedbackCubicTests {
|
||||
|
||||
let engine: SynthesisEngine
|
||||
let sr: Double = 44100
|
||||
|
||||
init() throws {
|
||||
engine = makeTestEngine(blockSize: 64, sampleRate: 44100)
|
||||
try engine.start()
|
||||
}
|
||||
|
||||
/// The wet output of the feedback delay is the cubic-read delayed signal.
|
||||
/// For a unit impulse and a 3.5-sample delay, the first two non-zero outputs
|
||||
/// (frames 2 and 3) read only the original impulse — feedback has not yet
|
||||
/// recirculated into those taps — so they equal the Catmull-Rom basis at
|
||||
/// t = 0.5 (-0.0625, then 0.5625) regardless of the feedback coefficient.
|
||||
@Test func cubicFirstEchoMatchesCatmullRomBeforeRecirculation() {
|
||||
let dlf: DelayLineFeedback = DelayLineFeedback(input: Impulse.Audio(freq: 1.0),
|
||||
maxDelay: 16.0 / sr, delay: 3.5 / sr,
|
||||
decayTime: 1.0, sampleRate: sr,
|
||||
interpolation: .cubic)
|
||||
let g: SynthGraph = makeSynthGraph(engine: engine)
|
||||
let s: [Double] = dlf.calculatedSamples(graph: g, count: engine.blockSize)[0]
|
||||
|
||||
#expect(abs(s[0]) < 1e-12)
|
||||
#expect(abs(s[1]) < 1e-12)
|
||||
#expect(abs(s[2] - (-0.0625)) < 1e-12)
|
||||
#expect(abs(s[3] - 0.5625) < 1e-12)
|
||||
#expect(s.allSatisfy { $0.isFinite })
|
||||
}
|
||||
|
||||
@Test func cubicFiniteUnderNoise() {
|
||||
let dlf: DelayLineFeedback = DelayLineFeedback(input: WhiteNoise.Audio(),
|
||||
maxDelay: 0.05, delay: 0.013,
|
||||
decayTime: 0.3, sampleRate: sr,
|
||||
interpolation: .cubic)
|
||||
let s: [Double] = collectBlocks(dlf, engine: engine, blocks: 20)
|
||||
#expect(s.allSatisfy { $0.isFinite })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user