cda596b9d5
Add a shared AmpVoicePedal.masterDrive(_:minDrive:maxDrive:) helper (Master knob [0,1] → power-amp drive range) and route British's powerAmpDriveInput through it. Two new BritishComboAmpPedal subclasses (Presence + Bright inherited): - British Master — 800-series single-channel lead: preampStage cascades a second gain stage (both driven by Gain) + Master + 4× power-amp oversample. - British Dual — 900/DSL: rebuildsOnChange Clean/Lead Channel switch (Lead cascades a stage set by Drive), Master, spring reverb; widthUnits 4. Registered across 6 sites as .amp. 11 tests (Master drives power amp via RMS-normalized SSD, cascaded-vs-Plexi, channel switch + rebuildsOnChange, drive/ reverb, ceiling on lead channel at max, control surfaces, round-trips, registry). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
95 lines
4.2 KiB
Swift
95 lines
4.2 KiB
Swift
// BritishDualAmpPedal.swift
|
||
// Lyrebird
|
||
//
|
||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||
// SPDX-License-Identifier: MIT
|
||
|
||
import LyrebirdSynth
|
||
import LyrebirdUI
|
||
|
||
/// British **dual-channel master-volume** — the 900/DSL-era Marshall: a footswitchable Clean/Lead
|
||
/// channel, a Master volume, spring reverb, Presence, and a Bright switch. The modern high-gain
|
||
/// British workhorse.
|
||
///
|
||
/// A ``BritishComboAmpPedal`` (Presence + Bright) that adds a `rebuildsOnChange` **Channel** switch —
|
||
/// the Lead channel cascades a second gain stage (set by `Drive`) via ``preampStage(_:)`` — a
|
||
/// `Master` (power-amp drive), and spring reverb in the onboard-effects slot.
|
||
public final class BritishDualAmpPedal: BritishComboAmpPedal {
|
||
|
||
/// Master volume in [0, 1] → power-amp drive in [`masterMinDrive`, `masterMaxDrive`].
|
||
@UIParam public var master: Double = 0.5
|
||
/// Lead-channel preamp gain (the cascaded stage). Range [1, 30].
|
||
@UIParam public var drive: Double = 8.0
|
||
/// Spring-reverb wet mix in [0, 1].
|
||
@UIParam public var reverb: Double = 0.2
|
||
/// Channel select: `0` = Clean, `1` = Lead (the cascaded gain stage).
|
||
@UIParam public var channel: Double = 0.0
|
||
|
||
private let masterMinDrive: Double = 0.5
|
||
private let masterMaxDrive: Double = 5.0
|
||
/// Grid bias of the cascaded lead stage — a little asymmetry for even-harmonic grind.
|
||
private let leadBias: Double = 0.15
|
||
/// Channel-select threshold: `>= this` selects the Lead channel.
|
||
private let channelThreshold: Double = 0.5
|
||
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
|
||
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
|
||
|
||
public override var summaryText: String {
|
||
"British dual-channel master-volume — Clean/Lead switching, reverb, Presence, and Bright."
|
||
}
|
||
public override var signatureKnobs: [PedalKnob] {
|
||
super.signatureKnobs + [
|
||
PedalKnob(label: "Master", node: $master, range: signatureRange),
|
||
PedalKnob(label: "Drive", node: $drive, range: driveRange),
|
||
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
|
||
]
|
||
}
|
||
|
||
public override var effectSwitches: [PedalSwitch] {
|
||
super.effectSwitches + [
|
||
PedalSwitch(
|
||
label: "Channel",
|
||
node: $channel,
|
||
options: [
|
||
PedalSwitch.Option(title: "Clean", value: switchOffValue),
|
||
PedalSwitch.Option(title: "Lead", value: switchOnValue),
|
||
],
|
||
rebuildsOnChange: true
|
||
),
|
||
]
|
||
}
|
||
|
||
/// Master drives the power-amp stage. 4× oversampling since it can be driven hard.
|
||
public override var powerAmpDriveInput: any ValidGeneratorInput {
|
||
masterDrive($master, minDrive: masterMinDrive, maxDrive: masterMaxDrive)
|
||
}
|
||
public override var powerAmpOversample: Int { 4 }
|
||
|
||
/// Wider card for the extra Master/Drive/Reverb knobs plus the Bright and Channel switches.
|
||
public override var widthUnits: Int { 4 }
|
||
|
||
/// Creates a British Dual amp.
|
||
///
|
||
/// - Parameters:
|
||
/// - inputBus: Audio bus index to read the dry input from. Defaults to `0`.
|
||
/// - outputBus: Audio bus index to write the processed output to. Defaults to `0`.
|
||
public init(inputBus: Int = 0, outputBus: Int = 0) {
|
||
super.init(name: "British Dual", inputBus: inputBus, outputBus: outputBus)
|
||
gain = 5.0
|
||
cab = 1.0 // British 4×12
|
||
}
|
||
|
||
/// Clean preamp, plus a cascaded lead stage on the Lead channel. `channel` is read at
|
||
/// board-build time (the switch is `rebuildsOnChange`), so only the selected channel is built.
|
||
public override func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||
let clean: any ValidGeneratorInput = super.preampStage(signal)
|
||
guard channel >= channelThreshold else { return clean }
|
||
return TriodeStage(input: clean, drive: $drive, bias: leadBias, oversample: preampOversample)
|
||
}
|
||
|
||
/// Spring reverb in the onboard-effects slot (after the tone stack).
|
||
public override func onboardEffects(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
|
||
SpringReverb.Audio(input: signal, mix: $reverb, sampleRate: sampleRate)
|
||
}
|
||
}
|