// BritishComboAmpPedal.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import LyrebirdSynth import LyrebirdUI /// Shared base for the British (Marshall-voiced) amps — the `.marshall` tone stack plus a common /// **Presence** lift (post-power-amp high-shelf) and a **Bright** switch (pre-preamp high-shelf). /// /// The non-master voices (Plexi / JTM / Bluesbreaker) run a fixed power-amp drive — loudness comes /// from cranking `Gain`; the Bluesbreaker additionally overlays tremolo. The master-volume voices /// (British Master / British Dual) subclass this too, adding a `Master` (via /// ``AmpVoicePedal/masterDrive(_:minDrive:maxDrive:)``) and a cascaded lead ``preampStage(_:)``. /// /// Distinct from ``BritishAmpPedal``, the standalone master-volume crunch voice. open class BritishComboAmpPedal: AmpVoicePedal { /// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`. @UIParam public var presence: Double = 0.4 /// Bright switch: `0` = flat, `1` = treble shelf engaged. @UIParam public var bright: Double = 0.0 private let presenceFreqHz: Double = 4500.0 private let presenceMaxGainDb: Double = 8.0 private let presenceSlope: Double = 0.7 private let brightFreqHz: Double = 3500.0 private let brightMaxGainDb: Double = 6.0 private let brightSlope: Double = 0.7 let switchOffValue: Double = 0.0 let switchOnValue: Double = 1.0 /// Grid bias of a cascaded lead/drive `TriodeStage` — a little asymmetry for even-harmonic /// grind. Shared by the master-volume subclasses' cascaded ``preampStage(_:)``. let leadBias: Double = 0.15 public override var toneStackModel: ToneStackModel { .marshall } public override var signatureKnobs: [PedalKnob] { [PedalKnob(label: "Presence", node: $presence, range: signatureRange)] } public override var effectSwitches: [PedalSwitch] { [ PedalSwitch( label: "Bright", node: $bright, options: [ PedalSwitch.Option(title: "Off", value: switchOffValue), PedalSwitch.Option(title: "On", value: switchOnValue), ] ), ] } /// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild). public override func inputShaping(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput { let shelfGainDb: any ValidGeneratorInput = $bright * brightMaxGainDb return RBJHighShelf.Audio( input: signal, freq: brightFreqHz, gain: shelfGainDb, slope: brightSlope) } /// Presence: a post-power-amp high-shelf lift, `[0, 1]` → `[0, presenceMaxGainDb]` dB. public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput { let gainDB: LinLin.Audio = LinLin.Audio( $presence, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: presenceMaxGainDb) return RBJHighShelf.Audio(input: signal, freq: presenceFreqHz, gain: gainDB, slope: presenceSlope) } }