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
@@ -38,11 +38,6 @@ final class HardwareInputPassThrough: SynthesizerBase {
/// Index of the board head bus to write to.
private let outputBusIndex: Int
// MARK: - Constants
/// Lag time in seconds for the mute transition — smooths audible ↔ muted to prevent clicks.
private let muteLagTime: Double = 0.02
// MARK: - Init
/// Creates a pass-through that copies `inputBusIndex` to `outputBusIndex`.
@@ -60,9 +55,11 @@ final class HardwareInputPassThrough: SynthesizerBase {
// MARK: - Build
override func build() {
// Gate the copied signal by a lagged mute: mute 0 → gain 1 (audible), 1 → gain 0 (silent).
let muteLagged: Lag.Control = Lag.Control(input: $inputMute, time: muteLagTime)
let muteGain: any ValidGeneratorInput = (muteLagged - 1.0) * -1.0
// Hard kill-switch gate: `1 − inputMute`, so mute 0 → gain 1 (audible), 1 → gain 0 (exactly
// silent). Unlagged on purpose — a lagged gate never settles to exactly zero on its first
// blocks and leaks a faint transient right when the mute is meant to keep things quiet; a
// kill-switch mute is expected to be abrupt anyway.
let muteGain: any ValidGeneratorInput = ($inputMute - 1.0) * -1.0
output(bus: outputBusIndex, source: input(bus: inputBusIndex) * muteGain)
}
}
@@ -38,11 +38,6 @@ final class TestLoopTap: SynthesizerBase {
/// Index of the board head bus to write to.
private let outputBusIndex: Int
// MARK: - Constants
/// Lag time in seconds for the mute transition — smooths audible ↔ muted to prevent clicks.
private let muteLagTime: Double = 0.02
// MARK: - Init
/// Creates a tap that copies `inputBusIndex` (the global test bus) to `outputBusIndex`
@@ -60,9 +55,11 @@ final class TestLoopTap: SynthesizerBase {
// MARK: - Build
override func build() {
// Gate the copied signal by a lagged mute: mute 0 → gain 1 (audible), 1 → gain 0 (silent).
let muteLagged: Lag.Control = Lag.Control(input: $inputMute, time: muteLagTime)
let muteGain: any ValidGeneratorInput = (muteLagged - 1.0) * -1.0
// Hard kill-switch gate: `1 − inputMute`, so mute 0 → gain 1 (audible), 1 → gain 0 (exactly
// silent). Unlagged on purpose — a lagged gate never settles to exactly zero on its first
// blocks and leaks a faint transient right when the mute is meant to keep things quiet; a
// kill-switch mute is expected to be abrupt anyway.
let muteGain: any ValidGeneratorInput = ($inputMute - 1.0) * -1.0
output(bus: outputBusIndex, source: input(bus: inputBusIndex) * muteGain)
}
}
+7 -5
View File
@@ -436,9 +436,11 @@ public final class ShoeGaze {
public private(set) var rigMuted: Bool = false
/// `true` when the **input** feeding every board is muted — the incoming guitar / mic signal,
/// distinct from ``rigMuted`` (the output). Defaults `true` and is re-asserted on each user
/// engine start so a fresh start is silent until the player un-mutes. See ``setInputMuted(_:)``.
public private(set) var inputMuted: Bool = true
/// distinct from ``rigMuted`` (the output). Defaults `false` (audible); the app re-asserts it
/// muted on each user engine start (see `EngineConfigView`) so a fresh start is silent until the
/// player un-mutes, without forcing silence on headless / offline library use. See
/// ``setInputMuted(_:)``.
public private(set) var inputMuted: Bool = false
/// Identities of boards currently in per-board full bypass. Observable so UI toggles refresh;
/// authoritative bypass value lives on each board's `boardBypassNode`. Transient (not persisted).
@@ -596,8 +598,8 @@ public final class ShoeGaze {
/// distinct from the rig-output ``setRigMuted(_:)``. Applied to every board's input writer
/// (test-loop tap or hardware pass-through), smoothed to avoid clicks.
///
/// Defaults muted (``inputMuted`` starts `true`) and is re-asserted on each user engine start
/// so a fresh start is silent until the player un-mutes — preventing accidental input noise.
/// The app re-asserts this muted on each user engine start (see `EngineConfigView`) so a fresh
/// start is silent until the player un-mutes — preventing accidental input noise.
///
/// - Parameter muted: `true` to silence the input, `false` to let it through.
public func setInputMuted(_ muted: Bool) {