From e207728a12cbe60c987cf4f0db94a7fef18bd471 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Sat, 11 Jul 2026 21:41:57 -0700 Subject: [PATCH] Review nits: name pulse-settle constant, fix stale comments Non-blocking cleanups from the clean review pass: - EngineConfigView.startEngine: collapse the redundant early-return in the sample-rate-mismatch branch into the shared tail. - InputMuteButton: hoist the 0.2s settle duration to a named pulseSettleDuration. - InputMuteTests: correct a stale "input defaults muted" comment (library default is audible; the test mutes explicitly). - Plan doc: setInputMuted(true) runs before engine.start(), not after; note the addBoard priming. 464 tests pass; macOS app builds. Co-Authored-By: Claude Opus 4.8 --- Sources/LyrebirdShoeGazeUI/EngineConfigView.swift | 3 --- Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift | 3 ++- Tests/LyrebirdShoeGazeTests/InputMuteTests.swift | 4 ++-- docs/plans/2.1.1-input-mute-and-io-persistence.md | 10 +++++++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Sources/LyrebirdShoeGazeUI/EngineConfigView.swift b/Sources/LyrebirdShoeGazeUI/EngineConfigView.swift index 3bb494c..c82b123 100644 --- a/Sources/LyrebirdShoeGazeUI/EngineConfigView.swift +++ b/Sources/LyrebirdShoeGazeUI/EngineConfigView.swift @@ -213,9 +213,6 @@ 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 } transportTick.toggle() onConfigApplied() diff --git a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift index d94892c..3c48cb6 100644 --- a/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift +++ b/Sources/LyrebirdShoeGazeUI/ShoeGazeBuilderView.swift @@ -1232,6 +1232,7 @@ public struct ShoeGazeBuilderView: View { private static let glowOpacityLow: Double = 0.35 private static let glowOpacityHigh: Double = 0.95 private static let pulseDuration: Double = 0.85 + private static let pulseSettleDuration: Double = 0.2 var body: some View { let muted: Bool = shoeGaze.inputMuted @@ -1271,7 +1272,7 @@ public struct ShoeGazeBuilderView: View { pulse = true } } else { - withAnimation(.easeOut(duration: 0.2)) { pulse = false } + withAnimation(.easeOut(duration: InputMuteButton.pulseSettleDuration)) { pulse = false } } } } diff --git a/Tests/LyrebirdShoeGazeTests/InputMuteTests.swift b/Tests/LyrebirdShoeGazeTests/InputMuteTests.swift index c5deb2e..1e7b6c8 100644 --- a/Tests/LyrebirdShoeGazeTests/InputMuteTests.swift +++ b/Tests/LyrebirdShoeGazeTests/InputMuteTests.swift @@ -92,13 +92,13 @@ struct InputMuteTests { @Test func mutedInputRendersSilent() throws { let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.25, numAudioBuses: 256) defer { try? FileManager.default.removeItem(at: url) } - let sg: ShoeGaze = ShoeGaze(engine: engine) // input defaults muted + let sg: ShoeGaze = ShoeGaze(engine: engine) try withExtendedLifetime(sg) { let board: PedalBoard = try sg.addBoard() try board.add(VolumePedal()) try sg.finalizeBoard(board) - sg.setInputMuted(true) + sg.setInputMuted(true) // mute explicitly before Start (library default is audible) try engine.start() let samples: [Float] = readStereoCAF(url: url) diff --git a/docs/plans/2.1.1-input-mute-and-io-persistence.md b/docs/plans/2.1.1-input-mute-and-io-persistence.md index ac9fc16..4a998ce 100644 --- a/docs/plans/2.1.1-input-mute-and-io-persistence.md +++ b/docs/plans/2.1.1-input-mute-and-io-persistence.md @@ -32,9 +32,13 @@ moment the mute is meant to keep things quiet; a kill-switch mute is expected to ### Engine start -`EngineConfigView.startEngine()` calls `shoeGaze.setInputMuted(true)` after a successful -user Start. Transient stop/start-around-rebuild paths (`applyInputSource`, `performClear`) -call `engine.start()` directly and are unaffected — they preserve the current mute state. +`EngineConfigView.startEngine()` calls `shoeGaze.setInputMuted(true)` **before** +`engine.start()`, while the engine is stopped — so the gain is seeded (`previousOutputValue` +primed to the target, no ramp) and the very first render block is already muted. Asserting it +after start would leave the opening blocks unmuted. Transient stop/start-around-rebuild paths +(`applyInputSource`, `performClear`) call `engine.start()` directly and are unaffected — they +preserve the current mute state. Nodes are also primed at creation in `addBoard()` (before the +node is spliced into the graph), so a board added while muted has no first-block leak either. ### MIDI