Looper: multitrack redesign with smart Loop footswitch

Replace the one-at-a-time slot model with a synchronized multitrack looper:
four track players summed to one output, track A's first take defining the
master loop length, and tracks B–D recorded as phase-locked overdub layers
on the same grid (overdub recorders run continuously while playing, reset to
the top at play-start, gated per-track by recLevel so only the selected
track layers new input — instant, drift-free overdub toggles).

A single smart Loop footswitch drives the whole transport by state:
record A → set end (quantized) → auto-overdub on wrap → toggle overdub/play;
B–D toggle overdub aligned to A's play-head. Selecting a track ends the
prior overdub. Stop / Cue Stop pause; Loop resumes. Reset returns to clear.

UI: transport row is now Loop / Stop / Cue Stop / Reverse / Reset; the old
action row is replaced by a one-line state indicator; the A/B/C/D timeline
dots are tappable to select a track; every stomp button shows a live caption
of what its next press does (Record → Set End → Overdub → Play, etc.).

Overdub-undo dropped. All transport routines keep the transportGeneration
guard on deferred beat/stop callbacks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 14:24:46 -07:00
parent 465e3e6dfd
commit 3007b76798
8 changed files with 637 additions and 907 deletions
@@ -4,30 +4,31 @@
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
/// Publicly-observable transport phase of ``LooperPedal``, surfaced for the UI so it can
/// colour the record LED, animate the "waiting for the next beat" armed states, and drive
/// the loop timeline.
/// Publicly-observable transport phase of the multitrack ``LooperPedal``, surfaced for the UI
/// so it can colour the state indicator, animate the "waiting for the next beat" armed states,
/// and drive the loop timeline.
///
/// The two `armed…` cases exist only when the pedal has a tempo ``LyrebirdClock`` — a
/// transport action then waits for the next beat boundary before it takes effect. Without a
/// clock the pedal transitions straight between ``empty``, ``recording`` and ``playing``.
/// The pedal is a synchronized multitrack looper: track A's first take defines the master loop
/// length, and tracks B–D are overdub layers recorded onto the same grid, all playing at once.
public enum LooperTransportState: Sendable, Equatable {
/// No take recorded yet. `Record` begins recording (or arms it, with a clock).
case empty
/// No material recorded on any track. Only track A can be selected; press Loop to record it.
case clear
/// A `Record` has been requested and the pedal is waiting for the next beat to start.
/// A Loop press has been made in the clear state and the pedal is waiting for the next beat
/// to start recording track A.
case armedRecord
/// Actively recording the primary take.
case recording
/// Recording track A's first take, which defines the master loop length.
case recordingMaster
/// A stop has been requested and the pedal is waiting for the next beat to close the loop.
case armedStop
/// A Loop press closed the master take and the pedal is waiting for the next beat to set the
/// loop end.
case armedClose
/// Looping playback of the recorded take (overdub / reverse / mute apply here).
/// Looping playback of all recorded tracks. The selected track may be overdubbing.
case playing
/// Playback halted by a stop, but a recorded loop is still loaded (ready to resume).
/// Playback paused by a stop, with recorded material still loaded (ready to resume).
case stopped
}