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:
@@ -37,6 +37,9 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
/// UserDefaults key persisting the input selection. Must match the key written by the
|
||||
/// builder view (`ShoeGazeBuilderView.inputSelectionDefaultsKey`).
|
||||
private static let inputSelectionDefaultsKey: String = "ShoeGaze.inputSelection"
|
||||
/// UserDefaults key persisting the last-used output-channel count. Must match the key written by
|
||||
/// the builder's engine-config UI (`EngineConfigView.outputChannelsDefaultsKey`).
|
||||
private static let outputChannelsDefaultsKey: String = "ShoeGaze.outputChannels"
|
||||
/// Persisted value meaning "live input, channel 0".
|
||||
private static let liveInputChannelZeroTag: Int = 0
|
||||
|
||||
@@ -144,10 +147,17 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
) -> (engine: SynthesisEngine, driver: iOSAudioDriver, shoeGaze: ShoeGaze) {
|
||||
let sampleRate: Double = AVAudioSession.sharedInstance().sampleRate
|
||||
let driver: iOSAudioDriver = iOSAudioDriver()
|
||||
// Restore the last-used output count so it survives relaunch (input stays on the
|
||||
// permission-gated rebuild flow). Falls back to the default on first launch.
|
||||
let defaults: UserDefaults = UserDefaults.standard
|
||||
let maximumChannels: Int = 8
|
||||
let restoredOutputs: Int = defaults.object(forKey: outputChannelsDefaultsKey) != nil
|
||||
? max(1, min(defaults.integer(forKey: outputChannelsDefaultsKey), maximumChannels))
|
||||
: ShoeGazeBuilderiOSAppModel.outputChannels
|
||||
let engine: SynthesisEngine = SynthesisEngine(
|
||||
blockSize: ShoeGazeBuilderiOSAppModel.blockSize,
|
||||
sampleRate: sampleRate,
|
||||
numOutputChannels: ShoeGazeBuilderiOSAppModel.outputChannels,
|
||||
numOutputChannels: restoredOutputs,
|
||||
numInputChannels: inputChannels,
|
||||
numAudioBuses: ShoeGazeBuilderiOSAppModel.numAudioBuses,
|
||||
driver: driver
|
||||
|
||||
Reference in New Issue
Block a user