Review fix: prime input-mute ramp + mute before engine start
Two blocking findings from external review: 1. UIParamNode itself ramps from previousOutputValue (seeded at the compile-time default, advanced only by RT render — update() doesn't touch it) to the target over the first block. So a node told to start muted still ramped full-gain→0 across block 0; the earlier "hard gate" only moved the leak from Lag to the param's own ramp. The mutedInputRendersSilent test passed by accident (the test-loop tone is quiet in that first block). Fix: prime previousOutputValue to the target. Race-free before a node is spliced into the graph (addBoard) and safe on a spliced node while the engine is stopped; a running engine keeps the ramp as a click-free live toggle. New setInputMuteGain(_:muted:seedRamp:) / primeInputMute helpers; setInputMuted seeds only when engine.isRunning == false. 2. EngineConfigView.startEngine called setInputMuted(true) AFTER engine.start(), so the engine came up unmuted for the first blocks. Moved it before start() (engine stopped there, so the gain is seeded with no ramp). Also: correct the setInputMuted doc (abrupt kill-switch, not "smoothed"). Regression test stoppedMutePrimesNodesSoTheresNoStartRamp asserts the ramp start equals the target (no pending ramp) after a stopped mute and for a board added while muted. 464 tests pass; both app targets build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -193,6 +193,12 @@ public struct EngineConfigView: View {
|
||||
)
|
||||
}
|
||||
}
|
||||
// A deliberate user Start comes up with the input muted so accidental noise can't leak
|
||||
// the instant the engine spins up. Set it BEFORE start (engine is stopped here, so the
|
||||
// gain is seeded with no ramp) — asserting it after start would leave the first render
|
||||
// blocks unmuted. Transient stop/start-around-rebuild paths call `engine.start()`
|
||||
// directly and are unaffected — they preserve the current mute state.
|
||||
shoeGaze.setInputMuted(true)
|
||||
try shoeGaze.engine.start()
|
||||
} catch {
|
||||
handleStartError(error)
|
||||
@@ -211,10 +217,6 @@ public struct EngineConfigView: View {
|
||||
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