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
@@ -85,18 +85,18 @@ struct MIDIControllerPCTests {
defer { try? FileManager.default.removeItem(at: url) }
withExtendedLifetime(sg) {
// A fresh session starts input-muted by default.
#expect(sg.inputMuted == true, "input defaults muted")
// A fresh library session starts audible (the app mutes on engine Start).
#expect(sg.inputMuted == false, "input defaults audible at the library level")
controller.armSwitchLearn(.inputMute)
controller.ingestForTesting(.programChange(channel: 0, program: 2)) // learn only
#expect(sg.inputMuted == true, "learn must not toggle")
#expect(sg.inputMuted == false, "learn must not toggle")
controller.ingestForTesting(.programChange(channel: 0, program: 2))
#expect(sg.inputMuted == false, "first press un-mutes the input")
#expect(sg.inputMuted == true, "first press mutes the input")
#expect(sg.rigMuted == false, "input mute must not touch the rig-output mute")
controller.ingestForTesting(.programChange(channel: 0, program: 2))
#expect(sg.inputMuted == true, "second press re-mutes the input")
#expect(sg.inputMuted == false, "second press un-mutes the input")
}
}