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:
@@ -194,13 +194,15 @@ public enum FactoryRigLibrary {
|
||||
}
|
||||
try board.append(DelayPedal()) { p in
|
||||
p.time = 0.4
|
||||
p.feedback = 2.2
|
||||
p.feedback = 1.5
|
||||
}
|
||||
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.decay = 0.85
|
||||
p.shimmer = 0.55
|
||||
p.damp = 0.35
|
||||
p.decay = 0.55
|
||||
p.shimmer = 0.3
|
||||
p.damp = 0.5
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,64 +648,61 @@ public enum FactoryRigLibrary {
|
||||
|
||||
// MARK: Two-board split
|
||||
|
||||
/// A two-board split — a full effects chain vs a clean direct path — selectable like an on-board
|
||||
/// effects loop. Showcases the multi-board router.
|
||||
/// Two boards — a full effects chain and a clean direct path — switched with the board selector.
|
||||
static let garciaOBELSplit: FactoryRig = FactoryRig(
|
||||
id: stableID("Garcia OBEL Split"),
|
||||
name: "Garcia OBEL Clean/Effects Split",
|
||||
blurb: "Two boards, one footswitch: an effects/lead chain (octave, envelope filter, "
|
||||
+ "overdrive, phaser, delay) versus a clean direct path — switch between them like an "
|
||||
+ "on-board effects loop. In the spirit of a certain improvising guitarist's late-'80s "
|
||||
+ "rig. Flip the router to A for effects, B for clean.",
|
||||
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.",
|
||||
category: .classic,
|
||||
sessionBuild: { session in
|
||||
let router: ChainRouter = try session.makeChainRouter()
|
||||
|
||||
// Board A — the effects / lead chain (effects loop engaged).
|
||||
try router.appendToA(BassOctaverPedal()) { p 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 router.appendToA(MutantPedal()) { p in
|
||||
try effects.append(MutantPedal()) { p in
|
||||
p.sensitivity = 2.5
|
||||
p.resonance = 5.0
|
||||
}
|
||||
try router.appendToA(OverdrivePedal()) { p in
|
||||
try effects.append(OverdrivePedal()) { p in
|
||||
p.drive = 5.0
|
||||
p.tone = 4200.0
|
||||
}
|
||||
try router.appendToA(PhaserPedal()) { p in
|
||||
try effects.append(PhaserPedal()) { p in
|
||||
p.rate = 0.4
|
||||
p.feedback = 0.4
|
||||
}
|
||||
try router.appendToA(DelayPedal()) { p in
|
||||
try effects.append(DelayPedal()) { p in
|
||||
p.time = 0.35
|
||||
p.feedback = 1.8
|
||||
}
|
||||
try router.appendToA(CaliforniaAmpPedal()) { p in
|
||||
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)
|
||||
|
||||
// Board B — the clean / direct path (effects loop bypassed).
|
||||
try router.appendToB(CompressorPedal()) { p in
|
||||
// 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 router.appendToB(CaliforniaAmpPedal()) { p in
|
||||
try clean.append(CaliforniaAmpPedal()) { p in
|
||||
p.gain = 3.5
|
||||
p.bass = 0.5
|
||||
p.mid = 0.55
|
||||
p.treble = 0.6
|
||||
}
|
||||
|
||||
// Default to the effects board; the router's A/B control switches paths.
|
||||
router.mode = .a
|
||||
try router.finalize()
|
||||
try session.finalizeBoard(clean)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -107,9 +107,18 @@ extension ShoeGaze {
|
||||
/// rebuilds every board with the all-or-nothing semantics of ``rebuildAllBoards(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.
|
||||
public func loadRig(from state: ShoeGazeState) throws {
|
||||
public func loadRig(
|
||||
from state: ShoeGazeState,
|
||||
keepingCurrentInput: Bool = false
|
||||
) throws {
|
||||
guard state.version <= presetFormatVersion else {
|
||||
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
|
||||
// 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
|
||||
// saved live-input channel that no longer exists on this engine falls back to the test loop
|
||||
// (same guard as reconfigureEngine), so the rebuild's addBoard() can't throw on a stale
|
||||
// channel. Absent (older rig) → leave the current input source untouched.
|
||||
if let savedInput: InputSource = state.inputSource {
|
||||
// Restore the saved input source before rebuilding, since board construction reads it — unless
|
||||
// the caller is switching rigs (`keepingCurrentInput`), in which case the current input is
|
||||
// kept so the player's live input survives the switch. A saved live-input channel that no
|
||||
// longer exists on this engine falls back to the test loop (same guard as reconfigureEngine),
|
||||
// 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,
|
||||
channel < 0 || channel >= engine.numInputChannels {
|
||||
inputSource = .testLoop
|
||||
|
||||
@@ -26,6 +26,7 @@ struct RigLibrarySidebarView: View {
|
||||
private static let subtitleOpacity: Double = 0.5
|
||||
private static let headerOpacity: Double = 0.65
|
||||
private static let emptyOpacity: Double = 0.4
|
||||
private static let tabPickerWidth: CGFloat = 168
|
||||
|
||||
// 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 {
|
||||
Picker("", selection: $tab) {
|
||||
ForEach(RigTab.allCases) { option in
|
||||
@@ -148,6 +149,9 @@ struct RigLibrarySidebarView: View {
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
.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.
|
||||
|
||||
@@ -1640,7 +1640,9 @@ public struct ShoeGazeBuilderView: View {
|
||||
let wasRunning: Bool = shoeGaze.engine.isRunning
|
||||
if wasRunning { shoeGaze.engine.stop() }
|
||||
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
|
||||
selectedBoardIndex = 0
|
||||
autosave()
|
||||
|
||||
@@ -422,11 +422,13 @@ struct PresetTests {
|
||||
try sg.loadRig(from: presetURL)
|
||||
#expect(abs(sg.clock.bpm - savedBpm) < 1e-9, "bpm should restore to \(savedBpm)")
|
||||
#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 {
|
||||
// Engine WITH an input channel: a live-input rig round-trips its source.
|
||||
@Test func loadPreservesCurrentInputSourceNotTheSavedOne() throws {
|
||||
// A rig captured with live input still RECORDS its source in the snapshot...
|
||||
let (engineIn, urlIn): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.1,
|
||||
numInputChannels: 1,
|
||||
@@ -434,29 +436,57 @@ struct PresetTests {
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: urlIn) }
|
||||
let sgIn: ShoeGaze = ShoeGaze(engine: engineIn, inputSource: .liveInput(channel: 0))
|
||||
let board: PedalBoard = try sgIn.addBoard()
|
||||
try board.add(OverdrivePedal())
|
||||
try sgIn.finalizeBoard(board)
|
||||
let liveBoard: PedalBoard = try sgIn.addBoard()
|
||||
try liveBoard.add(OverdrivePedal())
|
||||
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()
|
||||
#expect(state.inputSource == .liveInput(channel: 0), "capture should record the live input")
|
||||
|
||||
// Reload into the same input-capable engine: source preserved.
|
||||
try sgIn.loadRig(from: state)
|
||||
#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(
|
||||
// ...but loading a rig NEVER switches the session's current input — switching rigs keeps
|
||||
// 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
|
||||
// become live input; the new behaviour leaves it on the test loop.
|
||||
let (engineA, urlA): (SynthesisEngine, URL) = makeNRTEngine(
|
||||
duration: 0.1,
|
||||
numInputChannels: 0,
|
||||
numInputChannels: 1,
|
||||
numAudioBuses: 128
|
||||
)
|
||||
defer { try? FileManager.default.removeItem(at: urlNoIn) }
|
||||
let sgNoIn: ShoeGaze = ShoeGaze(engine: engineNoIn)
|
||||
try sgNoIn.loadRig(from: state)
|
||||
#expect(engineNoIn.numInputChannels == 0, "loadRig must not reconfigure the engine's I/O")
|
||||
#expect(sgNoIn.inputSource == .testLoop, "missing channel should fall back to test loop")
|
||||
defer { try? FileManager.default.removeItem(at: urlA) }
|
||||
let sgA: ShoeGaze = ShoeGaze(engine: engineA) // defaults to .testLoop
|
||||
try sgA.loadRig(from: liveState, keepingCurrentInput: true)
|
||||
#expect(sgA.inputSource == .testLoop, "switch must keep the current input, not adopt the rig's")
|
||||
|
||||
// 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 {
|
||||
|
||||
Reference in New Issue
Block a user