The rig snapshot already stores inputSource + input/output channel counts and syncs them via the autosave envelope and the iCloud rig library. Make that the single source of truth instead of the parallel UserDefaults path. - RigStore.restore applies the saved channel layout (applyChannelLayout) before loadRig, while stopped at launch, so a saved live-input channel validates against the restored count instead of falling back to the test loop. The general loadRig policy (don't force layout mid-session) is unchanged. - applyInputSource and the engine-config onConfigApplied now autosave, so input and I/O changes are captured into the rig immediately. - Remove the UserDefaults keys and read/write sites: ShoeGaze.inputSelection (builder view + iOS model) and the ShoeGaze.inputChannels/outputChannels keys added earlier (EngineConfigView + both app targets build at the default layout now; RigStore.restore supplies the rig's layout). - Fresh-launch default: the seed paths set inputSource = liveInput(0) when the engine has an input channel, so a first launch listens to the instrument. A restored rig keeps its own saved input; the view's on-appear hook only requests mic access for a restored live selection (test-loop fallback on denial). Test: RigStore.restoreAppliesSavedChannelLayoutAndInput. 461 tests pass; both app targets build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4.4 KiB
2.1.1 — Input mute + I/O persistence
Two small, related fixes to cut down accidental noise at engine start and make the input configuration survive relaunch.
(a) Input mute toggle
A hard mute on the input feeding every board (the guitar / mic signal), distinct from the existing rig-output mute. Goals:
- Defaults muted, and is re-asserted muted every time the engine is (user-)started, so a fresh start is silent until the player un-mutes — kills accidental ruckus.
- A toggle button sits next to the Start/Stop transport.
- MIDI mappable (Program Change + computer key), like Rig Mute.
- Also default the input source to In 0 (live input) instead of the test-loop arpeggio.
RT graph
Each board's input writer (TestLoopTap in test-loop mode, HardwareInputPassThrough
in live mode) gains an @UIParam inputMute (0 = audible, 1 = muted). build() multiplies
the copied signal by a lagged mute gain (20 ms, click-free), mirroring
BoardOutputMaster.rigOutputGainStage().
ShoeGaze
public private(set) var inputMuted: Bool = truesetInputMuted(_:)drives everytestLoopTaps+inputPassThroughsmute node;toggleInputMuted().addBoard()sets each new input node's mute to the currentinputMutedso rebuilds stay consistent.
Engine start
EngineConfigView.startEngine() calls shoeGaze.setInputMuted(true) after a successful
user Start. Transient stop/start-around-rebuild paths (applyInputSource, performClear)
call engine.start() directly and are unaffected — they preserve the current mute state.
MIDI
MIDIMap.Action.inputMuteMIDIController.perform→toggleInputMuted();hint→ nil.MIDIMappingSheetswitch row "Input Mute".
Default to In 0
ShoeGazeBuilderView.restoreInputSelection() first-launch (no saved choice) branch requests
mic access and selects .liveInput(channel: 0) (falling back to test loop on denial / no
input), instead of only auto-selecting when already authorised.
(b) Persist In/Out + input via the rig (iCloud), not UserDefaults
The rig snapshot (ShoeGazeState) already persists inputSource, numInputChannels,
and numOutputChannels, and the autosave envelope + rig library (iCloud) already carry
them. Two problems remained:
loadRig(from:)deliberately does not apply the saved channel layout (forcing it on every mid-session load would fight the global engine config / the iOS live-input rebuild). So at launch, the engine kept the app default (1 in / 2 out); a saved live-input channel>=that count failed validation and fell back to the test loop — the "In doesn't persist" bug.- A second, competing persistence path (
ShoeGazeBuilderView's UserDefaultsShoeGaze.inputSelection, plus the iOS model's copy) fought the rig's owninputSource.
Fix — make the rig the single source of truth:
- Launch applies the saved layout.
RigStore.restorecallsapplyChannelLayout(from: state)beforeloadRig, while the engine is stopped, so the input-channel validation runs against the restored count. A launch restore is exactly the place this is wanted (unlike a mid-session load), so the generalloadRigpolicy is unchanged. - Input changes autosave.
applyInputSource/ the engine-configonConfigAppliedcallautosave(), so a changed input or I/O layout is captured into the rig immediately. - Removed both UserDefaults paths. The
ShoeGaze.inputSelection/ShoeGaze.inputChannels/ShoeGaze.outputChannelskeys and their read/write sites (view + both app targets) are deleted. The app targets build the engine at the default layout;RigStore.restoresupplies the rig's layout. - Fresh-launch default. When there is no autosaved rig, the seed paths
(
AppDelegate.seedInitialBoard/ iOSseedFallbackBoard) setinputSource = .liveInput(0)when the engine has an input channel, so a first launch listens to the instrument rather than the test loop. A restored rig keeps its own saved input. The builder view's on-appear hook now only requests mic access for a restored live-input selection (falling back to the test loop on denial).
Tests
InputMuteTests—HardwareInputPassThrough/TestLoopTapmute gain;ShoeGaze.setInputMuteddrives all input nodes;addBoardbrings a new board up at the current mute state.MIDIController— aninputMuteswitch action togglesshoeGaze.inputMuted.