573a91f377
switchOffValue (0.0) / switchOnValue (1.0) were re-declared in six amp files and leadBias (0.15) in two. Hoist all three onto AmpVoicePedal as internal `let`s so every subclass inherits them; remove the per-file duplicates. Pure refactor — no behavior change; 610 tests stay green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
65 lines
2.8 KiB
Swift
65 lines
2.8 KiB
Swift
// 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
|
|
|
|
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)
|
|
}
|
|
}
|