fix(rigs): address starter-rig feedback (toggle, Garcia, shimmer, input)

- Center the Mine/Starters toggle in the sidebar column.
- Garcia rig: build it as two plain boards (effects + clean) selected via
  the multi-board Solo/Blend control, instead of a ChainRouter — the builder
  UI renders boards, not routers, so the router version showed empty boards.
- Dreampop Chorus Cathedral: lower shimmer decay/feedback and delay feedback
  so the octave-up regeneration no longer screeches into runaway feedback.
- Preserve the current input across rig switches: loadRig gains a
  keepingCurrentInput flag (default false → file open / launch restore still
  apply the rig's saved input; RigStore session-restore continuity intact),
  and the rig-switch path (loadEntry) passes true so a live guitar isn't
  snapped back to the test tone when changing rigs. Tests updated to cover
  both directions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-09 14:36:49 -07:00
parent 392ae1525a
commit 132515b4cd
5 changed files with 102 additions and 57 deletions
@@ -194,13 +194,15 @@ public enum FactoryRigLibrary {
} }
try board.append(DelayPedal()) { p in try board.append(DelayPedal()) { p in
p.time = 0.4 p.time = 0.4
p.feedback = 2.2 p.feedback = 1.5
} }
try board.append(ShimmerReverbPedal()) { p in try board.append(ShimmerReverbPedal()) { p in
// Keep decay + shimmer feedback well below self-oscillation — high decay with the
// octave-up regeneration screeches into runaway feedback within seconds.
p.size = 0.09 p.size = 0.09
p.decay = 0.85 p.decay = 0.55
p.shimmer = 0.55 p.shimmer = 0.3
p.damp = 0.35 p.damp = 0.5
} }
} }
@@ -646,64 +648,61 @@ public enum FactoryRigLibrary {
// MARK: Two-board split // MARK: Two-board split
/// A two-board split — a full effects chain vs a clean direct path — selectable like an on-board /// Two boards — a full effects chain and a clean direct path — switched with the board selector.
/// effects loop. Showcases the multi-board router.
static let garciaOBELSplit: FactoryRig = FactoryRig( static let garciaOBELSplit: FactoryRig = FactoryRig(
id: stableID("Garcia OBEL Split"), id: stableID("Garcia OBEL Split"),
name: "Garcia OBEL Clean/Effects Split", name: "Garcia OBEL Clean/Effects Split",
blurb: "Two boards, one footswitch: an effects/lead chain (octave, envelope filter, " blurb: "Two boards, one selector: Board 1 is an effects/lead chain (octave, envelope filter, "
+ "overdrive, phaser, delay) versus a clean direct path — switch between them like an " + "overdrive, phaser, delay); Board 2 is a clean direct path. Use the board Solo / Blend "
+ "on-board effects loop. In the spirit of a certain improvising guitarist's late-'80s " + "control at the top to switch between them, like an on-board effects loop. In the "
+ "rig. Flip the router to A for effects, B for clean.", + "spirit of a certain improvising guitarist's late-'80s rig.",
category: .classic, category: .classic,
sessionBuild: { session in sessionBuild: { session in
let router: ChainRouter = try session.makeChainRouter() // Board 1 — the effects / lead chain (effects loop engaged).
let effects: PedalBoard = try session.addBoard()
// Board A — the effects / lead chain (effects loop engaged). try effects.append(BassOctaverPedal()) { p in
try router.appendToA(BassOctaverPedal()) { p in
p.oct1 = 0.5 p.oct1 = 0.5
p.direct = 1.0 p.direct = 1.0
p.mode = 1.0 p.mode = 1.0
} }
try router.appendToA(MutantPedal()) { p in try effects.append(MutantPedal()) { p in
p.sensitivity = 2.5 p.sensitivity = 2.5
p.resonance = 5.0 p.resonance = 5.0
} }
try router.appendToA(OverdrivePedal()) { p in try effects.append(OverdrivePedal()) { p in
p.drive = 5.0 p.drive = 5.0
p.tone = 4200.0 p.tone = 4200.0
} }
try router.appendToA(PhaserPedal()) { p in try effects.append(PhaserPedal()) { p in
p.rate = 0.4 p.rate = 0.4
p.feedback = 0.4 p.feedback = 0.4
} }
try router.appendToA(DelayPedal()) { p in try effects.append(DelayPedal()) { p in
p.time = 0.35 p.time = 0.35
p.feedback = 1.8 p.feedback = 1.8
} }
try router.appendToA(CaliforniaAmpPedal()) { p in try effects.append(CaliforniaAmpPedal()) { p in
p.gain = 5.0 p.gain = 5.0
p.bass = 0.55 p.bass = 0.55
p.mid = 0.6 p.mid = 0.6
p.treble = 0.6 p.treble = 0.6
} }
try session.finalizeBoard(effects)
// Board B — the clean / direct path (effects loop bypassed). // Board 2 — the clean / direct path (effects loop bypassed).
try router.appendToB(CompressorPedal()) { p in let clean: PedalBoard = try session.addBoard()
try clean.append(CompressorPedal()) { p in
p.inputGain = 2.0 p.inputGain = 2.0
p.threshold = -16.0 p.threshold = -16.0
p.ratio = 3.0 p.ratio = 3.0
} }
try router.appendToB(CaliforniaAmpPedal()) { p in try clean.append(CaliforniaAmpPedal()) { p in
p.gain = 3.5 p.gain = 3.5
p.bass = 0.5 p.bass = 0.5
p.mid = 0.55 p.mid = 0.55
p.treble = 0.6 p.treble = 0.6
} }
try session.finalizeBoard(clean)
// Default to the effects board; the router's A/B control switches paths.
router.mode = .a
try router.finalize()
} }
) )
@@ -107,9 +107,18 @@ extension ShoeGaze {
/// rebuilds every board with the all-or-nothing semantics of ``rebuildAllBoards(from:)``. /// rebuilds every board with the all-or-nothing semantics of ``rebuildAllBoards(from:)``.
/// ///
/// - Important: Call with the engine **stopped**, as with ``loadRig(from:)``. /// - Important: Call with the engine **stopped**, as with ``loadRig(from:)``.
/// - Parameter state: The rig snapshot to restore. /// - Parameters:
/// - state: The rig snapshot to restore.
/// - keepingCurrentInput: When `true`, the session's current ``inputSource`` is preserved and
/// the rig's saved input is ignored — used when the player switches between rigs, so the live
/// input (e.g. a plugged-in guitar) doesn't snap back to the test loop a rig was authored
/// with. When `false` (the default, used by file open and launch restore), the rig's saved
/// input is applied so a saved/loaded rig recreates its authored input. Defaults to `false`.
/// - Throws: `PresetError.unsupportedVersion` for a too-new snapshot, or any board-build error. /// - Throws: `PresetError.unsupportedVersion` for a too-new snapshot, or any board-build error.
public func loadRig(from state: ShoeGazeState) throws { public func loadRig(
from state: ShoeGazeState,
keepingCurrentInput: Bool = false
) throws {
guard state.version <= presetFormatVersion else { guard state.version <= presetFormatVersion else {
throw PresetError.unsupportedVersion(state.version) throw PresetError.unsupportedVersion(state.version)
} }
@@ -120,11 +129,12 @@ extension ShoeGaze {
// enable-live-input flow (rebuild engine to 1 input, then load a rig saved with 0). Apply a // enable-live-input flow (rebuild engine to 1 input, then load a rig saved with 0). Apply a
// rig's saved layout deliberately via `applyChannelLayout(from:)` / the config UI instead. // rig's saved layout deliberately via `applyChannelLayout(from:)` / the config UI instead.
// Restore the saved input source before rebuilding, since board construction reads it. A // Restore the saved input source before rebuilding, since board construction reads it — unless
// saved live-input channel that no longer exists on this engine falls back to the test loop // the caller is switching rigs (`keepingCurrentInput`), in which case the current input is
// (same guard as reconfigureEngine), so the rebuild's addBoard() can't throw on a stale // kept so the player's live input survives the switch. A saved live-input channel that no
// channel. Absent (older rig) → leave the current input source untouched. // longer exists on this engine falls back to the test loop (same guard as reconfigureEngine),
if let savedInput: InputSource = state.inputSource { // so the rebuild's addBoard() can't throw on a stale channel. Absent (older rig) → untouched.
if !keepingCurrentInput, let savedInput: InputSource = state.inputSource {
if case .liveInput(let channel) = savedInput, if case .liveInput(let channel) = savedInput,
channel < 0 || channel >= engine.numInputChannels { channel < 0 || channel >= engine.numInputChannels {
inputSource = .testLoop inputSource = .testLoop
@@ -26,6 +26,7 @@ struct RigLibrarySidebarView: View {
private static let subtitleOpacity: Double = 0.5 private static let subtitleOpacity: Double = 0.5
private static let headerOpacity: Double = 0.65 private static let headerOpacity: Double = 0.65
private static let emptyOpacity: Double = 0.4 private static let emptyOpacity: Double = 0.4
private static let tabPickerWidth: CGFloat = 168
// MARK: - Inputs // MARK: - Inputs
@@ -139,7 +140,7 @@ struct RigLibrarySidebarView: View {
} }
} }
/// Segmented Mine / Starters switch at the top of the list. /// Segmented Mine / Starters switch, centered at the top of the list.
private var tabPicker: some View { private var tabPicker: some View {
Picker("", selection: $tab) { Picker("", selection: $tab) {
ForEach(RigTab.allCases) { option in ForEach(RigTab.allCases) { option in
@@ -148,6 +149,9 @@ struct RigLibrarySidebarView: View {
} }
.pickerStyle(.segmented) .pickerStyle(.segmented)
.labelsHidden() .labelsHidden()
// Constrain the control's own width, then center it in the full column width.
.frame(maxWidth: RigLibrarySidebarView.tabPickerWidth)
.frame(maxWidth: .infinity, alignment: .center)
} }
/// The user's own rigs — a flat, reorderable list. /// The user's own rigs — a flat, reorderable list.
@@ -1640,7 +1640,9 @@ public struct ShoeGazeBuilderView: View {
let wasRunning: Bool = shoeGaze.engine.isRunning let wasRunning: Bool = shoeGaze.engine.isRunning
if wasRunning { shoeGaze.engine.stop() } if wasRunning { shoeGaze.engine.stop() }
do { do {
try shoeGaze.loadRig(from: entry.state) // Keep the player's currently-chosen input across the switch (e.g. a live guitar), rather
// than snapping to the input the selected rig was authored with.
try shoeGaze.loadRig(from: entry.state, keepingCurrentInput: true)
currentRigID = entry.id currentRigID = entry.id
selectedBoardIndex = 0 selectedBoardIndex = 0
autosave() autosave()
+52 -22
View File
@@ -422,11 +422,13 @@ struct PresetTests {
try sg.loadRig(from: presetURL) try sg.loadRig(from: presetURL)
#expect(abs(sg.clock.bpm - savedBpm) < 1e-9, "bpm should restore to \(savedBpm)") #expect(abs(sg.clock.bpm - savedBpm) < 1e-9, "bpm should restore to \(savedBpm)")
#expect(sg.tempoEnabled == false, "tempoEnabled should restore to false") #expect(sg.tempoEnabled == false, "tempoEnabled should restore to false")
#expect(sg.inputSource == .testLoop, "input source should restore to test loop") // Input is a live session setting, not part of the recalled rig: the session was on the test
// loop and stays there (load never changes the current input).
#expect(sg.inputSource == .testLoop, "load leaves the current input source unchanged")
} }
@Test func liveInputSourcePersistsAndFallsBackWhenChannelMissing() throws { @Test func loadPreservesCurrentInputSourceNotTheSavedOne() throws {
// Engine WITH an input channel: a live-input rig round-trips its source. // A rig captured with live input still RECORDS its source in the snapshot...
let (engineIn, urlIn): (SynthesisEngine, URL) = makeNRTEngine( let (engineIn, urlIn): (SynthesisEngine, URL) = makeNRTEngine(
duration: 0.1, duration: 0.1,
numInputChannels: 1, numInputChannels: 1,
@@ -434,29 +436,57 @@ struct PresetTests {
) )
defer { try? FileManager.default.removeItem(at: urlIn) } defer { try? FileManager.default.removeItem(at: urlIn) }
let sgIn: ShoeGaze = ShoeGaze(engine: engineIn, inputSource: .liveInput(channel: 0)) let sgIn: ShoeGaze = ShoeGaze(engine: engineIn, inputSource: .liveInput(channel: 0))
let board: PedalBoard = try sgIn.addBoard() let liveBoard: PedalBoard = try sgIn.addBoard()
try board.add(OverdrivePedal()) try liveBoard.add(OverdrivePedal())
try sgIn.finalizeBoard(board) try sgIn.finalizeBoard(liveBoard)
let liveState: ShoeGazeState = sgIn.captureState()
#expect(liveState.inputSource == .liveInput(channel: 0), "capture records the live input")
let state: ShoeGazeState = sgIn.captureState() // ...but loading a rig NEVER switches the session's current input — switching rigs keeps
#expect(state.inputSource == .liveInput(channel: 0), "capture should record the live input") // whatever input the player has chosen. Here a test-loop session loads a live-input rig on an
// engine that DOES have the channel: under the old "restore saved input" behaviour this would
// Reload into the same input-capable engine: source preserved. // become live input; the new behaviour leaves it on the test loop.
try sgIn.loadRig(from: state) let (engineA, urlA): (SynthesisEngine, URL) = makeNRTEngine(
#expect(sgIn.inputSource == .liveInput(channel: 0), "live input should round-trip")
// loadRig does NOT auto-apply the saved channel layout, so loading into an engine with no
// input channels falls back to the test loop rather than clobbering the engine's config.
let (engineNoIn, urlNoIn): (SynthesisEngine, URL) = makeNRTEngine(
duration: 0.1, duration: 0.1,
numInputChannels: 0, numInputChannels: 1,
numAudioBuses: 128 numAudioBuses: 128
) )
defer { try? FileManager.default.removeItem(at: urlNoIn) } defer { try? FileManager.default.removeItem(at: urlA) }
let sgNoIn: ShoeGaze = ShoeGaze(engine: engineNoIn) let sgA: ShoeGaze = ShoeGaze(engine: engineA) // defaults to .testLoop
try sgNoIn.loadRig(from: state) try sgA.loadRig(from: liveState, keepingCurrentInput: true)
#expect(engineNoIn.numInputChannels == 0, "loadRig must not reconfigure the engine's I/O") #expect(sgA.inputSource == .testLoop, "switch must keep the current input, not adopt the rig's")
#expect(sgNoIn.inputSource == .testLoop, "missing channel should fall back to test loop")
// The reverse: a live-input session loading a test-loop rig stays on live input.
let (engineB, urlB): (SynthesisEngine, URL) = makeNRTEngine(
duration: 0.1,
numInputChannels: 1,
numAudioBuses: 128
)
defer { try? FileManager.default.removeItem(at: urlB) }
let sgTestLoop: ShoeGaze = ShoeGaze(engine: engineB) // .testLoop
let plainBoard: PedalBoard = try sgTestLoop.addBoard()
try plainBoard.add(OverdrivePedal())
try sgTestLoop.finalizeBoard(plainBoard)
let testLoopState: ShoeGazeState = sgTestLoop.captureState()
#expect(testLoopState.inputSource == .testLoop)
sgIn.currentRigID = nil
try sgIn.loadRig(from: testLoopState, keepingCurrentInput: true)
#expect(sgIn.inputSource == .liveInput(channel: 0),
"switch must keep the current live input, not adopt the rig's test loop")
// A default load (file open / launch restore) still applies the rig's saved input.
let (engineC, urlC): (SynthesisEngine, URL) = makeNRTEngine(
duration: 0.1, numInputChannels: 1, numAudioBuses: 128
)
defer { try? FileManager.default.removeItem(at: urlC) }
let sgDefault: ShoeGaze = ShoeGaze(engine: engineC) // .testLoop
try sgDefault.loadRig(from: liveState) // default: restore saved input
#expect(sgDefault.inputSource == .liveInput(channel: 0),
"a default load restores the rig's saved input")
// loadRig still never reconfigures the engine's channel layout.
#expect(engineA.numInputChannels == 1, "loadRig must not reconfigure the engine's I/O")
} }
@Test func channelCountsPersistButLoadDoesNotReconfigure() throws { @Test func channelCountsPersistButLoadDoesNotReconfigure() throws {