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:
@@ -31,6 +31,10 @@ public struct EngineConfigView: View {
|
||||
/// Channel-count stepper bounds.
|
||||
private static let maxInputs: Int = 8
|
||||
private static let maxOutputs: Int = 8
|
||||
/// UserDefaults keys persisting the last-used engine channel counts so they survive relaunch.
|
||||
/// The app targets read these when constructing the engine (fallback to their own defaults).
|
||||
static let inputChannelsDefaultsKey: String = "ShoeGaze.inputChannels"
|
||||
static let outputChannelsDefaultsKey: String = "ShoeGaze.outputChannels"
|
||||
/// Sample-rate comparison tolerance in Hz.
|
||||
private static let rateEpsilon: Double = 0.5
|
||||
private static let rowSpacing: CGFloat = 12
|
||||
@@ -162,12 +166,21 @@ public struct EngineConfigView: View {
|
||||
outputChannels: pendingOutputs
|
||||
)
|
||||
}
|
||||
persistChannelCounts()
|
||||
onConfigApplied()
|
||||
} catch {
|
||||
print("[EngineConfigView] live reconfigure failed: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
/// Persists the current channel counts so the next launch rebuilds the engine with the same
|
||||
/// I/O. Read by the app targets at engine-construction time.
|
||||
private func persistChannelCounts() {
|
||||
let defaults: UserDefaults = UserDefaults.standard
|
||||
defaults.set(pendingInputs, forKey: EngineConfigView.inputChannelsDefaultsKey)
|
||||
defaults.set(pendingOutputs, forKey: EngineConfigView.outputChannelsDefaultsKey)
|
||||
}
|
||||
|
||||
private func label(_ text: String) -> some View {
|
||||
Text(text)
|
||||
.font(.subheadline)
|
||||
@@ -192,6 +205,7 @@ public struct EngineConfigView: View {
|
||||
outputChannels: pendingOutputs
|
||||
)
|
||||
}
|
||||
persistChannelCounts()
|
||||
}
|
||||
try shoeGaze.engine.start()
|
||||
} catch {
|
||||
@@ -207,7 +221,14 @@ public struct EngineConfigView: View {
|
||||
abs(hardware - shoeGaze.engine.sampleRate) > EngineConfigView.rateEpsilon {
|
||||
shoeGaze.engine.stop()
|
||||
presentMismatch(requested: shoeGaze.engine.sampleRate, hardware: hardware)
|
||||
transportTick.toggle()
|
||||
onConfigApplied()
|
||||
return
|
||||
}
|
||||
// A deliberate user start comes up with the input muted so accidental noise can't leak the
|
||||
// instant the engine spins up — the player un-mutes when ready. Transient stop/start-around-
|
||||
// rebuild paths call `engine.start()` directly and are unaffected.
|
||||
shoeGaze.setInputMuted(true)
|
||||
transportTick.toggle()
|
||||
onConfigApplied()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user