ShimmerReverb: flush denormals in tank feedback; clarify grain-read doc

Review nits: denormal-flush the recirculated tank value (not just the
damping state) so denormals can't persist in the buffer and burn RT CPU;
document that the octave-up grains read the recent wet tank content.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 09:33:24 -07:00
parent a12f58e1d1
commit 7a39a2477e
@@ -25,9 +25,10 @@ private let shimmerReverbZeroBlock: [Double] = makeSampleBuffer()
/// feedback = decay·damped + shimmer·pitched → written back into the tank
/// ```
///
/// The octave-up is a two-grain, 50%-overlap, Hann-windowed reader running at 2× over the tank
/// buffer (a tape-style pitch raise). A per-sample safety clamp + denormal flush keep the loop
/// bounded even at high `decay` / `shimmer`.
/// The octave-up is a two-grain, 50%-overlap, Hann-windowed reader running at 2× over the most
/// recent `grain` samples of the tank (the live wet content), a tape-style pitch raise whose
/// pitched output recirculates through the feedback. A per-sample safety clamp + denormal flush
/// keep the loop bounded even at high `decay` / `shimmer`.
///
/// `size`, `decay`, `shimmer`, and `damp` are read at control rate (once per block). Output is mono.
///
@@ -214,6 +215,8 @@ public final class ShimmerReverb: GeneratorBase, AudioGenerator {
var writeVal: Double = diffused + decay * damped + shimmer * pitched
if writeVal > safetyClamp { writeVal = safetyClamp }
else if writeVal < -safetyClamp { writeVal = -safetyClamp }
// Flush denormals so they never recirculate in the tank (RT CPU guard).
if abs(writeVal) < denormalFloor { writeVal = 0.0 }
tank[writePos] = writeVal
out[i] = damped