From 16f837ee106cc7c86ac3ef05ed242fb7c55b7a67 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Sat, 27 Jun 2026 22:07:31 -0700 Subject: [PATCH] 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 --- .../Generators/ShimmerReverb.swift | 10 ++++++++++ .../LyrebirdShoeGazeTests/ShimmerReverbTests.swift | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Sources/LyrebirdShoeGaze/Generators/ShimmerReverb.swift b/Sources/LyrebirdShoeGaze/Generators/ShimmerReverb.swift index 5ce4531..a4ba69a 100644 --- a/Sources/LyrebirdShoeGaze/Generators/ShimmerReverb.swift +++ b/Sources/LyrebirdShoeGaze/Generators/ShimmerReverb.swift @@ -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, diff --git a/Tests/LyrebirdShoeGazeTests/ShimmerReverbTests.swift b/Tests/LyrebirdShoeGazeTests/ShimmerReverbTests.swift index b8a8264..cf611b8 100644 --- a/Tests/LyrebirdShoeGazeTests/ShimmerReverbTests.swift +++ b/Tests/LyrebirdShoeGazeTests/ShimmerReverbTests.swift @@ -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).