feat(amps): split combined Amp pedal into California/British/Chime voices

Replace the single AmpPedal (a model-selector pedal) with three dedicated
amp-voice blocks, each fixing one tone-stack model and adding a signature
control so the per-amp UI can be customized:

- AmpVoicePedal: open base — shared Gain/Bass/Mid/Treble/Cab chain
  (TriodeStage preamp → ToneStack → TriodeStage power amp → shapeVoice →
  ConvolutionReverb cab), overridable toneStackModel/summary/signatureKnobs/
  shapeVoice.
- CaliforniaAmpPedal (.fender): Bright high-shelf, clean-leaning gain default.
- BritishAmpPedal (.marshall): Presence high-shelf, crunch gain default.
- ChimeAmpPedal (.vox): Cut low-pass, top-boost jangle.

Registered in PedalRegistry / PedalType / PedalCategory / palette order /
enclosure colors. Help acknowledgment updated for the three tone stacks.
12 new tests in AmpVoicePedalTests; removed AmpPedal + its tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-02 14:47:07 -07:00
parent 23d607b9fc
commit 1b247cf766
14 changed files with 462 additions and 291 deletions
+3 -1
View File
@@ -44,7 +44,9 @@ public struct PedalType: RawRepresentable, Hashable, Sendable {
public extension PedalType {
// Drive & dynamics
static let amp = PedalType("Amp")
static let california = PedalType("California")
static let british = PedalType("British")
static let chime = PedalType("Chime")
static let neuralAmp = PedalType("Neural Amp")
static let overdrive = PedalType("Overdrive")
static let distortion = PedalType("Distortion")
@@ -1,172 +0,0 @@
// AmpPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// A full component-style guitar amp: preamp tube stage → tone stack → power-amp tube stage →
/// speaker cabinet, all white-box (no neural capture).
///
/// Signal chain (inside `effect(_:)`):
/// ```
/// dry → TriodeStage(drive: gain) (preamp)
/// → ToneStack(bass, mid, treble, model) (tone stack — Fender/Marshall/Vox, live-selectable)
/// → TriodeStage(power-amp drive) (power-amp warmth)
/// → ConvolutionReverb(cab IR) (speaker cabinet — live-selectable voice)
/// → mono out
/// ```
///
/// The tone-stack model and cabinet voice are each built once per option at `build()` and picked
/// live with a `Select` (so both round-trip through the rig save format). The amp is fully wet;
/// `Level` is the master volume. Built on Lyrebird 1.7's `TriodeStage` / `ToneStack` plus
/// ShoeGaze's synthesized cabinet IRs.
///
/// > Note: `Select` evaluates *all* its inputs every block (SC parity — keeps state in sync), so
/// > every tone-stack model **and** every cabinet convolver runs continuously, not just the
/// > selected one. That is a few extra IIRs plus one partitioned-FFT convolver per unselected
/// > cabinet voice — a real (but bounded) CPU cost that scales with the number of voices. The
/// > cabinet IRs are synthesized at `build()` for the injected `sampleRate`; a live engine
/// > sample-rate change takes effect on the next rebuild.
///
/// ## Parameters
///
/// Inherits `bypass` and `level` (master) from `Pedal`, plus:
///
/// - `gain`: Preamp drive. Range `[1, 30]`.
/// - `bass` / `mid` / `treble`: Tone-stack controls in `[0, 1]`.
/// - `amp`: Tone-stack model (Fender / Marshall / Vox).
/// - `cab`: Speaker-cabinet voice.
public final class AmpPedal: Pedal {
/// One-line description shown in the picker and info panel.
public override var summary: String {
"Full tube amp — preamp, tone stack, power amp, and speaker cabinet in one."
}
/// The amp is fully wet (it replaces the dry signal); hide the Mix control.
public override var showsMixControl: Bool { false }
/// Amp-head-style double-width card so the four tone knobs plus the Amp / Cab selectors and
/// master lay out with room, rather than cramping into a single-width stompbox.
public override var widthUnits: Int { 2 }
// MARK: - Parameters
/// Preamp drive into the first tube stage. Range [1, 30].
@UIParam public var gain: Double = 6.0
/// Tone-stack bass control in [0, 1].
@UIParam public var bass: Double = 0.5
/// Tone-stack mid control in [0, 1].
@UIParam public var mid: Double = 0.5
/// Tone-stack treble control in [0, 1].
@UIParam public var treble: Double = 0.6
/// Selected tone-stack model as an index into `ToneStackModel.allCases`.
@UIParam public var amp: Double = 0.0
/// Selected cabinet voice as an index into `CabinetVoice.allCases`.
@UIParam public var cab: Double = 0.0
// MARK: - Constants
private static let defaultMix: Double = 1.0
/// Preamp grid bias — a little asymmetry for even-harmonic warmth.
private let preampBias: Double = 0.2
/// Fixed power-amp stage drive and bias (gentler than the preamp).
private let powerAmpDrive: Double = 1.5
private let powerAmpBias: Double = 0.0
/// Fully-wet convolution; the base class provides bypass and master level.
private let cabinetMix: Double = 1.0
/// Gain knob range.
private let gainRange: ClosedRange<Double> = 1.0 ... 30.0
private let toneRange: ClosedRange<Double> = 0.0 ... 1.0
private static let ampStops: [PedalSelectorKnob.Stop] = ToneStackModel.allCases
.enumerated()
.map { (index: Int, model: ToneStackModel) in
PedalSelectorKnob.Stop(title: model.displayName, value: Double(index))
}
private static let cabStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
.enumerated()
.map { (index: Int, voice: CabinetVoice) in
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
}
// MARK: - Init
/// Creates an amp pedal.
///
/// - 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: "Amp",
inputBus: inputBus,
outputBus: outputBus,
initialMix: AmpPedal.defaultMix
)
}
// MARK: - UI
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Gain", node: $gain, range: gainRange),
PedalKnob(label: "Bass", node: $bass, range: toneRange),
PedalKnob(label: "Mid", node: $mid, range: toneRange),
PedalKnob(label: "Treble", node: $treble, range: toneRange),
]
}
public override var effectSelectors: [PedalSelectorKnob] {
[
PedalSelectorKnob(label: "Amp", node: $amp, stops: AmpPedal.ampStops),
PedalSelectorKnob(label: "Cab", node: $cab, stops: AmpPedal.cabStops),
]
}
// MARK: - Effect
/// Preamp → tone stack (model-selected) → power amp → cabinet (voice-selected).
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: The amped, cab-convolved mono output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
let sr: Double = sampleRate
// Preamp tube stage.
let preamp: TriodeStage = TriodeStage(input: dry, drive: $gain, bias: preampBias, oversample: 4)
// Tone stack — one per model, picked live.
let toneStacks: [any ValidGeneratorInput] = ToneStackModel.allCases.map { (model: ToneStackModel) in
ToneStack(input: preamp, bass: $bass, mid: $mid, treble: $treble, model: model)
}
let toned: Select.Audio = Select.Audio(which: $amp, inputs: toneStacks)
// Power-amp tube stage (fixed, gentle).
let powerAmp: TriodeStage = TriodeStage(input: toned, drive: powerAmpDrive, bias: powerAmpBias, oversample: 2)
// Speaker cabinet — one convolver per voice, picked live.
let cabinets: [any ValidGeneratorInput] = CabinetVoice.allCases.map { (voice: CabinetVoice) in
ConvolutionReverb.Audio(
input: powerAmp,
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sr),
mix: cabinetMix
)
}
return Select.Audio(which: $cab, inputs: cabinets)
}
}
@@ -0,0 +1,150 @@
// AmpVoicePedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Shared base for the fixed-voicing amp pedals (California / British / Chime).
///
/// Each concrete amp fixes one tone-stack ``ToneStackModel`` and adds one signature control, but
/// shares the common chain built here:
/// ```
/// dry → TriodeStage(drive: gain) (preamp)
/// → ToneStack(bass, mid, treble, model) (fixed per amp)
/// → TriodeStage(power-amp drive) (power-amp warmth)
/// → shapeVoice(_:) (subclass signature filter)
/// → ConvolutionReverb(cab IR) (speaker cabinet — live-selectable voice)
/// ```
/// Fully wet (the amp replaces the dry signal); `Level` is the master. Double-width amp-head card.
///
/// Subclasses override ``toneStackModel``, ``summaryText``, ``signatureKnobs``, and
/// ``shapeVoice(_:)``, and may set a voice-appropriate default `gain` in their `init`.
open class AmpVoicePedal: Pedal {
// MARK: - Common parameters
/// Preamp drive into the first tube stage. Range [1, 30].
@UIParam public var gain: Double = 6.0
/// Tone-stack bass control in [0, 1].
@UIParam public var bass: Double = 0.5
/// Tone-stack mid control in [0, 1].
@UIParam public var mid: Double = 0.5
/// Tone-stack treble control in [0, 1].
@UIParam public var treble: Double = 0.6
/// Selected cabinet voice as an index into `CabinetVoice.allCases`.
@UIParam public var cab: Double = 0.0
// MARK: - Subclass configuration
/// The fixed tone-stack model for this amp voice. Subclasses override.
open var toneStackModel: ToneStackModel { .fender }
/// One-line description. Subclasses override.
open var summaryText: String { "Tube amp." }
/// The amp's signature knob(s), appended after Gain/Bass/Mid/Treble. Default none.
open var signatureKnobs: [PedalKnob] { [] }
/// Applies the amp's signature post-power-amp shaping (e.g. a bright/presence shelf or a cut
/// low-pass). Default: identity. Subclasses override.
///
/// - Parameter signal: The post-power-amp signal.
/// - Returns: The shaped signal fed to the cabinet.
open func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
signal
}
// MARK: - Constants
private static let defaultMix: Double = 1.0
/// Preamp grid bias — a little asymmetry for even-harmonic warmth.
private let preampBias: Double = 0.2
/// Fixed power-amp stage drive/bias (gentler than the preamp).
private let powerAmpDrive: Double = 1.5
private let powerAmpBias: Double = 0.0
private let cabinetMix: Double = 1.0
let gainRange: ClosedRange<Double> = 1.0 ... 30.0
let toneRange: ClosedRange<Double> = 0.0 ... 1.0
/// Range for a signature control that maps [0, 1] (Bright / Presence / Cut amount).
let signatureRange: ClosedRange<Double> = 0.0 ... 1.0
private static let cabStops: [PedalSelectorKnob.Stop] = CabinetVoice.allCases
.enumerated()
.map { (index: Int, voice: CabinetVoice) in
PedalSelectorKnob.Stop(title: voice.displayName, value: Double(index))
}
// MARK: - Chrome
/// The amp is fully wet (it replaces the dry signal); hide the Mix control.
public override var showsMixControl: Bool { false }
/// Amp-head-style double-width card.
public override var widthUnits: Int { 2 }
public override var summary: String { summaryText }
// MARK: - Init
/// Creates an amp voice pedal.
///
/// - Parameters:
/// - name: Display name (the amp voice, e.g. "California").
/// - 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(
name: String,
inputBus: Int = 0,
outputBus: Int = 0
) {
super.init(
name: name,
inputBus: inputBus,
outputBus: outputBus,
initialMix: AmpVoicePedal.defaultMix
)
}
// MARK: - UI
public override var effectKnobs: [PedalKnob] {
[
PedalKnob(label: "Gain", node: $gain, range: gainRange),
PedalKnob(label: "Bass", node: $bass, range: toneRange),
PedalKnob(label: "Mid", node: $mid, range: toneRange),
PedalKnob(label: "Treble", node: $treble, range: toneRange),
] + signatureKnobs
}
public override var effectSelectors: [PedalSelectorKnob] {
[
PedalSelectorKnob(label: "Cab", node: $cab, stops: AmpVoicePedal.cabStops),
]
}
// MARK: - Effect
/// Preamp → fixed tone stack → power amp → signature shaping → cabinet (voice-selected).
///
/// - Parameter dry: Dry mono input signal.
/// - Returns: The amped, cab-convolved mono output.
public override func effect(_ dry: any ValidGeneratorInput) -> any ValidGeneratorInput {
let sr: Double = sampleRate
let preamp: TriodeStage = TriodeStage(input: dry, drive: $gain, bias: preampBias, oversample: 4)
let toned: ToneStack = ToneStack(
input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel)
let powerAmp: TriodeStage = TriodeStage(
input: toned, drive: powerAmpDrive, bias: powerAmpBias, oversample: 2)
let shaped: any ValidGeneratorInput = shapeVoice(powerAmp)
let cabinets: [any ValidGeneratorInput] = CabinetVoice.allCases.map { (voice: CabinetVoice) in
ConvolutionReverb.Audio(
input: shaped,
ir: CabinetIRFactory.makeIR(voice: voice, sampleRate: sr),
mix: cabinetMix
)
}
return Select.Audio(which: $cab, inputs: cabinets)
}
}
@@ -0,0 +1,46 @@
// BritishAmpPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// British-voiced amp (mid-forward crunch) with a **Presence** upper-high lift control.
///
/// A ``AmpVoicePedal`` fixed to the British tone stack, defaulting to a higher gain for crunch.
public final class BritishAmpPedal: AmpVoicePedal {
/// Presence amount in [0, 1] → 0…`presenceMaxGainDb` of lift above `presenceFreqHz`.
@UIParam public var presence: Double = 0.4
private let presenceFreqHz: Double = 4500.0
private let presenceMaxGainDb: Double = 8.0
private let shelfSlope: Double = 0.7
public override var toneStackModel: ToneStackModel { .marshall }
public override var summaryText: String {
"British crunch — forward mids and bite, with a Presence lift."
}
public override var signatureKnobs: [PedalKnob] {
[PedalKnob(label: "Presence", node: $presence, range: signatureRange)]
}
/// Creates a British 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", inputBus: inputBus, outputBus: outputBus)
gain = 10.0 // crunch-leaning default
cab = 1.0 // default to the British 4×12 cab
}
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: shelfSlope)
}
}
@@ -0,0 +1,45 @@
// CaliforniaAmpPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// American-voiced amp (scooped-mid, bright clean) with a **Bright** high-shelf sparkle control.
///
/// A ``AmpVoicePedal`` fixed to the American tone stack, defaulting to a lower gain for headroom.
public final class CaliforniaAmpPedal: AmpVoicePedal {
/// Bright high-shelf amount in [0, 1] → 0…`brightMaxGainDb` of lift above `brightFreqHz`.
@UIParam public var bright: Double = 0.3
private let brightFreqHz: Double = 3200.0
private let brightMaxGainDb: Double = 6.0
private let shelfSlope: Double = 1.0
public override var toneStackModel: ToneStackModel { .fender }
public override var summaryText: String {
"American clean — scooped mids, glassy top, with a Bright sparkle shelf."
}
public override var signatureKnobs: [PedalKnob] {
[PedalKnob(label: "Bright", node: $bright, range: signatureRange)]
}
/// Creates a California 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: "California", inputBus: inputBus, outputBus: outputBus)
gain = 4.0 // clean-leaning default
}
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
let gainDB: LinLin.Audio = LinLin.Audio(
$bright, inLo: 0.0, inHi: 1.0, outLo: 0.0, outHi: brightMaxGainDb)
return RBJHighShelf.Audio(input: signal, freq: brightFreqHz, gain: gainDB, slope: shelfSlope)
}
}
@@ -0,0 +1,48 @@
// ChimeAmpPedal.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Chimey/jangly amp (bell-like top boost) with a **Cut** control that rolls off the high end as
/// it's turned up — the classic top-boost "Cut" behavior.
///
/// A ``AmpVoicePedal`` fixed to the chime tone stack.
public final class ChimeAmpPedal: AmpVoicePedal {
/// Cut amount in [0, 1]: `0` = fully open/bright, `1` = darkest. Maps to a low-pass cutoff
/// swept from `cutOpenHz` down to `cutDarkHz`.
@UIParam public var cut: Double = 0.2
private let cutOpenHz: Double = 9000.0
private let cutDarkHz: Double = 2500.0
private let cutQ: Double = 0.707
public override var toneStackModel: ToneStackModel { .vox }
public override var summaryText: String {
"Chimey top-boost jangle with a Cut control that tames the highs."
}
public override var signatureKnobs: [PedalKnob] {
[PedalKnob(label: "Cut", node: $cut, range: signatureRange)]
}
/// Creates a Chime 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: "Chime", inputBus: inputBus, outputBus: outputBus)
gain = 5.0
}
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
// cut 0 → cutOpenHz (bright), cut 1 → cutDarkHz (dark).
let cutoff: LinLin.Audio = LinLin.Audio(
$cut, inLo: 0.0, inHi: 1.0, outLo: cutOpenHz, outHi: cutDarkHz)
return RBJLowPass.Audio(input: signal, freq: cutoff, q: cutQ)
}
}
@@ -31,7 +31,9 @@ public enum PedalRegistry {
/// `ShoeGaze.loadRig(from:)` updates `inputBus`/`outputBus` when adding the pedal
/// to a board via `board.add(_:)`.
public static let builtIn: [String: @MainActor () -> Pedal] = [
"Amp": { AmpPedal() },
"California": { CaliforniaAmpPedal() },
"British": { BritishAmpPedal() },
"Chime": { ChimeAmpPedal() },
"Neural Amp": { NeuralAmpPedal() },
"Overdrive": { OverdrivePedal() },
"Distortion": { DistortionPedal() },