feat(amp): shared power-amp Sag + Bias in an advanced pop-over

Phase 11. Promote Sag from Modern High-Gain to a shared AmpVoicePedal
capability and add a Bias control, both surfaced in a new pedal-card
pop-over rather than on the amp face.

- AmpVoicePedal gains `sag` [0,1] (AmplitudeFollower gain-droop, clamped
  [0.15,1] to prevent phase inversion) and `bias` [0,1] mapped to the
  power-amp TriodeStage grid bias ([-0.25,0.25], neutral 0.5 → 0.0 so
  existing voices are unchanged at defaults). Both applied in
  preCabinetCore; new `applySag(_:)` + `powerAmpBiasInput` helpers.
- Modern High-Gain drops its bespoke sag (now inherited); keeps sag=0.3
  default. Sag moves off its face into the pop-over.
- Pedal gains an `advancedKnobs` surface; PedalView draws a gear button
  (top-right) presenting them in a popover, reusing the existing pattern.
- Advanced knobs round-trip through PedalState (new `advancedValues`,
  backward-compatible decode) and are MIDI-CC-mappable (appended last).

De-branding (review nits): "Vox" removed from the Chime family's
user-visible summaries + docs; "Fullerton Princeton" renamed to display
"Fullerton Ivy League". Palette horizontal picker second row now shows
Routing before the Amp Model group.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-03 21:08:23 -07:00
parent 6cf698dbac
commit 1de14fd879
18 changed files with 273 additions and 77 deletions
+21 -5
View File
@@ -237,6 +237,17 @@ open class Pedal: SynthesizerBase {
[]
}
/// Secondary "advanced" knobs that read best tucked behind a pop-over rather than on the pedal
/// face — deep-cut controls a player reaches for occasionally, not while performing (e.g. an
/// amp's power-amp Sag / Bias / Bias X). When non-empty the pedal card shows a small button that
/// presents these in a popover; when empty no button is drawn. Defaults to empty.
///
/// These are ordinary live `@UIParam` knobs — they round-trip through `PedalState` and are not
/// topology controls (no `rebuildsOnChange`).
open var advancedKnobs: [PedalKnob] {
[]
}
/// Current values of every ``effectSelectors`` and ``effectSwitches`` entry flagged
/// `rebuildsOnChange` — the controls whose choice changes the graph topology (e.g. a cabinet
/// voice or a clean/drive channel). A lightweight recall compares this before/after applying a
@@ -283,11 +294,13 @@ open class Pedal: SynthesizerBase {
}
/// Every continuous control on this pedal that a MIDI Control Change can drive — the pedal's
/// knobs (effect knobs + Mix + Level) followed by its vertical-fader sliders. Discrete controls
/// (switches, stepped selectors) are excluded; they suit Program Change toggles, not CC sweeps.
/// knobs (effect knobs + Mix + Level), then its vertical-fader sliders, then its advanced
/// (pop-over) knobs. Discrete controls (switches, stepped selectors) are excluded; they suit
/// Program Change toggles, not CC sweeps.
///
/// Ordering is stable — knobs first, then sliders — so a persisted CC binding addressed by index
/// keeps resolving to the same control across launches. Used by MIDI mapping.
/// Ordering is stable — knobs, then sliders, then advanced knobs (appended last so existing
/// index-addressed CC bindings keep resolving to the same control across launches). Used by MIDI
/// mapping.
public var ccMappableControls: [PedalControl] {
let knobControls: [PedalControl] = knobs.map {
PedalControl(label: $0.label, node: $0.node, range: $0.range)
@@ -295,7 +308,10 @@ open class Pedal: SynthesizerBase {
let sliderControls: [PedalControl] = effectSliders.map {
PedalControl(label: $0.label, node: $0.node, range: $0.range)
}
return knobControls + sliderControls
let advancedControls: [PedalControl] = advancedKnobs.map {
PedalControl(label: $0.label, node: $0.node, range: $0.range)
}
return knobControls + sliderControls + advancedControls
}
// MARK: - Tempo sync
+1 -1
View File
@@ -66,7 +66,7 @@ public extension PedalType {
static let chimeBaby = PedalType("Chime Baby")
static let fullertonReverb = PedalType("Fullerton Reverb")
static let fullertonDeluxe = PedalType("Fullerton Deluxe")
static let fullertonPrinceton = PedalType("Fullerton Princeton")
static let fullertonPrinceton = PedalType("Fullerton Ivy League")
static let fullertonDrive = PedalType("Fullerton Drive")
static let jazzClean = PedalType("Jazz Clean")
static let chimeTopBoost = PedalType("Chime Top Boost")
@@ -48,6 +48,14 @@ open class AmpVoicePedal: Pedal {
@UIParam public var treble: Double = 0.6
/// Selected cabinet voice as an index into `CabinetVoice.allCases`.
@UIParam public var cab: Double = 0.0
/// Power-amp **Sag** in `[0, 1]`: `0` = stiff (no droop), `1` = heavy power-supply sag/bloom.
/// Surfaced in the advanced pop-over, not on the pedal face. See ``applySag(_:)``.
@UIParam public var sag: Double = 0.0
/// Power-amp **Bias** in `[0, 1]`, mapped to the power-amp `TriodeStage` grid bias. `0.5` = the
/// neutral (symmetric) operating point; lower = colder (tighter, more odd harmonics), higher =
/// hotter (warmer, more even harmonics). Surfaced in the advanced pop-over. See
/// ``powerAmpBiasInput``.
@UIParam public var bias: Double = 0.5
// MARK: - Subclass configuration
@@ -153,6 +161,31 @@ open class AmpVoicePedal: Pedal {
/// power stage of the standard voices).
open var powerAmpOversample: Int { 2 }
/// Grid bias fed to the power-amp `TriodeStage`, from the live `Bias` knob: `[0, 1]` mapped to
/// `[coldPowerAmpBias, hotPowerAmpBias]`. The neutral `bias = 0.5` maps to `0.0`, so the default
/// leaves the power-amp stage symmetric (unchanged from the old fixed bias).
var powerAmpBiasInput: any ValidGeneratorInput {
LinLin.Audio($bias, inLo: 0.0, inHi: 1.0, outLo: coldPowerAmpBias, outHi: hotPowerAmpBias)
}
/// Applies power-supply **Sag**: an `AmplitudeFollower` on `signal` reduces gain as it gets loud
/// (droop) and recovers slowly (bloom). `Sag` scales the depth; at `sag = 0` the droop is `0` and
/// the gain is a constant `1.0` (an identity multiply), so a sag-less amp is unchanged.
///
/// The droop gain is clamped to `[sagGainFloor, 1]`: the envelope tracks a post-power-amp,
/// post-`shapeVoice` signal that can exceed 1 (Presence/Depth shelves), so an unclamped
/// `1 − sag·env` would go negative and phase-invert loud content instead of attenuating it.
///
/// - Parameter signal: The post-`shapeVoice` signal to apply sag to.
/// - Returns: The sagged signal.
func applySag(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
in: signal, attackTime: sagAttackSeconds, releaseTime: sagReleaseSeconds)
let sagGain: any ValidGeneratorInput = Clip.Audio(
1.0 - ($sag * envelope), lo: sagGainFloor, hi: 1.0)
return signal * sagGain
}
// MARK: - Constants
private static let defaultMix: Double = 1.0
@@ -166,9 +199,22 @@ open class AmpVoicePedal: Pedal {
/// Generic `PedalSwitch` off / on values, shared by every amp that publishes switches.
let switchOffValue: Double = 0.0
let switchOnValue: Double = 1.0
/// Fixed power-amp stage drive/bias (gentler than the preamp).
/// Fixed power-amp stage drive (gentler than the preamp).
private let powerAmpDrive: Double = 1.5
private let powerAmpBias: Double = 0.0
/// Power-amp grid bias at `bias = 0` (coldest) and `bias = 1` (hottest). Symmetric about `0`, so
/// the neutral `bias = 0.5` maps to `0.0` — the old fixed power-amp bias — leaving every amp's
/// default tone unchanged. Modest magnitude so the control colours the harmonics without
/// drastically re-voicing the amp.
private let coldPowerAmpBias: Double = -0.25
private let hotPowerAmpBias: Double = 0.25
/// Sag envelope-follower attack — moderately fast (the supply starts drooping under load).
private let sagAttackSeconds: Double = 0.02
/// Sag envelope-follower release — slow, so the sag lingers and blooms back (supply recovery).
private let sagReleaseSeconds: Double = 0.30
/// Lowest the sag gain can droop to (~-16 dB). Bounds sag depth and — crucially — keeps the gain
/// strictly positive: the envelope tracks a post-shelf signal that can exceed 1, so an unclamped
/// `1 − sag·env` would go negative and phase-invert loud content instead of drooping.
private let sagGainFloor: Double = 0.15
private let cabinetMix: Double = 1.0
/// Output soft-limit drive. `1.0` gives unit small-signal gain (clean playing untouched) with a
/// hard `tanh` asymptote at ±1 — models output-transformer / speaker compression and keeps the
@@ -243,6 +289,16 @@ open class AmpVoicePedal: Pedal {
]
}
/// Power-amp deep-cut controls, tucked behind the pedal card's advanced pop-over: **Sag**
/// (power-supply droop/bloom) and **Bias** (power-amp grid-bias operating point). Neither is a
/// topology control — both are live nodes that round-trip through the rig save format.
public override var advancedKnobs: [PedalKnob] {
[
PedalKnob(label: "Sag", node: $sag, range: signatureRange),
PedalKnob(label: "Bias", node: $bias, range: toneRange),
]
}
// MARK: - Effect
/// Preamp → fixed tone stack → power amp → signature shaping → cabinet → output soft-limit.
@@ -277,8 +333,8 @@ open class AmpVoicePedal: Pedal {
input: preamp, bass: $bass, mid: $mid, treble: $treble, model: toneStackModel)
let processed: any ValidGeneratorInput = onboardEffects(toned)
let powerAmp: TriodeStage = TriodeStage(
input: processed, drive: powerAmpDriveInput, bias: powerAmpBias, oversample: powerAmpOversample)
return shapeVoice(powerAmp)
input: processed, drive: powerAmpDriveInput, bias: powerAmpBiasInput, oversample: powerAmpOversample)
return applySag(shapeVoice(powerAmp))
}
/// The per-channel cabinet + output stage: the selected `CabinetVoice` convolver → `tanh`
@@ -10,8 +10,8 @@ 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. The base of the Vox-voiced family — the
/// AC-style variants (Chime 15 / Chime Normal / Chime Baby) subclass it and differ by gain, cab,
/// A ``AmpVoicePedal`` fixed to the chime tone stack. The base of the chime-voiced family — the
/// EL84-combo variants (Chime 15 / Chime Normal / Chime Baby) subclass it and differ by gain, cab,
/// and tone defaults (and, for the smaller combos, an earlier power-amp breakup).
open class ChimeAmpPedal: AmpVoicePedal {
@@ -7,7 +7,7 @@
import LyrebirdSynth
import LyrebirdUI
/// Vox-voiced **practice combo** — the tiny AC4/AC10-style amp: low headroom, a small boxy
/// Chime-family **practice combo** — the tiny, low-power amp: low headroom, a small boxy
/// speaker, and the earliest breakup of the chime family.
///
/// A ``ChimeAmpPedal`` (Cut voice) driven hardest into the power stage, with the small lo-fi cab.
@@ -17,7 +17,7 @@ public final class ChimeBabyAmpPedal: ChimeAmpPedal {
private let babyPowerDrive: Double = 2.5
public override var summaryText: String {
"Vox practice combo — tiny, boxy, earliest-breakup chime with a Cut control."
"Chime-style practice combo — tiny, boxy, earliest-breakup chime with a Cut control."
}
/// Driven hardest of the chime family, so 4× oversampling for anti-alias headroom.
@@ -7,7 +7,7 @@
import LyrebirdSynth
import LyrebirdUI
/// Vox-voiced **1×12 EL84 combo** — the lower-powered, earlier-breakup sibling of the AC top-boost
/// Chime-family **1×12 EL84 combo** — the lower-powered, earlier-breakup sibling of the top-boost
/// voice. Chimey but grittier: the small power section saturates sooner.
///
/// A ``ChimeAmpPedal`` (Cut voice) with a higher fixed power-amp drive and a bright cab.
@@ -17,7 +17,7 @@ public final class ChimeFifteenAmpPedal: ChimeAmpPedal {
private let fifteenPowerDrive: Double = 2.0
public override var summaryText: String {
"Vox 1×12 EL84 combo — chimey but earlier-breakup, with a Cut control."
"Chime-style 1×12 EL84 combo — chimey but earlier-breakup, with a Cut control."
}
/// Driven harder than the base, so 4× oversampling for anti-alias headroom.
@@ -7,15 +7,15 @@
import LyrebirdSynth
import LyrebirdUI
/// Vox-voiced **Normal channel** — the AC30's non-top-boost side: warmer and rounder than the
/// bright top-boost voice, with the same high clean headroom.
/// Chime-family **Normal channel** — the big combo's non-top-boost side: warmer and rounder than
/// the bright top-boost voice, with the same high clean headroom.
///
/// A ``ChimeAmpPedal`` (Cut voice) voiced darker (lower treble default, a touch more Cut) to stand
/// in for the plainer Normal-channel EQ.
public final class ChimeNormalAmpPedal: ChimeAmpPedal {
public override var summaryText: String {
"Vox Normal channel — warm, round, high-headroom chime with a Cut control."
"Chime Normal channel — warm, round, high-headroom chime with a Cut control."
}
/// Creates a Chime Normal amp.
@@ -26,13 +26,13 @@ public final class FullertonPrincetonAmpPedal: FullertonReverbAmpPedal {
public override var powerAmpOversample: Int { 4 }
public override var powerAmpDriveInput: any ValidGeneratorInput { princetonPowerDrive }
/// Creates a Fullerton Princeton amp.
/// Creates a Fullerton Ivy League 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 Princeton", inputBus: inputBus, outputBus: outputBus)
super.init(name: "Fullerton Ivy League", inputBus: inputBus, outputBus: outputBus)
gain = 5.0 // hotter still — the small combo grits up soonest
bass = 0.4 // least low end of the trio
treble = 0.55 // a shade darker
@@ -17,36 +17,21 @@ import LyrebirdUI
/// tube-rectified amp. **Tight** high-passes the input to tighten the low end for fast riffing.
public final class ModernHighGainAmpPedal: BoutiqueAmpPedal {
/// Sag amount in [0, 1]: `0` = stiff (no droop), `1` = heavy power-supply sag/bloom.
@UIParam public var sag: Double = 0.3
/// Tight switch: `0` = full low end, `1` = low-cut engaged (tight riffing).
@UIParam public var tight: Double = 0.0
/// Sag envelope-follower attack — moderately fast (the supply starts drooping under load).
private let sagAttackSeconds: Double = 0.02
/// Sag envelope-follower release — slow, so the sag lingers and blooms back (supply recovery).
private let sagReleaseSeconds: Double = 0.30
/// Tight low-cut: high-pass corner is ~20 Hz (loose, no cut) or `tightFreqHz` (tight).
private let tightLooseFreqHz: Double = 20.0
/// Tight-switch-on high-pass corner in Hz.
private let tightFreqHz: Double = 120.0
/// Tight high-pass Q (Butterworth).
private let tightQ: Double = 0.707
/// Lowest the sag gain can droop to (~-16 dB — the deepest droop before the tone reads as
/// obviously gated rather than sagging). Bounds sag depth and — crucially — keeps the gain
/// strictly positive: the envelope tracks a post-shelf signal that can exceed 1, so an unclamped
/// `1 − sag·env` would go negative and phase-invert loud content instead of drooping.
private let sagGainFloor: Double = 0.15
public override var toneStackModel: ToneStackModel { .mesa }
public override var summaryText: String {
"Modern high-gain rectifier — scooped Mesa lead with Sag (power-supply bloom) and a Tight switch."
}
public override var signatureKnobs: [PedalKnob] {
super.signatureKnobs + [PedalKnob(label: "Sag", node: $sag, range: signatureRange)]
}
public override var effectSwitches: [PedalSwitch] {
super.effectSwitches + [
PedalSwitch(
@@ -70,6 +55,7 @@ public final class ModernHighGainAmpPedal: BoutiqueAmpPedal {
gain = 7.0
drive = 18.0 // hottest lead of the lineup
cab = 1.0 // British 4×12 — tight, aggressive
sag = 0.3 // rectifier bloom on by default (shared power-amp Sag from AmpVoicePedal)
}
/// Tight switch: a pre-preamp high-pass whose corner switches between ~20 Hz (loose, negligible
@@ -79,18 +65,4 @@ public final class ModernHighGainAmpPedal: BoutiqueAmpPedal {
$tight, inLo: 0.0, inHi: 1.0, outLo: tightLooseFreqHz, outHi: tightFreqHz)
return RBJHighPass.Audio(input: signal, freq: cutoff, q: tightQ)
}
/// Base Presence/Depth shaping, then power-supply Sag: an envelope follower reduces gain as the
/// signal gets loud (droop) and recovers slowly (bloom). `Sag` scales the depth; `0` = stiff.
public override func shapeVoice(_ signal: any ValidGeneratorInput) -> any ValidGeneratorInput {
let shaped: any ValidGeneratorInput = super.shapeVoice(signal)
let envelope: AmplitudeFollower.Audio = AmplitudeFollower.Audio(
in: shaped, attackTime: sagAttackSeconds, releaseTime: sagReleaseSeconds)
// Gain droops toward `sagGainFloor` as the envelope rises. The Presence/Depth shelves can
// push the envelope above 1, so clamp to `[sagGainFloor, 1]` — an unclamped `1 − sag·env`
// would go negative and phase-invert loud content instead of attenuating it.
let sagGain: any ValidGeneratorInput = Clip.Audio(
1.0 - ($sag * envelope), lo: sagGainFloor, hi: 1.0)
return shaped * sagGain
}
}
@@ -20,6 +20,7 @@ extension Pedal {
let switchValues: [Double] = effectSwitches.map { $0.node.value }
let sliderValues: [Double] = effectSliders.map { $0.node.value }
let selectorValues: [Double] = effectSelectors.map { $0.node.value }
let advancedValues: [Double] = advancedKnobs.map { $0.node.value }
return PedalState(
id: id,
type: displayName,
@@ -27,6 +28,7 @@ extension Pedal {
switchValues: switchValues,
sliderValues: sliderValues,
selectorValues: selectorValues,
advancedValues: advancedValues,
bypass: bypass,
tempoSync: tempoSync.isEmpty ? nil : tempoSync,
resourcePath: resourcePath
@@ -62,6 +64,9 @@ extension Pedal {
for (selector, value) in zip(effectSelectors, state.selectorValues) {
selector.node.update(value)
}
for (advancedKnob, value) in zip(advancedKnobs, state.advancedValues) {
advancedKnob.node.update(value)
}
bypass = state.bypass
// Restore tempo-sync state. The synced values themselves are recomputed from the rig's
// tempo by `ShoeGaze` after the rebuild, so no clock is required here.
@@ -53,7 +53,7 @@ public enum PedalRegistry {
"Chime Baby": { ChimeBabyAmpPedal() },
"Fullerton Reverb": { FullertonReverbAmpPedal() },
"Fullerton Deluxe": { FullertonDeluxeAmpPedal() },
"Fullerton Princeton": { FullertonPrincetonAmpPedal() },
"Fullerton Ivy League": { FullertonPrincetonAmpPedal() },
"Fullerton Drive": { FullertonDriveAmpPedal() },
"Jazz Clean": { JazzCleanAmpPedal() },
"Chime Top Boost": { ChimeTopBoostAmpPedal() },
@@ -42,6 +42,10 @@ public struct PedalState: Codable, Equatable {
/// no selectors. Absent in presets saved before selectors existed — decodes to `[]`.
public let selectorValues: [Double]
/// Advanced (pop-over) knob values in the same order as `Pedal.advancedKnobs`. Empty for pedals
/// with no advanced knobs. Absent in presets saved before advanced knobs existed — decodes to `[]`.
public let advancedValues: [Double]
/// Bypass parameter value. `0.0` = engaged, `1.0` = bypassed.
public let bypass: Double
@@ -62,6 +66,7 @@ public struct PedalState: Codable, Equatable {
/// - switchValues: Current switch values in `Pedal.effectSwitches` order. Defaults to empty.
/// - sliderValues: Current slider values in `Pedal.effectSliders` order. Defaults to empty.
/// - selectorValues: Current selector values in `Pedal.effectSelectors` order. Defaults to empty.
/// - advancedValues: Current advanced-knob values in `Pedal.advancedKnobs` order. Defaults to empty.
/// - bypass: Bypass parameter value (`0.0` = engaged, `1.0` = bypassed).
/// - tempoSync: Tempo-sync state per syncable parameter, or `nil` for none. Defaults to `nil`.
/// - resourcePath: Path to an external resource the pedal references (e.g. a neural-amp
@@ -73,6 +78,7 @@ public struct PedalState: Codable, Equatable {
switchValues: [Double] = [],
sliderValues: [Double] = [],
selectorValues: [Double] = [],
advancedValues: [Double] = [],
bypass: Double,
tempoSync: [String: TempoSync]? = nil,
resourcePath: String? = nil
@@ -83,6 +89,7 @@ public struct PedalState: Codable, Equatable {
self.switchValues = switchValues
self.sliderValues = sliderValues
self.selectorValues = selectorValues
self.advancedValues = advancedValues
self.bypass = bypass
self.tempoSync = tempoSync
self.resourcePath = resourcePath
@@ -95,13 +102,14 @@ public struct PedalState: Codable, Equatable {
case switchValues
case sliderValues
case selectorValues
case advancedValues
case bypass
case tempoSync
case resourcePath
}
/// Decodes a snapshot, tolerating presets saved before `switchValues` / `sliderValues` /
/// `selectorValues` / `tempoSync` existed by defaulting the missing keys.
/// `selectorValues` / `advancedValues` / `tempoSync` existed by defaulting the missing keys.
public init(from decoder: any Decoder) throws {
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decodeIfPresent(UUID.self, forKey: .id) ?? UUID()
@@ -110,6 +118,7 @@ public struct PedalState: Codable, Equatable {
self.switchValues = try container.decodeIfPresent([Double].self, forKey: .switchValues) ?? []
self.sliderValues = try container.decodeIfPresent([Double].self, forKey: .sliderValues) ?? []
self.selectorValues = try container.decodeIfPresent([Double].self, forKey: .selectorValues) ?? []
self.advancedValues = try container.decodeIfPresent([Double].self, forKey: .advancedValues) ?? []
self.bypass = try container.decode(Double.self, forKey: .bypass)
self.tempoSync = try container.decodeIfPresent([String: TempoSync].self, forKey: .tempoSync)
self.resourcePath = try container.decodeIfPresent(String.self, forKey: .resourcePath)