Music XML updates and optimizations
This commit is contained in:
@@ -429,6 +429,29 @@ struct SVFTests {
|
||||
#expect(!allSame, "SVF.Audio with LFO-driven freq must produce non-constant output")
|
||||
}
|
||||
|
||||
// MARK: 18b. Generator-driven freq above the sample rate stays stable (no divergence)
|
||||
|
||||
@Test func freqAboveSampleRateStaysFinite() {
|
||||
// A generator cutoff swept well past the sample rate drives sin(π·freq/sr)
|
||||
// negative; the coefficient must clamp to 0 rather than produce a negative
|
||||
// f that diverges the Chamberlin recurrence.
|
||||
let hugeFreq: Double = 2.0 * sampleRate
|
||||
let lfo: OscSin.Audio = OscSin.Audio(freq: 0.5, mul: hugeFreq, add: hugeFreq)
|
||||
let input: OscSin.Audio = OscSin.Audio(freq: 100.0, mul: 0.5)
|
||||
let svf: SVF.Audio = SVF.Audio(input: input, freq: lfo, q: svfButterworthQ)
|
||||
|
||||
var allFinite: Bool = true
|
||||
for _ in 0..<8 {
|
||||
let g: SynthGraph = makeSynthGraph(engine: engine)
|
||||
let result: [[Double]] = svf.calculatedSamples(graph: g, count: blockSize)
|
||||
for ch: Int in 0..<result.count {
|
||||
for s: Double in result[ch].prefix(blockSize) where !s.isFinite { allFinite = false }
|
||||
}
|
||||
advanceBlock(engine)
|
||||
}
|
||||
#expect(allFinite, "SVF.Audio with above-Nyquist generator freq must not diverge")
|
||||
}
|
||||
|
||||
// MARK: 19. Q driven by audio generator (per-sample q path)
|
||||
|
||||
@Test func qDrivenByAudioGenerator() {
|
||||
|
||||
Reference in New Issue
Block a user