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>
This commit is contained in:
2026-08-03 13:04:06 -07:00
parent 8cd77ad984
commit da4d5e23ea
12 changed files with 327 additions and 10 deletions
+10 -1
View File
@@ -54,6 +54,11 @@ public struct PedalSwitch {
/// to their first (off) option — while the tempo indicator is turned off. Defaults to `false`.
public let tempoDependent: Bool
/// When `true`, committing a new position asks the host to rebuild the board — for switches that
/// change the *graph topology* (e.g. a clean/drive channel that adds or removes a gain stage),
/// the same mechanism as ``PedalSelectorKnob/rebuildsOnChange``. Defaults to `false`.
public let rebuildsOnChange: Bool
/// Creates a switch descriptor.
///
/// - Parameters:
@@ -62,17 +67,21 @@ public struct PedalSwitch {
/// (`pedal.$mode`, `pedal.$direction`, …).
/// - options: Ordered switch positions, left to right. At least two.
/// - tempoDependent: `true` if the switch depends on the tempo/clock. Defaults to `false`.
/// - rebuildsOnChange: Ask the host to rebuild the board when a new position is committed. Use
/// for switches that change graph topology (e.g. a channel switch). Defaults to `false`.
public init(
label: String,
node: UIParamNode,
options: [Option],
tempoDependent: Bool = false
tempoDependent: Bool = false,
rebuildsOnChange: Bool = false
) {
precondition(options.count >= 2, "PedalSwitch requires at least two options")
self.label = label
self.node = node
self.options = options
self.tempoDependent = tempoDependent
self.rebuildsOnChange = rebuildsOnChange
}
/// The value of the next option after the one nearest `current`, wrapping to the first — so a
+1
View File
@@ -56,6 +56,7 @@ public extension PedalType {
static let fullertonReverb = PedalType("Fullerton Reverb")
static let fullertonDeluxe = PedalType("Fullerton Deluxe")
static let fullertonPrinceton = PedalType("Fullerton Princeton")
static let fullertonDrive = PedalType("Fullerton Drive")
static let jazzClean = PedalType("Jazz Clean")
static let chimeTopBoost = PedalType("Chime Top Boost")
static let neuralAmp = PedalType("Neural Amp")
@@ -85,6 +85,16 @@ open class AmpVoicePedal: Pedal {
signal
}
/// The preamp gain stage — the (post-`inputShaping`) input driven through the first tube stage
/// at `Gain`. Default: one `TriodeStage`. A channel-switching amp overrides this to cascade an
/// extra stage on its drive channel (call `super.preampStage(_:)` for the clean stage first).
///
/// - Parameter signal: The post-`inputShaping` input signal.
/// - Returns: The preamp output fed into the tone stack.
open func preampStage(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
TriodeStage(input: signal, drive: $gain, bias: preampBias, oversample: preampOversample)
}
/// Drive into the power-amp `TriodeStage`. Defaults to the fixed power-amp drive. Two kinds of
/// amp override it: a **master-volume** amp returns a live `Master` knob mapped to a drive range
/// (turning Master up pushes the power-amp stage into saturation — the real master-volume
@@ -105,6 +115,8 @@ open class AmpVoicePedal: Pedal {
private static let defaultMix: Double = 1.0
/// Preamp grid bias — a little asymmetry for even-harmonic warmth.
private let preampBias: Double = 0.2
/// Oversampling factor for the preamp stage (4× — the preamp can be driven hard by `Gain`).
let preampOversample: Int = 4
/// Fixed power-amp stage drive/bias (gentler than the preamp).
private let powerAmpDrive: Double = 1.5
private let powerAmpBias: Double = 0.0
@@ -211,7 +223,7 @@ open class AmpVoicePedal: Pedal {
/// - Returns: The post-power-amp, pre-cabinet mono signal.
func preCabinetCore(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
let preShaped: any ValidGeneratorInput = inputShaping(dry)
let preamp: TriodeStage = TriodeStage(input: preShaped, drive: $gain, bias: preampBias, oversample: 4)
let preamp: any ValidGeneratorInput = preampStage(preShaped)
let toned: ToneStack = ToneStack(
input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel)
let processed: any ValidGeneratorInput = onboardEffects(toned)
@@ -0,0 +1,109 @@
// 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)
}
}
@@ -38,6 +38,10 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
@UIParam public var bright: Double = 0.0
/// Chorus footswitch: `1` = chorus engaged (stereo), `0` = bypassed (dry, mono-equivalent).
@UIParam public var chorusEnabled: Double = 1.0
/// Drive-channel preamp gain (the onboard distortion). Range [1, 30].
@UIParam public var drive: Double = 8.0
/// Channel select: `0` = Clean, `1` = Distortion (the cascaded onboard-distortion stage).
@UIParam public var channel: Double = 0.0
// MARK: - Constants
@@ -50,9 +54,15 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
/// Fixed chorus wet/dry blend when the chorus is engaged (the amp has no chorus-mix knob).
private let chorusMixValue: Double = 0.5
/// Grid bias of the cascaded distortion stage — solid-state-flavoured, near-symmetric.
private let driveBias: Double = 0.1
/// Channel-select threshold: `>= this` selects the Distortion channel.
private let channelThreshold: Double = 0.5
private let reverbRange: ClosedRange<Double> = 0.0 ... 1.0
private let chorusRateRange: ClosedRange<Double> = 0.1 ... 5.0
private let chorusDepthRange: ClosedRange<Double> = 0.0005 ... 0.015
private let driveRange: ClosedRange<Double> = 1.0 ... 30.0
private let switchOffValue: Double = 0.0
private let switchOnValue: Double = 1.0
@@ -60,13 +70,14 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
public override var toneStackModel: ToneStackModel { .fender }
public override var summaryText: String {
"Solid-state clean — lush stereo chorus, spring reverb, and a Bright switch."
"Solid-state clean — lush stereo chorus, spring reverb, a Bright switch, and a Distortion channel."
}
public override var signatureKnobs: [PedalKnob] {
[
PedalKnob(label: "Reverb", node: $reverb, range: reverbRange),
PedalKnob(label: "Rate", node: $chorusRate, range: chorusRateRange),
PedalKnob(label: "Depth", node: $chorusDepth, range: chorusDepthRange),
PedalKnob(label: "Drive", node: $drive, range: driveRange),
]
}
@@ -109,9 +120,27 @@ public final class JazzCleanAmpPedal: AmpVoicePedal {
PedalSwitch.Option(title: "On", value: switchOnValue),
]
),
PedalSwitch(
label: "Channel",
node: $channel,
options: [
PedalSwitch.Option(title: "Clean", value: switchOffValue),
PedalSwitch.Option(title: "Dist", value: switchOnValue),
],
rebuildsOnChange: true
),
]
}
/// Clean preamp, plus the onboard-distortion stage on the Distortion 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)
}
// MARK: - Hooks
/// Bright switch: a high-shelf lift ahead of the preamp (identity when off, live, no rebuild).
@@ -43,6 +43,7 @@ public enum PedalRegistry {
"Fullerton Reverb": { FullertonReverbAmpPedal() },
"Fullerton Deluxe": { FullertonDeluxeAmpPedal() },
"Fullerton Princeton": { FullertonPrincetonAmpPedal() },
"Fullerton Drive": { FullertonDriveAmpPedal() },
"Jazz Clean": { JazzCleanAmpPedal() },
"Chime Top Boost": { ChimeTopBoostAmpPedal() },
"Neural Amp": { NeuralAmpPedal() },