Looper: fix multitrack RT-safety findings from review

Phase-lock: reset the overdub recorder write heads (requestReset) and the
player play-heads (playTrigger rising edge) synchronously in startPlayback so
both re-anchor on the same audio block, instead of deferring the trigger an
extra run-loop turn; playTrigger is zeroed on every stop for a clean 0→1 edge.
This also makes overdub actually record under NRT.

Reverse vs overdub: overdub records forward-in-time and can't follow a reversed
play-head. Block engaging overdub while reversed, and make Reverse a
toggleReverse() action that ends any active overdub when engaging reverse (the
footswitch keeps its LED via indicator: $reverse).

resetLoop: gate isPlaying off before clear() so the buffer-clear overlaps at
most one in-flight RT block; corrected the rationale comment.

Docs: fix stale $overdubOn / .empty / .recording references.

Tests: overdubbingTrackAAddsEnergyToTheLoop (NRT overdub records),
overdubBlockedWhileReversed, engagingReverseWhileOverdubbingEndsOverdub.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 15:07:41 -07:00
parent 3007b76798
commit 83b8fff74b
4 changed files with 115 additions and 25 deletions
+6 -4
View File
@@ -67,13 +67,15 @@ public struct MIDIMap: Codable, Equatable, Sendable {
/// A pedal-specific momentary action addressable by ``Action/pedalAction(pedalID:kind:)``.
/// New pedals with more than a simple bypass toggle add cases here.
public enum PedalActionKind: Codable, Equatable, Sendable {
/// Looper: `.empty` → begin recording; `.recording` → stop and start looping.
/// Looper: presses the smart Loop footswitch (record → set end → overdub → play by
/// state) — same as ``looperOverdubToggle``; both dispatch to `LooperPedal.pressLoop()`.
// TODO: collapse looperRecordStop / looperOverdubToggle into one case (both call pressLoop).
case looperRecordStop
/// Looper: flips `overdubOn` between `0` and `1`.
/// Looper: presses the smart Loop footswitch (toggles overdub once a loop is playing).
case looperOverdubToggle
/// Looper: flips `loopOn` between `0` and `1`.
/// Looper: flips `loopOn` (loop mute) between `0` and `1`.
case looperLoopToggle
/// Looper: reset — clears the loop and returns to `.empty`.
/// Looper: reset — clears all tracks and returns to the clear state.
case looperReset
}