From b9a63eeaf595c2c55cb6165600ba7fe4cfcf80ed Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Mon, 3 Aug 2026 09:53:03 -0700 Subject: [PATCH] feat(amps): master-volume enabler + Master knob on British MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add powerAmpDriveInput hook to AmpVoicePedal: an overridable drive into the power-amp TriodeStage, defaulting to the fixed powerAmpDrive so the five existing amps are byte-for-byte unchanged. A master-volume amp overrides it with a live knob mapped to a drive range — so Master pushes the power-amp stage into saturation (real master-volume behaviour), unlike `level`, which only attenuates the finished output post-cab/post-limiter. British gains a Master knob (LinLin [0,1] → power-amp drive [0.5, 5.0]): crank Gain for preamp grind, set Master for power-amp saturation. signatureKnobs now [Presence, Master]. Other current amps are non-master (Fender blackface, Vox, JC) and keep the fixed drive. Tests: Master changes the power-amp tone (not just level), round-trips through state; British control-surface updated. Co-Authored-By: Claude Opus 4.8 --- .../Pedals/AmpVoicePedal.swift | 9 ++++++- .../Pedals/BritishAmpPedal.swift | 25 ++++++++++++++++--- .../AmpVoicePedalTests.swift | 20 ++++++++++++++- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift b/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift index 4eeb4ac..f411c70 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift @@ -85,6 +85,13 @@ open class AmpVoicePedal: Pedal { signal } + /// Drive into the power-amp `TriodeStage`. Defaults to the fixed ``powerAmpDrive``; a + /// master-volume amp overrides this to return a live `Master` knob mapped to a drive range, so + /// turning Master up pushes the power-amp stage into saturation — the real master-volume + /// behaviour — rather than merely attenuating the finished output the way `level` does. Non- + /// master amps leave it at the fixed value and are unaffected. + open var powerAmpDriveInput: any ValidGeneratorInput { powerAmpDrive } + // MARK: - Constants private static let defaultMix: Double = 1.0 @@ -201,7 +208,7 @@ open class AmpVoicePedal: Pedal { input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel) let processed: any ValidGeneratorInput = onboardEffects(toned) let powerAmp: TriodeStage = TriodeStage( - input: processed, drive: powerAmpDrive, bias: powerAmpBias, oversample: 2) + input: processed, drive: powerAmpDriveInput, bias: powerAmpBias, oversample: 2) return shapeVoice(powerAmp) } diff --git a/Sources/LyrebirdShoeGaze/Pedals/BritishAmpPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/BritishAmpPedal.swift index 84fd5d1..04b6f64 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/BritishAmpPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/BritishAmpPedal.swift @@ -7,24 +7,41 @@ import LyrebirdSynth import LyrebirdUI -/// British-voiced amp (mid-forward crunch) with a **Presence** upper-high lift control. +/// British-voiced amp (mid-forward crunch) with a **Presence** lift and a **Master** volume. /// -/// A ``AmpVoicePedal`` fixed to the British tone stack, defaulting to a higher gain for crunch. +/// A ``AmpVoicePedal`` fixed to the British tone stack, defaulting to a higher gain for crunch. The +/// Master control drives the power-amp stage (via ``AmpVoicePedal/powerAmpDriveInput``), so raising +/// it adds power-amp saturation — turn `Gain` up for preamp grind and use `Master` to set how hard +/// that hits the power amp, the classic master-volume interplay. public final class BritishAmpPedal: AmpVoicePedal { /// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`. @UIParam public var presence: Double = 0.4 + /// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`]. + @UIParam public var master: Double = 0.3 private let presenceFreqHz: Double = 4500.0 private let presenceMaxGainDb: Double = 8.0 private let shelfSlope: Double = 0.7 + /// Power-amp drive at `master = 0` — barely driven (cleanest power stage). + private let masterMinDrive: Double = 0.5 + /// Power-amp drive at `master = 1` — hard into power-amp saturation. + private let masterMaxDrive: Double = 5.0 public override var toneStackModel: ToneStackModel { .marshall } public override var summaryText: String { - "British crunch — forward mids and bite, with a Presence lift." + "British crunch — forward mids and bite, with Presence and a Master volume." } public override var signatureKnobs: [PedalKnob] { - [PedalKnob(label: "Presence", node: $presence, range: signatureRange)] + [ + PedalKnob(label: "Presence", node: $presence, range: signatureRange), + PedalKnob(label: "Master", node: $master, range: signatureRange), + ] + } + + /// Master drives the power-amp stage: `[0, 1]` → `[masterMinDrive, masterMaxDrive]`. + public override var powerAmpDriveInput: any ValidGeneratorInput { + LinLin.Audio($master, inLo: 0.0, inHi: 1.0, outLo: masterMinDrive, outHi: masterMaxDrive) } /// Creates a British amp. diff --git a/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift b/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift index 918652e..abd4b15 100644 --- a/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift +++ b/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift @@ -127,6 +127,24 @@ struct AmpVoicePedalTests { #expect(windowedSSD(flat, lifted) > 0, "British Presence had no effect") } + @Test func britishMasterDrivesPowerAmp() throws { + // Master drives the power-amp stage, so at fixed preamp Gain a low vs high Master must + // change the tone (power-amp saturation), not merely the level — verify the waveform differs + // after normalizing out any overall level change. + let low: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 12.0; $0.master = 0.1 } + let high: [Float] = try render({ BritishAmpPedal() }) { $0.gain = 12.0; $0.master = 1.0 } + #expect(hasNonSilentOutput(low) && hasNonSilentOutput(high)) + #expect(windowedSSD(low, high) > 0, "Master had no effect on the power-amp stage") + } + + @Test func britishMasterRoundTripsThroughState() throws { + let pedal: BritishAmpPedal = BritishAmpPedal() + pedal.master = 0.8 + let restored: BritishAmpPedal = BritishAmpPedal() + restored.applyState(pedal.captureState()) + #expect(restored.master == 0.8, "Master did not round-trip") + } + @Test func chimeCutChangesOutput() throws { let open: [Float] = try render({ ChimeAmpPedal() }) { $0.cut = 0.0 } let dark: [Float] = try render({ ChimeAmpPedal() }) { $0.cut = 1.0 } @@ -137,7 +155,7 @@ struct AmpVoicePedalTests { @Test func exposesControls() throws { #expect(CaliforniaAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Bright"]) - #expect(BritishAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence"]) + #expect(BritishAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Presence", "Master"]) #expect(ChimeAmpPedal().effectKnobs.map { $0.label } == ["Gain", "Bass", "Mid", "Treble", "Cut"]) for voice in voices { let pedal: AmpVoicePedal = voice.make()