// BritishComboAmpPedal.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT import LyrebirdSynth import LyrebirdUI /// Shared base for the **non-master** British voices (Plexi / JTM / Bluesbreaker) — the earlier /// Marshalls with no master volume, so the power-amp stage runs at a fixed drive and loudness comes /// from cranking `Gain`. /// /// Provides the common British control surface: the `.marshall` tone stack, a **Presence** lift /// (post-power-amp high-shelf) and a **Bright** switch (pre-preamp high-shelf). Concrete voices /// subclass this and differ by gain/cab/headroom; the Bluesbreaker additionally overlays tremolo. /// /// Distinct from ``BritishAmpPedal``, which is the master-volume (JCM-style) 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 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) } }