From a2fcd59e1b32c19811a893982c72cee374058a60 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Tue, 4 Aug 2026 08:26:56 -0700 Subject: [PATCH] docs+test(amp): honest Bias X wording + combined-extreme ceiling test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review follow-ups (no blockers were found): - Rewrite Bias X docs: it's a power-amp bias-balance CHARACTER control that re-shapes the saturation knee, not a literal push-pull even-harmonic model (averaging two same-polarity bias-offset stages doesn't replicate push-pull imbalance). Document that both halves are always built (2x power-amp cost even at biasX=0 — chosen for a smooth live knob over a rebuild-on-change fast path). Fix a public->internal DocC symbol link (plain code font). - Add extremeBiasAndBiasXStayWithinCeiling: Bias hot + Bias X max drives a half-stage bias to ±0.6 (tanh-bounded, outputLimit-clamped) — asserts finite, ≤ ±1. 651 tests pass. Co-Authored-By: Claude Opus 4.8 --- .../Pedals/AmpVoicePedal.swift | 29 ++++++++++--------- .../AmpVoicePedalTests.swift | 14 +++++++++ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift b/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift index 9400595..c40c168 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift @@ -59,10 +59,11 @@ open class AmpVoicePedal: Pedal { /// hotter (warmer, more even harmonics). Surfaced in the advanced pop-over. See /// ``powerAmpBiasInput``. @UIParam public var bias: Double = 0.5 - /// Power-amp **Bias X** (push-pull balance) in `[0, 1]`, default `0` = balanced. `0` reproduces - /// the shipped single-stage tone exactly; turning it up spreads the two power-amp half-stages' - /// operating points, shifting the even/odd harmonic mix as an imbalanced push-pull pair would. - /// Surfaced in the advanced pop-over. See ``powerAmpStage(_:)``. + /// Power-amp **Bias X** (bias balance) in `[0, 1]`, default `0` = balanced. At `0` the power amp + /// is a single stage — the shipped tone, exactly. Turning it up spreads the two power-amp + /// half-stages' bias operating points and averages them, re-shaping the saturation knee for a + /// distinct power-amp character (named after the "bias balance" trim on amps that expose one). + /// Surfaced in the advanced pop-over. See `powerAmpStage(_:)`. @UIParam public var biasX: Double = 0.0 // MARK: - Subclass configuration @@ -176,14 +177,16 @@ open class AmpVoicePedal: Pedal { LinLin.Audio($bias, inLo: 0.0, inHi: 1.0, outLo: coldPowerAmpBias, outHi: hotPowerAmpBias) } - /// The power-amp stage, modelling push-pull tube **balance** via ``biasX``: two `TriodeStage` - /// halves biased at `powerAmpBiasInput ± (biasX · biasXMaxSpread)`, averaged. At `biasX = 0` both - /// halves share the base bias, so the average is bit-identical to a single stage (the shipped - /// behaviour); turning `biasX` up spreads their operating points, shifting the even/odd harmonic - /// mix the way an imbalanced push-pull pair would. + /// The power-amp stage. **Bias X** (``biasX``) spreads the two `TriodeStage` halves' bias + /// operating points to `powerAmpBiasInput ± (biasX · biasXMaxSpread)` and averages them. At + /// `biasX = 0` both halves share the base bias, so the average is bit-identical to a single stage + /// (the shipped tone); turning `biasX` up widens the spread, re-shaping the saturation character. /// - /// > Note: this is a character control layered on the single-ended power-stage model, not a full - /// > push-pull topology rebuild — it deliberately reduces to the exact prior tone at `biasX = 0`. + /// > Note: a deliberate approximation — a *character* control on the single-ended power-stage + /// > model, not a literal push-pull topology (which would re-voice every amp). It reduces to the + /// > exact prior tone at `biasX = 0`. Both halves are always built, so an amp pays two oversampled + /// > stages even at `biasX = 0` — a smooth, live knob was preferred over a rebuild-on-change + /// > single-stage fast path. /// /// - Parameter signal: The post-`onboardEffects` signal into the power amp. /// - Returns: The blended power-amp output. @@ -338,8 +341,8 @@ open class AmpVoicePedal: Pedal { /// Power-amp deep-cut controls, tucked behind the pedal card's advanced pop-over: **Sag** /// (power-supply droop/bloom), **Bias** (power-amp grid-bias operating point), and **Bias X** - /// (push-pull balance). None is a topology control — all are live nodes that round-trip through - /// the rig save format. Order is append-only (persisted positionally in `advancedValues`). + /// (power-amp bias balance). None is a topology control — all are live nodes that round-trip + /// through the rig save format. Order is append-only (persisted positionally in `advancedValues`). public override var advancedKnobs: [PedalKnob] { [ PedalKnob(label: "Sag", node: $sag, range: signatureRange), diff --git a/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift b/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift index 1d69238..2d61040 100644 --- a/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift +++ b/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift @@ -263,6 +263,20 @@ struct AmpVoicePedalTests { } } + @Test func extremeBiasAndBiasXStayWithinCeiling() throws { + // Bias (hot) + Bias X (max) together drive a half-stage bias to ±0.6 (base ±0.25 ± spread + // 0.35). The tanh stays bounded and outputLimit clamps — output must stay finite and ≤ ±1. + let ceilingEpsilon: Double = 1.0e-4 + for voice in voices { + let hot: [Float] = try render(voice.make) { (pedal: AmpVoicePedal) in + pedal.gain = 30.0; pedal.bass = 1.0; pedal.treble = 1.0; pedal.bias = 1.0; pedal.biasX = 1.0 + } + #expect(hot.allSatisfy { $0.isFinite }, "\(voice.name) bias+biasX produced non-finite output") + let peak: Double = hot.reduce(0.0) { Swift.max($0, abs(Double($1))) } + #expect(peak <= 1.0 + ceilingEpsilon, "\(voice.name) bias+biasX peak \(peak) exceeds ±1") + } + } + @Test func advancedKnobsExposeSagBiasAndBiasX() throws { for voice in voices { let pedal: AmpVoicePedal = voice.make()