Non-blocking cleanups from the clean review pass: - EngineConfigView.startEngine: collapse the redundant early-return in the sample-rate-mismatch branch into the shared tail. - InputMuteButton: hoist the 0.2s settle duration to a named pulseSettleDuration. - InputMuteTests: correct a stale "input defaults muted" comment (library default is audible; the test mutes explicitly). - Plan doc: setInputMuted(true) runs before engine.start(), not after; note the addBoard priming. 464 tests pass; macOS app builds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5.1 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:
- The app re-asserts it muted every time the engine is (user-)started, so a fresh start is silent until the player un-mutes — kills accidental ruckus. (The library-level default is audible; muting is the app's Start-time policy, so headless / offline library use isn't forced silent.)
- 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 hard gain (inputMute − 1)·−1 — an un-lagged kill switch. (A lagged
gate never settles to exactly zero on its first blocks and leaks a faint transient at the very
moment the mute is meant to keep things quiet; a kill-switch mute is expected to be abrupt.)
ShoeGaze
public private(set) var inputMuted: Bool = false(app mutes on Start)setInputMuted(_:)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) before
engine.start(), while the engine is stopped — so the gain is seeded (previousOutputValue
primed to the target, no ramp) and the very first render block is already muted. Asserting it
after start would leave the opening blocks unmuted. Transient stop/start-around-rebuild paths
(applyInputSource, performClear) call engine.start() directly and are unaffected — they
preserve the current mute state. Nodes are also primed at creation in addBoard() (before the
node is spliced into the graph), so a board added while muted has no first-block leak either.
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. - No UserDefaults path. The
ShoeGaze.inputSelectionkey and its read/write sites (builder view + iOS model) are removed; the engine channel counts are never persisted to UserDefaults at all. The app targets build the engine at the default layout;RigStore.restoresupplies the rig's saved 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.