Address Shimmer review: init param docs + deterministic generator test
- Add init-level /// - Parameters: block to ShimmerReverb (dual-location docs). - Add a pinned-value generator test: with decay/shimmer/damp = 0 the tank is a unity-DC allpass chain, so two DC levels scale exactly linearly (ratio 2.0, output-gain independent). Suite 256. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -92,6 +92,16 @@ public final class ShimmerReverb: GeneratorBase, AudioGenerator {
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a shimmer reverb.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - input: Audio-rate signal to reverberate.
|
||||
/// - maxDelay: Maximum tank delay in seconds; sizes the pre-allocated buffer.
|
||||
/// - size: Tank delay in seconds. Control rate; clamped to `[0.005, maxDelay]`.
|
||||
/// - decay: Feedback gain (tail length). Control rate; clamped to `[0, 0.92]`.
|
||||
/// - shimmer: Octave-up feedback amount. Control rate; clamped to `[0, 0.85]`.
|
||||
/// - damp: High-frequency damping in the feedback `[0, 1]` (0 = bright, 1 = dark). Control rate.
|
||||
/// - sampleRate: Sample rate used to size buffers and convert seconds → frames; match the engine.
|
||||
public init(
|
||||
input: any ValidGeneratorInput,
|
||||
maxDelay: Double,
|
||||
|
||||
@@ -81,6 +81,20 @@ struct ShimmerReverbTests {
|
||||
#expect(!hasNonSilentOutput(samples), "shimmer reverb rang with no input")
|
||||
}
|
||||
|
||||
@Test func passesDCWithUnityGainAndLinearScaling() throws {
|
||||
// With decay = shimmer = damp = 0, the tank is just the input through two Schroeder
|
||||
// allpasses (unity at DC steady state) delayed by `size`. The output is therefore a fixed
|
||||
// gain (the harness output gain/pan) times the DC input — exactly linear. Compare two DC
|
||||
// levels at a settled frame so the harness scale cancels: the ratio must be 2.0.
|
||||
let high: [Float] = try render(oscFreq: nil, dc: 1.0, size: 0.01, decay: 0.0, shimmer: 0.0)
|
||||
let low: [Float] = try render(oscFreq: nil, dc: 0.5, size: 0.01, decay: 0.0, shimmer: 0.0)
|
||||
let frame: Int = 1500 // past the size delay + allpass settling, within the read window
|
||||
let h: Double = Double(high[frame * 2])
|
||||
let l: Double = Double(low[frame * 2])
|
||||
#expect(abs(h) > 1e-3, "settled DC output should be non-zero")
|
||||
#expect(abs(h / l - 2.0) < 0.01, "DC gain should be exactly linear (ratio 2.0)")
|
||||
}
|
||||
|
||||
@Test func decayChangesTheTail() throws {
|
||||
// Small tank so feedback round-trips compound within the reader's window; different decay
|
||||
// must change the tail (direction-agnostic — a tuned comb is not monotonic in level).
|
||||
|
||||
Reference in New Issue
Block a user