From 6f651b6e17c0929d3db62870ea35befbc0637ed0 Mon Sep 17 00:00:00 2001 From: Joshua Parmenter Date: Fri, 3 Jul 2026 16:52:18 -0700 Subject: [PATCH] Looper: reset also clears reverse and the transient notice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resetLoop() left `reverse` untouched, so after a reset with reverse engaged the next take's auto-overdub on track A was silently blocked (closeMasterAndPlay skips overdub while reversed) and playback ran backward — the "record/overdub after reset looks broken" report. Reset now returns to forward playback and also clears any lingering engine-stop/rig-change notice so it can't mask the fresh state indicator. Covered by recordsAgainAfterReset. Co-Authored-By: Claude Opus 4.8 --- .../LyrebirdShoeGaze/Pedals/LooperPedal.swift | 4 +++ .../LooperPedalTests.swift | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Sources/LyrebirdShoeGaze/Pedals/LooperPedal.swift b/Sources/LyrebirdShoeGaze/Pedals/LooperPedal.swift index 69cb407..7fffc7f 100644 --- a/Sources/LyrebirdShoeGaze/Pedals/LooperPedal.swift +++ b/Sources/LyrebirdShoeGaze/Pedals/LooperPedal.swift @@ -532,9 +532,13 @@ public final class LooperPedal: Pedal { masterLength = 0 masterBeats = 0.0 loopOn = 1.0 + reverse = 0.0 // clean slate: forward playback playTrigger = 0.0 stoppedIndicator = 0.0 cueStopArmed = 0.0 + // Drop any lingering transient notice so it can't mask the fresh state indicator. + noticeText = nil + noticeExpiry = nil updateOverdubGates() phase = .clear } diff --git a/Tests/LyrebirdShoeGazeTests/LooperPedalTests.swift b/Tests/LyrebirdShoeGazeTests/LooperPedalTests.swift index 23bedbf..e195f5f 100644 --- a/Tests/LyrebirdShoeGazeTests/LooperPedalTests.swift +++ b/Tests/LyrebirdShoeGazeTests/LooperPedalTests.swift @@ -437,6 +437,33 @@ struct LooperPedalTests { } } } + @Test func recordsAgainAfterReset() throws { + let (engine, clock, pedal): (SynthesisEngine, LyrebirdClock, LooperPedal) = + try makeQuantizedFixture(bpm: 120.0, sampleRate: 44100.0) + withExtendedLifetime(engine) { withExtendedLifetime(clock) { + pedal.clock = nil + pedal.pressLoop() // record A + pedal.pressLoop() // playing + overdub A + pedal.toggleReverse() // leave reverse engaged before reset + #expect(pedal.reverse == 1.0) + + pedal.resetLoop() + #expect(pedal.transportState == .clear) + #expect(pedal.overdubbingTrackIndex == nil) + #expect(pedal.reverse == 0.0, "reset returns to forward playback") + + // Second take must behave exactly like the first — including auto-overdub on A, + // which was silently blocked when reset didn't clear a left-on reverse. + pedal.pressLoop() + #expect(pedal.transportState == .recordingMaster, "record after reset should re-enter recording") + #expect(pedal.loopButtonCaption == "Set End") + pedal.pressLoop() + #expect(pedal.transportState == .playing) + #expect(pedal.overdubbingTrackIndex == 0, "auto-overdub on A must engage after a reset") + #expect(pedal.trackHasContent(0)) + } } + } + @Test func stopResumeAndCueStop() throws { let (engine, clock, pedal): (SynthesisEngine, LyrebirdClock, LooperPedal) = try makeQuantizedFixture(bpm: 120.0, sampleRate: 44100.0)