Files
ShoeGaze/Sources/LyrebirdShoeGaze/Pedals/FullertonDriveAmpPedal.swift
T
josh da4d5e23ea feat(amps): channel-switch enabler + drive-channel amps (Phase 4)
Enabler:
- PedalSwitch.rebuildsOnChange (mirrors PedalSelectorKnob): a switch that changes
  graph topology asks the host to rebuild. Wired through PedalSwitchView (onCommit
  on a changed tap) and PedalView.switchRow → pedalRebuildAction.
- AmpVoicePedal.preampStage(_:) overridable hook (default: one TriodeStage at
  Gain). preCabinetCore feeds it; a channel amp cascades an extra stage on its
  drive channel. Named preampOversample constant (4).

Amps:
- Fullerton Drive — American two-channel combo: blackface Clean + an overdrive
  channel (cascaded TriodeStage set by Drive), spring reverb, Bright. Channel
  switch is rebuildsOnChange, so only the selected channel's stages are built.
- Jazz Clean — add the JC onboard Distortion channel (Clean/Dist switch + Drive
  knob) via the same preampStage cascade; flows through its stereo wideEffect.

Registered Fullerton Drive across 6 sites as .amp. 22 tests across the two amps
(channel switch changes output, drive knob, rebuildsOnChange, ceiling on the
drive channel, control surface, round-trip, registry).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-03 13:04:06 -07:00

110 lines
4.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// FullertonDriveAmpPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// American **two-channel combo** — a blackface-style clean plus a hotter overdrive channel, with
/// spring reverb and a Bright switch. The modern gigging combo (Hot Rod / Blues Jr. lineage).
///
/// The **Channel** switch selects Clean or Drive. On the Drive channel a second cascaded
/// ``TriodeStage`` (set by the `Drive` knob) is added ahead of the tone stack for preamp overdrive;
/// on Clean it is omitted entirely. Because the channel changes the graph topology the switch is
/// `rebuildsOnChange` — flipping it rebuilds the board (like the cab selector), so only the selected
/// channel's stages are ever built.
public final class FullertonDriveAmpPedal: AmpVoicePedal {
/// Spring-reverb wet mix in [0, 1].
@UIParam public var reverb: Double = 0.25
/// Drive-channel preamp gain (the cascaded overdrive stage). Range [1, 30].
@UIParam public var drive: Double = 8.0
/// Bright switch: `0` = flat, `1` = treble shelf engaged.
@UIParam public var bright: Double = 0.0
/// Channel select: `0` = Clean, `1` = Drive (the cascaded overdrive stage).
@UIParam public var channel: Double = 0.0
private let brightFreqHz: Double = 3200.0
private let brightMaxGainDb: Double = 6.0
private let brightSlope: Double = 1.0
/// Grid bias of the cascaded drive stage — a little asymmetry for even-harmonic grind.
private let driveBias: Double = 0.25
/// Channel-select threshold: `>= this` selects the Drive channel.
private let channelThreshold: Double = 0.5
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
private let cleanValue: Double = 0.0
private let driveValue: Double = 1.0
public override var toneStackModel: ToneStackModel { .fender }
public override var summaryText: String {
"American two-channel combo — blackface clean plus an overdrive channel, with reverb and Bright."
}
public override var signatureKnobs: [PedalKnob] {
[
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
PedalKnob(label: "Drive", node: $drive, range: driveRange),
]
}
/// Wider card for the Reverb/Drive knobs plus the Bright and Channel switches.
public override var widthUnits: Int { 3 }
public override var effectSwitches: [PedalSwitch] {
[
PedalSwitch(
label: "Bright",
node: $bright,
options: [
PedalSwitch.Option(title: "Off", value: cleanValue),
PedalSwitch.Option(title: "On", value: driveValue),
]
),
PedalSwitch(
label: "Channel",
node: $channel,
options: [
PedalSwitch.Option(title: "Clean", value: cleanValue),
PedalSwitch.Option(title: "Drive", value: driveValue),
],
rebuildsOnChange: true
),
]
}
/// Creates a Fullerton Drive 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: "Fullerton Drive", inputBus: inputBus, outputBus: outputBus)
gain = 4.0
cab = 0.0 // American 1×12
}
/// 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)
}
/// Clean preamp, plus a cascaded overdrive stage on the Drive channel. The `channel` value is
/// read at board-build time (the switch is `rebuildsOnChange`), so only the selected channel's
/// stages exist in the graph.
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: driveBias, 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)
}
}