diff --git a/Sources/LyrebirdShoeGaze/Pedal.swift b/Sources/LyrebirdShoeGaze/Pedal.swift index aa7f074..905dd6b 100644 --- a/Sources/LyrebirdShoeGaze/Pedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedal.swift @@ -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 diff --git a/Sources/LyrebirdShoeGaze/PedalType.swift b/Sources/LyrebirdShoeGaze/PedalType.swift index af9b0fd..97f560c 100644 --- a/Sources/LyrebirdShoeGaze/PedalType.swift +++ b/Sources/LyrebirdShoeGaze/PedalType.swift @@ -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") diff --git a/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift b/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift index b1d0011..4c1ac07 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/AmpVoicePedal.swift @@ -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` diff --git a/Sources/LyrebirdShoeGaze/Pedals/ChimeAmpPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/ChimeAmpPedal.swift index fb1806e..ff8826f 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/ChimeAmpPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/ChimeAmpPedal.swift @@ -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 { diff --git a/Sources/LyrebirdShoeGaze/Pedals/ChimeBabyAmpPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/ChimeBabyAmpPedal.swift index cca6ae4..fd8fdaf 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/ChimeBabyAmpPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/ChimeBabyAmpPedal.swift @@ -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. diff --git a/Sources/LyrebirdShoeGaze/Pedals/ChimeFifteenAmpPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/ChimeFifteenAmpPedal.swift index 53cb4b5..5e6da13 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/ChimeFifteenAmpPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/ChimeFifteenAmpPedal.swift @@ -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. diff --git a/Sources/LyrebirdShoeGaze/Pedals/ChimeNormalAmpPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/ChimeNormalAmpPedal.swift index 98c3400..5f50917 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/ChimeNormalAmpPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/ChimeNormalAmpPedal.swift @@ -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. diff --git a/Sources/LyrebirdShoeGaze/Pedals/FullertonPrincetonAmpPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/FullertonPrincetonAmpPedal.swift index 0351f17..cb8243e 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/FullertonPrincetonAmpPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/FullertonPrincetonAmpPedal.swift @@ -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 diff --git a/Sources/LyrebirdShoeGaze/Pedals/ModernHighGainAmpPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/ModernHighGainAmpPedal.swift index 98eb329..bfc3e04 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/ModernHighGainAmpPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/ModernHighGainAmpPedal.swift @@ -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 - } } diff --git a/Sources/LyrebirdShoeGaze/Presets/Pedal+Preset.swift b/Sources/LyrebirdShoeGaze/Presets/Pedal+Preset.swift index aec809f..cfbff3d 100644 --- a/Sources/LyrebirdShoeGaze/Presets/Pedal+Preset.swift +++ b/Sources/LyrebirdShoeGaze/Presets/Pedal+Preset.swift @@ -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. diff --git a/Sources/LyrebirdShoeGaze/Presets/PedalRegistry.swift b/Sources/LyrebirdShoeGaze/Presets/PedalRegistry.swift index 4a43cb2..ab3c9f8 100644 --- a/Sources/LyrebirdShoeGaze/Presets/PedalRegistry.swift +++ b/Sources/LyrebirdShoeGaze/Presets/PedalRegistry.swift @@ -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() }, diff --git a/Sources/LyrebirdShoeGaze/Presets/PedalState.swift b/Sources/LyrebirdShoeGaze/Presets/PedalState.swift index 5ee2f2b..6e7801f 100644 --- a/Sources/LyrebirdShoeGaze/Presets/PedalState.swift +++ b/Sources/LyrebirdShoeGaze/Presets/PedalState.swift @@ -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 = 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) diff --git a/Sources/LyrebirdShoeGazeUI/PedalCategory.swift b/Sources/LyrebirdShoeGazeUI/PedalCategory.swift index 5c86fb5..f3a332d 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalCategory.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalCategory.swift @@ -44,7 +44,7 @@ public enum PedalCategory: String, CaseIterable, Identifiable, Sendable { } private static let mapping: [String: PedalCategory] = [ - "California": .amp, "British": .amp, "British Plexi": .amp, "British JTM": .amp, "British Bluesbreaker": .amp, "British Master": .amp, "British Dual": .amp, "Boutique Lead": .amp, "Boutique OD": .amp, "Cali Hi-Gain": .amp, "Command": .amp, "Citrus": .amp, "Sixties Combo": .amp, "Magna Vibrato": .amp, "Anaheim": .amp, "Modern High-Gain": .amp, "Chime": .amp, "Chime 15": .amp, "Chime Normal": .amp, "Chime Baby": .amp, "Fullerton Reverb": .amp, "Fullerton Deluxe": .amp, "Fullerton Princeton": .amp, "Fullerton Drive": .amp, "Jazz Clean": .amp, "Chime Top Boost": .amp, "Neural Amp": .amp, + "California": .amp, "British": .amp, "British Plexi": .amp, "British JTM": .amp, "British Bluesbreaker": .amp, "British Master": .amp, "British Dual": .amp, "Boutique Lead": .amp, "Boutique OD": .amp, "Cali Hi-Gain": .amp, "Command": .amp, "Citrus": .amp, "Sixties Combo": .amp, "Magna Vibrato": .amp, "Anaheim": .amp, "Modern High-Gain": .amp, "Chime": .amp, "Chime 15": .amp, "Chime Normal": .amp, "Chime Baby": .amp, "Fullerton Reverb": .amp, "Fullerton Deluxe": .amp, "Fullerton Ivy League": .amp, "Fullerton Drive": .amp, "Jazz Clean": .amp, "Chime Top Boost": .amp, "Neural Amp": .amp, "Overdrive": .gain, "Distortion": .gain, "Fuzz": .gain, "Volume": .gain, "Compressor": .dynamics, "Sustainer": .dynamics, "Limiter": .dynamics, "Noise Gate": .dynamics, "Graphic EQ": .filter, "Auto-Wah": .filter, "Wah": .filter, "Mutant": .filter, diff --git a/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift b/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift index 20d09d7..6d62173 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalPaletteView.swift @@ -54,7 +54,7 @@ public struct PedalPaletteView: View { /// Preferred display order for the built-in pedals. Any registered pedal not listed here is /// appended afterwards (sorted) so the palette never silently drops a newly added pedal. private static let preferredOrder: [String] = [ - "California", "British", "British Plexi", "British JTM", "British Bluesbreaker", "British Master", "British Dual", "Boutique Lead", "Boutique OD", "Cali Hi-Gain", "Command", "Citrus", "Sixties Combo", "Magna Vibrato", "Anaheim", "Modern High-Gain", "Chime", "Chime 15", "Chime Normal", "Chime Baby", "Fullerton Reverb", "Fullerton Deluxe", "Fullerton Princeton", "Fullerton Drive", "Jazz Clean", "Chime Top Boost", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz", + "California", "British", "British Plexi", "British JTM", "British Bluesbreaker", "British Master", "British Dual", "Boutique Lead", "Boutique OD", "Cali Hi-Gain", "Command", "Citrus", "Sixties Combo", "Magna Vibrato", "Anaheim", "Modern High-Gain", "Chime", "Chime 15", "Chime Normal", "Chime Baby", "Fullerton Reverb", "Fullerton Deluxe", "Fullerton Ivy League", "Fullerton Drive", "Jazz Clean", "Chime Top Boost", "Overdrive", "Distortion", "Compressor", "Sustainer", "Limiter", "Noise Gate", "Fuzz", "Volume", "Graphic EQ", "Tremolo", "Phaser", "Modulation", "Chorus", "Flanger", "Vibrato", "Rotary", "Auto-Wah", "Wah", "Mutant", "Cabinet", "Ring Modulator", "Diffuser", "Bitcrusher", "Granulator", @@ -183,6 +183,12 @@ public struct PedalPaletteView: View { /// Full-width column for a left sidebar. private var verticalBody: some View { VStack(alignment: .leading, spacing: PedalPaletteView.sectionSpacing) { + VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) { + sectionTitle("ROUTING") + ForEach(PedalPaletteView.routingOptions, id: \.title) { option in + routingCard(title: option.title, caption: option.caption, action: option.action) + } + } VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) { HStack { sectionTitle("PEDALS") @@ -193,13 +199,6 @@ public struct PedalPaletteView: View { pedalRow(name) } } - - VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) { - sectionTitle("ROUTING") - ForEach(PedalPaletteView.routingOptions, id: \.title) { option in - routingCard(title: option.title, caption: option.caption, action: option.action) - } - } } } @@ -225,6 +224,14 @@ public struct PedalPaletteView: View { } } HStack(alignment: .top, spacing: PedalPaletteView.sectionSpacing) { + VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) { + sectionTitle("ROUTING") + HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) { + ForEach(PedalPaletteView.routingOptions, id: \.title) { option in + routingCard(title: option.title, caption: option.caption, action: option.action) + } + } + } if let amps: (category: PedalCategory, names: [String]) = ampGroup { VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) { categoryLabel(amps.category) @@ -235,14 +242,6 @@ public struct PedalPaletteView: View { } } } - VStack(alignment: .leading, spacing: PedalPaletteView.rowSpacing) { - sectionTitle("ROUTING") - HStack(alignment: .top, spacing: PedalPaletteView.rowSpacing) { - ForEach(PedalPaletteView.routingOptions, id: \.title) { option in - routingCard(title: option.title, caption: option.caption, action: option.action) - } - } - } } } } diff --git a/Sources/LyrebirdShoeGazeUI/PedalView.swift b/Sources/LyrebirdShoeGazeUI/PedalView.swift index 612c78d..b72ac56 100644 --- a/Sources/LyrebirdShoeGazeUI/PedalView.swift +++ b/Sources/LyrebirdShoeGazeUI/PedalView.swift @@ -34,15 +34,15 @@ private func enclosureColor(for displayName: String) -> Color { case "Anaheim": return Color(red: 0.24, green: 0.30, blue: 0.32) // hybrid slate case "Modern High-Gain": return Color(red: 0.12, green: 0.12, blue: 0.14) // recto black case "Chime": return Color(red: 0.16, green: 0.24, blue: 0.22) // vintage green - case "Chime 15": return Color(red: 0.18, green: 0.28, blue: 0.22) // brighter vox green - case "Chime Normal": return Color(red: 0.20, green: 0.26, blue: 0.20) // warm vox green - case "Chime Baby": return Color(red: 0.22, green: 0.30, blue: 0.24) // pale vox green + case "Chime 15": return Color(red: 0.18, green: 0.28, blue: 0.22) // brighter chime green + case "Chime Normal": return Color(red: 0.20, green: 0.26, blue: 0.20) // warm chime green + case "Chime Baby": return Color(red: 0.22, green: 0.30, blue: 0.24) // pale chime green case "Fullerton Reverb": return Color(red: 0.15, green: 0.22, blue: 0.30) // blackface panel case "Fullerton Deluxe": return Color(red: 0.17, green: 0.20, blue: 0.26) // blackface, warmer - case "Fullerton Princeton": return Color(red: 0.19, green: 0.19, blue: 0.23) // small blackface + case "Fullerton Ivy League": return Color(red: 0.19, green: 0.19, blue: 0.23) // small blackface case "Fullerton Drive": return Color(red: 0.22, green: 0.18, blue: 0.24) // two-channel combo case "Jazz Clean": return Color(red: 0.14, green: 0.30, blue: 0.34) // solid-state silver-teal - case "Chime Top Boost": return Color(red: 0.20, green: 0.32, blue: 0.20) // vox-green tolex + case "Chime Top Boost": return Color(red: 0.20, green: 0.32, blue: 0.20) // chime-green tolex case "Neural Amp": return Color(red: 0.22, green: 0.16, blue: 0.30) // deep neural violet case "Overdrive": return Color(red: 0.85, green: 0.42, blue: 0.08) // warm orange case "Distortion": return Color(red: 0.80, green: 0.26, blue: 0.12) // hot rust @@ -470,6 +470,14 @@ public struct PedalView: View { /// Insets placing the ⓘ info button just under the top-left corner screw. private static let infoButtonLeading: CGFloat = 5 private static let infoButtonTop: CGFloat = 20 + /// Insets placing the advanced (gear) button just under the top-right corner screw, mirroring + /// the info button. + private static let advancedButtonTrailing: CGFloat = 5 + private static let advancedButtonTop: CGFloat = 20 + /// Layout of the advanced-controls pop-over: knobs per row and the inter-knob gap. + private static let advancedPopoverColumns: Int = 2 + private static let advancedPopoverSpacing: CGFloat = 14 + private static let advancedPopoverPadding: CGFloat = 16 private static let outerBorderLineWidth: CGFloat = 1.5 private static let innerHighlightLineWidth: CGFloat = 1 private static let innerHighlightPadding: CGFloat = 1 @@ -482,6 +490,9 @@ public struct PedalView: View { /// Presentation flag for the pedal info panel (description + control ranges). @State private var showInfo: Bool = false + /// Presentation flag for the advanced-controls pop-over (amp Sag / Bias / Bias X). + @State private var showAdvanced: Bool = false + /// Presentation flag for the Neural Amp model-file importer. @State private var showModelImporter: Bool = false @@ -559,6 +570,15 @@ public struct PedalView: View { .padding(.leading, PedalView.infoButtonLeading) .padding(.top, PedalView.infoButtonTop) } + // Advanced (gear) button, tucked under the top-right corner screw — only for pedals that + // publish advanced knobs (e.g. an amp's Sag / Bias). + .overlay(alignment: .topTrailing) { + if !pedal.advancedKnobs.isEmpty { + advancedButton + .padding(.trailing, PedalView.advancedButtonTrailing) + .padding(.top, PedalView.advancedButtonTop) + } + } .shadow( color: Color.black.opacity(PedalView.shadowOpacity), radius: PedalView.shadowRadius, @@ -731,6 +751,46 @@ public struct PedalView: View { .help("About this pedal") } + /// Advanced-controls (gear) button tucked under the top-right corner screw. Presents + /// ``advancedPanel`` — the pedal's ``Pedal/advancedKnobs`` — in a popover. Only drawn when the + /// pedal publishes advanced knobs (the caller gates on `advancedKnobs.isEmpty`). + private var advancedButton: some View { + Button { + showAdvanced = true + } label: { + Image(systemName: "slider.horizontal.3") + .font(.system(size: PedalView.fontSizeNamePlate)) + .foregroundStyle(Color.white.opacity(PedalView.infoButtonOpacity)) + } + .buttonStyle(.plain) + .help("Advanced controls") + .popover(isPresented: $showAdvanced) { + advancedPanel + .presentationCompactAdaptation(.popover) + } + } + + /// Grid of the pedal's ``Pedal/advancedKnobs`` shown in the advanced popover, laid out in rows of + /// ``advancedPopoverColumns``. Plain `ParameterKnob`s — these are live, non-topology controls. + private var advancedPanel: some View { + let knobs: [PedalKnob] = pedal.advancedKnobs + let columns: Int = PedalView.advancedPopoverColumns + let rows: [[PedalKnob]] = stride(from: 0, to: knobs.count, by: columns).map { startIndex in + Array(knobs[startIndex ..< min(startIndex + columns, knobs.count)]) + } + return VStack(spacing: PedalView.advancedPopoverSpacing) { + ForEach(Array(rows.enumerated()), id: \.offset) { rowPair in + HStack(alignment: .top, spacing: PedalView.advancedPopoverSpacing) { + ForEach(Array(rowPair.element.enumerated()), id: \.offset) { knobPair in + ParameterKnob(knobPair.element.label, node: knobPair.element.node, range: knobPair.element.range) + .foregroundStyle(Color.white) + } + } + } + } + .padding(PedalView.advancedPopoverPadding) + } + /// Grid of the effect knobs, in rows of up to `knobColumnCount`. /// /// The trailing `Mix` and `Level` knobs (the last two entries of `pedal.knobs`) are diff --git a/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift b/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift index ec5668c..ec11144 100644 --- a/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift +++ b/Tests/LyrebirdShoeGazeTests/AmpVoicePedalTests.swift @@ -183,6 +183,82 @@ struct AmpVoicePedalTests { #expect(windowedSSD(open, dark) > 0, "Chime Cut had no effect") } + // MARK: - Power-amp Sag / Bias (shared) + + @Test func sagChangesOutput() throws { + for voice in voices { + let stiff: [Float] = try render(voice.make) { $0.gain = 20.0; $0.sag = 0.0 } + let saggy: [Float] = try render(voice.make) { $0.gain = 20.0; $0.sag = 1.0 } + #expect(windowedSSD(stiff, saggy) > 0, "\(voice.name) Sag had no effect") + } + } + + @Test func sagStaysWithinCeilingWithoutPhaseInversion() throws { + // Sag is a gain droop; it must attenuate loud content, never phase-invert it. The envelope + // tracks a post-power-amp signal that can exceed 1, so the droop gain is clamped positive. + // Assert the sagged output correlates positively with the stiff one (not an inverted copy) + // and never breaches the ±1 ceiling. + let ceilingEpsilon: Double = 1.0e-4 + for voice in voices { + let cfg: (AmpVoicePedal) -> Void = { (p: AmpVoicePedal) in + p.gain = 25.0; p.bass = 1.0; p.treble = 1.0 + } + let stiff: [Float] = try render(voice.make) { cfg($0); $0.sag = 0.0 } + let saggy: [Float] = try render(voice.make) { cfg($0); $0.sag = 1.0 } + let peak: Double = saggy.reduce(0.0) { Swift.max($0, abs(Double($1))) } + #expect(peak <= 1.0 + ceilingEpsilon, "\(voice.name) sagged peak \(peak) exceeds ±1") + let skip: Int = 4096, window: Int = 4096 + guard stiff.count >= skip + window, saggy.count >= skip + window else { + Issue.record("\(voice.name) render too short"); continue + } + let dotProduct: Double = zip(stiff[skip..<(skip + window)], saggy[skip..<(skip + window)]) + .reduce(0.0) { acc, pair in acc + Double(pair.0) * Double(pair.1) } + #expect(dotProduct > 0, "\(voice.name) Sag phase-inverted the signal (dot \(dotProduct) < 0)") + } + } + + @Test func biasChangesWaveshape() throws { + // Bias shifts the power-amp tanh operating point → changes the even/odd harmonic mix (a + // waveshape change), not merely the level. RMS-normalize so a pure level difference collapses. + for voice in voices { + let cold: [Float] = try render(voice.make) { $0.gain = 22.0; $0.bias = 0.0 } + let hot: [Float] = try render(voice.make) { $0.gain = 22.0; $0.bias = 1.0 } + #expect(hasNonSilentOutput(cold) && hasNonSilentOutput(hot)) + #expect(rmsNormalizedSSD(cold, hot) > 1.0e-4, "\(voice.name) Bias changed level but not waveshape") + } + } + + @Test func neutralBiasAndZeroSagAreIdentityDefault() throws { + // The shipped defaults are sag = 0 and bias = 0.5 (neutral). Setting them explicitly to those + // values must be bit-for-bit identical to leaving them at their defaults — proof the new + // controls don't perturb any existing amp's voice at their neutral position. + for voice in voices { + let byDefault: [Float] = try render(voice.make) + let explicit: [Float] = try render(voice.make) { $0.sag = 0.0; $0.bias = 0.5 } + #expect(windowedSSD(byDefault, explicit) == 0, "\(voice.name) neutral Sag/Bias is not identity") + } + } + + @Test func advancedKnobsExposeSagAndBias() throws { + for voice in voices { + let pedal: AmpVoicePedal = voice.make() + #expect(pedal.advancedKnobs.map { $0.label } == ["Sag", "Bias"], "\(voice.name) advanced knobs") + // Sag/Bias are pop-over-only — they must NOT also appear on the pedal face. + let faceLabels: [String] = pedal.effectKnobs.map { $0.label } + #expect(!faceLabels.contains("Sag") && !faceLabels.contains("Bias"), + "\(voice.name) leaked Sag/Bias onto the pedal face") + } + } + + @Test func sagBiasRoundTripThroughState() throws { + let pedal: CaliforniaAmpPedal = CaliforniaAmpPedal() + pedal.sag = 0.7 + pedal.bias = 0.2 + let restored: CaliforniaAmpPedal = CaliforniaAmpPedal() + restored.applyState(pedal.captureState()) + #expect(restored.sag == 0.7 && restored.bias == 0.2, "Sag/Bias did not round-trip through state") + } + // MARK: - Chrome / config @Test func exposesControls() throws { diff --git a/Tests/LyrebirdShoeGazeTests/FullertonVariantsTests.swift b/Tests/LyrebirdShoeGazeTests/FullertonVariantsTests.swift index 9cef60d..7640d8d 100644 --- a/Tests/LyrebirdShoeGazeTests/FullertonVariantsTests.swift +++ b/Tests/LyrebirdShoeGazeTests/FullertonVariantsTests.swift @@ -51,7 +51,7 @@ struct FullertonVariantsTests { private let variants: [(name: String, make: () -> FullertonReverbAmpPedal)] = [ ("Fullerton Deluxe", { FullertonDeluxeAmpPedal() }), - ("Fullerton Princeton", { FullertonPrincetonAmpPedal() }), + ("Fullerton Ivy League", { FullertonPrincetonAmpPedal() }), ] @Test func bothBuildNonSilentFinite() throws { @@ -122,6 +122,6 @@ struct FullertonVariantsTests { @Test func registeredInBuiltInRegistry() throws { #expect(PedalRegistry.makePedal(type: "Fullerton Deluxe") is FullertonDeluxeAmpPedal) - #expect(PedalRegistry.makePedal(type: "Fullerton Princeton") is FullertonPrincetonAmpPedal) + #expect(PedalRegistry.makePedal(type: "Fullerton Ivy League") is FullertonPrincetonAmpPedal) } } diff --git a/Tests/LyrebirdShoeGazeTests/ModernHighGainAmpPedalTests.swift b/Tests/LyrebirdShoeGazeTests/ModernHighGainAmpPedalTests.swift index fa576fc..33febe7 100644 --- a/Tests/LyrebirdShoeGazeTests/ModernHighGainAmpPedalTests.swift +++ b/Tests/LyrebirdShoeGazeTests/ModernHighGainAmpPedalTests.swift @@ -98,11 +98,14 @@ struct ModernHighGainAmpPedalTests { @Test func exposesControlSurface() throws { let pedal: ModernHighGainAmpPedal = ModernHighGainAmpPedal() + // Sag now lives in the shared advanced pop-over (with Bias), not on the pedal face. #expect(pedal.effectKnobs.map { $0.label } - == ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive", "Sag"]) + == ["Gain", "Bass", "Mid", "Treble", "Presence", "Depth", "Master", "Drive"]) + #expect(pedal.advancedKnobs.map { $0.label } == ["Sag", "Bias"]) #expect(pedal.effectSwitches.map { $0.label } == ["Channel", "Tight"]) #expect(pedal.widthUnits == 4) #expect(pedal.toneStackModel == .mesa) + #expect(pedal.sag == 0.3, "Modern High-Gain keeps rectifier sag on by default") } @Test func controlsRoundTripThroughState() throws {