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:
@@ -25,9 +25,10 @@ private let shimmerReverbZeroBlock: [Double] = makeSampleBuffer()
|
|||||||
/// feedback = decay·damped + shimmer·pitched → written back into the tank
|
/// 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
|
/// The octave-up is a two-grain, 50%-overlap, Hann-windowed reader running at 2× over the most
|
||||||
/// buffer (a tape-style pitch raise). A per-sample safety clamp + denormal flush keep the loop
|
/// recent `grain` samples of the tank (the live wet content), a tape-style pitch raise whose
|
||||||
/// bounded even at high `decay` / `shimmer`.
|
/// 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.
|
/// `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
|
var writeVal: Double = diffused + decay * damped + shimmer * pitched
|
||||||
if writeVal > safetyClamp { writeVal = safetyClamp }
|
if writeVal > safetyClamp { writeVal = safetyClamp }
|
||||||
else 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
|
tank[writePos] = writeVal
|
||||||
|
|
||||||
out[i] = damped
|
out[i] = damped
|
||||||
|
|||||||
Reference in New Issue
Block a user