From 2aea609f342831a7f217f721faa9fb5e29330b74 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Mon, 10 Aug 2026 17:04:58 -0700 Subject: [PATCH] feat(rigs): ship the tweaked Garcia rig as a captured state Replace the code-built Garcia with the user's hand-authored version, transcribed verbatim as a ShoeGazeState: Board 1 (Bass Octaver, Mutant, Overdrive, Graphic EQ, Phaser, Delay, Fullerton Reverb) and Board 2 (Overdrive, Graphic EQ, Compressor, Fullerton Reverb), preserving exact mix, graphic-EQ slider, cab-selector and amp sag/bias values. Input source and channel counts are omitted so the rig stays input-agnostic. Adds a FactoryRigBuild.state case (and matching FactoryRig init) for rigs shipped as a pre-captured state rather than a live builder, and bumps seedVersion to 3 so existing libraries refresh Garcia to the new version. Co-Authored-By: Claude Opus 4.8 --- .../Presets/Factory/FactoryRig.swift | 26 ++++ .../Presets/Factory/FactoryRigBuild.swift | 7 ++ .../Presets/Factory/FactoryRigLibrary.swift | 112 ++++++++++-------- 3 files changed, 95 insertions(+), 50 deletions(-) diff --git a/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRig.swift b/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRig.swift index 2b1286e..4ceb8b5 100644 --- a/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRig.swift +++ b/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRig.swift @@ -96,4 +96,30 @@ public struct FactoryRig: Identifiable, Sendable { self.category = category self.build = .session(sessionBuild) } + + /// Creates a factory rig from a pre-captured ``ShoeGazeState``. + /// + /// The rig's content is the supplied state verbatim — used for a complex, hand-authored rig + /// captured from the app. Seeding builds the entry directly from `state` (no live session). + /// + /// - Parameters: + /// - id: Stable identifier (a fixed literal per rig — see ``id``). + /// - name: Rig name (picker title + saved entry name). + /// - blurb: User-facing description of the sound. + /// - category: Sonic family for picker grouping. + /// - state: The captured rig content to ship. + @MainActor + public init( + id: UUID, + name: String, + blurb: String, + category: FactoryRigCategory, + state: ShoeGazeState + ) { + self.id = id + self.name = name + self.blurb = blurb + self.category = category + self.build = .state({ state }) + } } diff --git a/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRigBuild.swift b/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRigBuild.swift index 42eb4c5..46839b0 100644 --- a/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRigBuild.swift +++ b/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRigBuild.swift @@ -14,4 +14,11 @@ public enum FactoryRigBuild: Sendable { /// Builds the whole graph against the session (boards and/or routers), owning its own /// `addBoard`/`finalizeBoard` and `makeChainRouter`/`finalize` lifecycle. case session(@MainActor (_ session: ShoeGaze) throws -> Void) + + /// Ships a pre-captured ``ShoeGazeState`` directly — the entry is built from it with no live + /// session. Use for a complex, hand-authored rig captured from the app, where transcribing the + /// exact `PedalState` arrays (mix, sliders, selectors, advanced values) is more faithful than + /// re-deriving them through typed setters. The closure returns the state so the case stays + /// `Sendable` without requiring `ShoeGazeState` itself to be `Sendable`. + case state(@MainActor () -> ShoeGazeState) } diff --git a/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRigLibrary.swift b/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRigLibrary.swift index 2eb352c..febc9bf 100644 --- a/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRigLibrary.swift +++ b/Sources/LyrebirdShoeGaze/Presets/Factory/FactoryRigLibrary.swift @@ -74,7 +74,7 @@ public enum FactoryRigLibrary { /// an existing rig's definition corrected — so launch catch-up re-runs on already-populated /// libraries and refreshes every starter to its current form. Within a single version the marker /// only advances once, so a starter the user deletes stays deleted until the next bump. - public static let seedVersion: Int = 2 + public static let seedVersion: Int = 3 /// Stable ids of every built-in rig, for detecting whether a library entry is a factory rig. /// @@ -654,57 +654,61 @@ public enum FactoryRigLibrary { id: stableID("Garcia OBEL Split"), name: "Garcia OBEL Clean/Effects Split", blurb: "Two boards, one selector: Board 1 is an effects/lead chain (octave, envelope filter, " - + "overdrive, phaser, delay); Board 2 is a clean direct path. Use the board Solo / Blend " - + "control at the top to switch between them, like an on-board effects loop. In the " - + "spirit of a certain improvising guitarist's late-'80s rig.", + + "overdrive, graphic EQ, phaser, delay, reverb); Board 2 is a fuller direct voice " + + "(overdrive, graphic EQ, compression, reverb). Use the board Solo / Blend control at the " + + "top to switch between them, like an on-board effects loop. In the spirit of a certain " + + "improvising guitarist's late-'80s rig.", category: .classic, - sessionBuild: { session in - // Board 1 — the effects / lead chain (effects loop engaged). - let effects: PedalBoard = try session.addBoard() - try effects.append(BassOctaverPedal()) { p in - p.oct1 = 0.5 - p.direct = 1.0 - p.mode = 1.0 - } - try effects.append(MutantPedal()) { p in - p.sensitivity = 2.5 - p.resonance = 5.0 - } - try effects.append(OverdrivePedal()) { p in - p.drive = 5.0 - p.tone = 4200.0 - } - try effects.append(PhaserPedal()) { p in - p.rate = 0.4 - p.feedback = 0.4 - } - try effects.append(DelayPedal()) { p in - p.time = 0.35 - p.feedback = 1.8 - } - try effects.append(CaliforniaAmpPedal()) { p in - p.gain = 5.0 - p.bass = 0.55 - p.mid = 0.6 - p.treble = 0.6 - } - try session.finalizeBoard(effects) + // Hand-authored in the app and shipped as a captured state — transcribing the exact pedal + // values (mix, graphic-EQ sliders, cab selector, amp sag/bias) is more faithful than + // re-deriving them through typed setters. Input source / channel counts are intentionally + // omitted so the rig is input-agnostic. + state: garciaState + ) - // Board 2 — the clean / direct path (effects loop bypassed). - let clean: PedalBoard = try session.addBoard() - try clean.append(CompressorPedal()) { p in - p.inputGain = 2.0 - p.threshold = -16.0 - p.ratio = 3.0 - } - try clean.append(CaliforniaAmpPedal()) { p in - p.gain = 3.5 - p.bass = 0.5 - p.mid = 0.55 - p.treble = 0.6 - } - try session.finalizeBoard(clean) - } + /// The shipped Garcia rig content. `static let` so its (default) pedal ids are stable per process, + /// keeping seeding deterministic. + private static let garciaState: ShoeGazeState = ShoeGazeState( + boards: [ + BoardState(label: "Board 1", pedals: [ + PedalState(type: "Bass Octaver", + knobValues: [0.5, 0, 1, 1, 1], switchValues: [1], bypass: 0), + PedalState(type: "Mutant", + knobValues: [2.5, 4.45515625, 1, 1], switchValues: [1, 0], bypass: 0), + PedalState(type: "Overdrive", + knobValues: [5, 4200, 1, 1], bypass: 0), + PedalState(type: "Graphic EQ", + knobValues: [1, 1], + sliderValues: [-4.7786931818181815, -2.214204545454546, 1.552840909090909, + 1.8536931818181799, -3.3426136363636374, -0.45852272727272947], + bypass: 0), + PedalState(type: "Phaser", + knobValues: [0.4, 0.4, 0.5, 1], bypass: 0), + PedalState(type: "Delay", + knobValues: [0.35, 1.8, 0.35, 1], bypass: 0), + PedalState(type: "Fullerton Reverb", + knobValues: [2.5505078125, 0.5, 0.5, 0.6, 0.25, 4, 0, 1, 1], + switchValues: [0, 1, 0], selectorValues: [4], + advancedValues: [0, 0.5, 0], bypass: 0), + ]), + BoardState(label: "Board 2", pedals: [ + PedalState(type: "Overdrive", + knobValues: [6.54533203125, 4000, 1, 1], bypass: 0), + PedalState(type: "Graphic EQ", + knobValues: [1, 1], + sliderValues: [2.957386363636365, 0, 2.7741477272727266, + 1.940624999999999, -0.6767045454545446, 0], + bypass: 0), + PedalState(type: "Compressor", + knobValues: [2, -16, 3, 1, 1], switchValues: [0], bypass: 0), + PedalState(type: "Fullerton Reverb", + knobValues: [5.08, 0.5, 0.5, 0.6, 0.13624999999999998, 4, 0, 1, 1], + switchValues: [0, 1, 0], selectorValues: [4], + advancedValues: [0, 0.5, 0], bypass: 0), + ]), + ], + bpm: 120, + tempoEnabled: true ) // MARK: - Seeding @@ -726,6 +730,12 @@ public enum FactoryRigLibrary { var entries: [RigEntry] = [] entries.reserveCapacity(all.count) for rig: FactoryRig in all { + // A state-backed rig needs no live session — build its entry directly from the state. + if case .state(let makeState) = rig.build { + entries.append(RigEntry(id: rig.id, name: rig.name, state: makeState())) + continue + } + let session: ShoeGaze = try makeSession() // Tear down on every exit from this iteration, including a throw from a builder, so a // failing rig never leaks its throwaway engine's buses/nodes. @@ -739,6 +749,8 @@ public enum FactoryRigLibrary { // The builder owns its own board/router lifecycle (addBoard/finalizeBoard, // makeChainRouter/finalize). try build(session) + case .state: + continue // handled above } entries.append(session.captureEntry(name: rig.name, id: rig.id)) }