v1.7.2 release: sample-rate-invariant TriodeStage coupling + Mesa/Soldano tone stacks
- TriodeStage coupling DC-blocker corner is now held constant in Hz across sample rates (was a fixed pole whose corner drifted up with Fs, thinning low end at high rates); evaluated at init, off the RT thread. - New ToneStackModel cases .mesa and .soldano (Faust tonestacks-library values). - GrayNoise output clamped to [-1, 1] (Int32.min edge).
This commit is contained in:
@@ -110,4 +110,35 @@ struct TriodeStageTests {
|
||||
#expect(naiveRatio > 0.05, "baseline did not alias as expected (ratio=\(naiveRatio))")
|
||||
#expect(osRatio < naiveRatio * 0.5, "oversampling did not reduce aliasing: os=\(osRatio) naive=\(naiveRatio)")
|
||||
}
|
||||
|
||||
@Test func couplingPoleMatchesLegacyAtReferenceRate() {
|
||||
// The sample-rate-aware coupling pole must equal the legacy fixed coefficient at 44.1 kHz,
|
||||
// so the historical 44.1 / 48 kHz voicing is unchanged.
|
||||
#expect(abs(TriodeStage.couplingPole(sampleRate: 44_100.0) - leakDCDefaultAudioCoef) < 1.0e-12)
|
||||
}
|
||||
|
||||
@Test func couplingCornerIsSampleRateInvariant() throws {
|
||||
// The DC-blocker corner must stay fixed in Hz across sample rates — with the old fixed pole
|
||||
// the corner drifted up with Fs and thinned the low end at 88.2 / 96 kHz. Measure |H| at a
|
||||
// low frequency (small amplitude → near-linear) and confirm it matches across rates.
|
||||
let lowHz: Double = 40.0
|
||||
func lowFreqTransfer(atSampleRate rate: Double) throws -> Double {
|
||||
let eng: SynthesisEngine = makeTestEngine(blockSize: 64, sampleRate: rate)
|
||||
try eng.start()
|
||||
let blocks: Int = 400
|
||||
let tailLen: Int = eng.blockSize * 256
|
||||
let sineIn: OscSin.Audio = OscSin.Audio(freq: lowHz, mul: 0.05)
|
||||
let inTail: [Double] = Array(collectBlocks(sineIn, engine: eng, blocks: blocks).suffix(tailLen))
|
||||
let sine: OscSin.Audio = OscSin.Audio(freq: lowHz, mul: 0.05)
|
||||
let stage: TriodeStage = TriodeStage(input: sine, drive: 1.0, bias: 0.0, oversample: 2)
|
||||
let outTail: [Double] = Array(collectBlocks(stage, engine: eng, blocks: blocks).suffix(tailLen))
|
||||
let cps: Double = lowHz / rate
|
||||
return goertzel(outTail, cyclesPerSample: cps) / goertzel(inTail, cyclesPerSample: cps)
|
||||
}
|
||||
let h48: Double = try lowFreqTransfer(atSampleRate: 48_000.0)
|
||||
let h96: Double = try lowFreqTransfer(atSampleRate: 96_000.0)
|
||||
#expect(h48 > 0.5 && h96 > 0.5, "low-frequency transfer implausibly low (48k=\(h48) 96k=\(h96))")
|
||||
#expect(abs(h96 - h48) / h48 < 0.1,
|
||||
"coupling corner drifts with sample rate: |H(40Hz)| 48k=\(h48) 96k=\(h96)")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user