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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user