From 3cdb8d9ddb32ee37060b7a7dad903de199c85f19 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Mon, 3 Aug 2026 16:28:05 -0700 Subject: [PATCH] docs+test(amps): Modern High-Gain re-review nits - Note the sagGainFloor 0.15 rationale (~-16 dB, deepest droop before gating). - Rename the sag test's metric to dotProduct (it's an unnormalized sign check). Co-Authored-By: Claude Opus 4.8 --- Sources/LyrebirdShoeGaze/Pedals/ModernHighGainAmpPedal.swift | 5 +++-- .../LyrebirdShoeGazeTests/ModernHighGainAmpPedalTests.swift | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Sources/LyrebirdShoeGaze/Pedals/ModernHighGainAmpPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/ModernHighGainAmpPedal.swift index 49bafe1..98eb329 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/ModernHighGainAmpPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/ModernHighGainAmpPedal.swift @@ -32,8 +32,9 @@ public final class ModernHighGainAmpPedal: BoutiqueAmpPedal { private let tightFreqHz: Double = 120.0 /// Tight high-pass Q (Butterworth). private let tightQ: Double = 0.707 - /// Lowest the sag gain can droop to. Bounds sag depth and — crucially — keeps the gain strictly - /// positive: the envelope tracks a post-shelf signal that can exceed 1, so an unclamped + /// Lowest the sag gain can droop to (~-16 dB — the deepest droop before the tone reads as + /// obviously gated rather than sagging). Bounds sag depth and — crucially — keeps the gain + /// strictly positive: the envelope tracks a post-shelf signal that can exceed 1, so an unclamped /// `1 − sag·env` would go negative and phase-invert loud content instead of drooping. private let sagGainFloor: Double = 0.15 diff --git a/Tests/LyrebirdShoeGazeTests/ModernHighGainAmpPedalTests.swift b/Tests/LyrebirdShoeGazeTests/ModernHighGainAmpPedalTests.swift index 871ad4b..fa576fc 100644 --- a/Tests/LyrebirdShoeGazeTests/ModernHighGainAmpPedalTests.swift +++ b/Tests/LyrebirdShoeGazeTests/ModernHighGainAmpPedalTests.swift @@ -76,9 +76,10 @@ struct ModernHighGainAmpPedalTests { guard stiff.count >= skip + window, saggy.count >= skip + window else { Issue.record("render too short"); return } - let corr: Double = zip(stiff[skip..<(skip + window)], saggy[skip..<(skip + window)]) + // Unnormalized dot product — its sign is what matters: negative ⇒ phase-inverted copy. + let dotProduct: Double = zip(stiff[skip..<(skip + window)], saggy[skip..<(skip + window)]) .reduce(0.0) { acc, pair in acc + Double(pair.0) * Double(pair.1) } - #expect(corr > 0, "sag phase-inverted the signal (correlation \(corr) < 0)") + #expect(dotProduct > 0, "sag phase-inverted the signal (dot product \(dotProduct) < 0)") } @Test func tightSwitchChangesOutput() throws {