Add input mute + persist engine I/O counts

Input mute: a hard gate on the signal feeding every board (guitar / mic),
distinct from the rig-output mute. Each board input writer (TestLoopTap /
HardwareInputPassThrough) gains a lagged @UIParam mute gain; ShoeGaze holds
inputMuted (default true), drives every input node, and brings newly-added
boards up at the current state. A deliberate user Start re-asserts the mute so
a fresh engine is silent until the player un-mutes — cutting accidental noise.
Toggle sits beside the Start/Stop transport and is MIDI mappable
(MIDIMap.Action.inputMute). First launch now defaults to live In 0 instead of
the test-loop arpeggio.

I/O persistence: the engine's input/output channel counts now persist to
UserDefaults (written by EngineConfigView, restored by the app targets at
engine construction), so a multi-channel setup survives relaunch and a saved
live-input channel stays valid — fixing the input selection reverting to the
test loop after a restart.

Tests: InputMuteTests (default-muted, node driving, per-board adoption, live
path) + a MIDI PC input-mute latch test. StereoRouting render tests un-mute
before rendering. 460 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-11 15:17:51 -07:00
parent f61961b90b
commit 5987ec7b78
14 changed files with 382 additions and 8 deletions
+39
View File
@@ -302,6 +302,7 @@ public final class ShoeGaze {
outputBusIndex: board.headBus.index
)
try engine.add(tap, position: NodePosition.after(source))
tap.inputMuteNode.update(inputMuted ? 1.0 : 0.0)
testLoopTaps.append(tap)
// Record the tap as the head input node so PedalBoard.add(_:) can chain the first
// pedal after it automatically (without needing an explicit `after:`).
@@ -317,6 +318,7 @@ public final class ShoeGaze {
outputBusIndex: board.headBus.index
)
try engine.add(passThrough)
passThrough.inputMuteNode.update(inputMuted ? 1.0 : 0.0)
inputPassThroughs.append(passThrough)
board.headInputNode = passThrough
}
@@ -433,6 +435,11 @@ public final class ShoeGaze {
/// `true` when the rig output is muted (hard-silenced, not bypassed). Survives a rebuild.
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
/// 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).
public private(set) var bypassedBoards: Set<ObjectIdentifier> = []
@@ -585,6 +592,38 @@ public final class ShoeGaze {
setRigMuted(!rigMuted)
}
/// Mutes or un-mutes the **input** feeding every board — the incoming guitar / mic signal,
/// 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.
///
/// - Parameter muted: `true` to silence the input, `false` to let it through.
public func setInputMuted(_ muted: Bool) {
let value: Double = muted ? 1.0 : 0.0
for tap: TestLoopTap in testLoopTaps {
tap.inputMuteNode.update(value)
}
for passThrough: HardwareInputPassThrough in inputPassThroughs {
passThrough.inputMuteNode.update(value)
}
inputMuted = muted
}
/// Toggles the input mute. See ``setInputMuted(_:)``.
public func toggleInputMuted() {
setInputMuted(!inputMuted)
}
/// The live mute-gain values of every board input writer (test-loop taps and hardware
/// pass-throughs). `1` = muted, `0` = audible. Exposed for tests to confirm the RT nodes are
/// actually driven by ``setInputMuted(_:)``, not just the ``inputMuted`` flag.
var inputMuteNodeValues: [Double] {
testLoopTaps.map { $0.inputMuteNode.value }
+ inputPassThroughs.map { $0.inputMuteNode.value }
}
/// Removes a single board and its associated input source and output master from
/// the engine, then releases the board's buses. The other boards are unaffected.
///