Review fix: exact-silence input mute (hard kill-switch gate)

External review found the lagged mute gate leaks a faint transient (~-54 dB) on
its first blocks: Lag seeds its state at 0, so gating on a lagged value never
starts at exactly zero on a rig that comes up muted — the moment the mute is
meant to keep things quiet. Measured directly via an NRT render.

- Gate the input with a hard, un-lagged kill switch `(inputMute - 1) * -1` in
  both HardwareInputPassThrough and TestLoopTap. A muted node is then exactly
  silent from the first sample; a kill-switch mute is expected to be abrupt.
  Drop the now-unused muteLagTime constant.
- Flip the library default to `inputMuted = false` (audible). Muting is the app's
  Start-time policy (EngineConfigView already re-asserts muted on user Start), so
  headless/offline library use isn't forced silent and render tests that route the
  test-loop through a board no longer depend on a leak to see signal. The pulsing
  glow now also starts at engine Start rather than before it.
- Tests: add render-level mutedInputRendersSilent (exact silence) and
  unmutedInputRendersSignal; update the default-state and MIDI-latch expectations;
  drop the StereoRouting un-mutes that the leak had made necessary.
- Plan doc: correct the mute default / gate description and the UserDefaults note.

463 tests pass; both app targets build.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-11 16:03:50 -07:00
parent be0e3d118b
commit b29c8848ef
7 changed files with 89 additions and 48 deletions
@@ -8,8 +8,10 @@ input configuration survive relaunch.
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.
- 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.
@@ -18,12 +20,13 @@ from the existing rig-**output** mute. Goals:
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()`.
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 = true`
- `public private(set) var inputMuted: Bool = false` (app mutes on Start)
- `setInputMuted(_:)` drives every `testLoopTaps` + `inputPassThroughs` mute node; `toggleInputMuted()`.
- `addBoard()` sets each new input node's mute to the current `inputMuted` so rebuilds stay consistent.
@@ -68,10 +71,10 @@ Fix — make the rig the single source of truth:
unchanged.
- **Input changes autosave.** `applyInputSource` / the engine-config `onConfigApplied` call
`autosave()`, so a changed input or I/O layout is captured into the rig immediately.
- **Removed both UserDefaults paths.** The `ShoeGaze.inputSelection` / `ShoeGaze.inputChannels`
/ `ShoeGaze.outputChannels` keys and their read/write sites (view + both app targets) are
deleted. The app targets build the engine at the default layout; `RigStore.restore` supplies
the rig's layout.
- **No UserDefaults path.** The `ShoeGaze.inputSelection` key 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.restore` supplies the
rig's saved layout.
- **Fresh-launch default.** When there is no autosaved rig, the seed paths
(`AppDelegate.seedInitialBoard` / iOS `seedFallbackBoard`) set `inputSource = .liveInput(0)`
when the engine has an input channel, so a first launch listens to the instrument rather