Looper: add Sync / Free transport mode toggle

New syncToBeat switch (Free / Sync, default Sync) rendered as a segmented
control below the knobs and persisted with the rig. When off, runQuantized
applies transport immediately (freeform — loop length is whatever you play,
not beat-measured) even with a clock present; when on, record start / loop
close arm to the next beat as before. Not reset by resetLoop / resetForRebuild
so the mode sticks. Covered by freeformModeRecordsImmediatelyDespiteClock.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 17:16:13 -07:00
parent fb3e2d2653
commit 5dafc00d98
2 changed files with 42 additions and 2 deletions
@@ -70,6 +70,11 @@ public final class LooperPedal: Pedal {
/// Playback direction. `0` = forward, `1` = reverse. Read as `1 − 2·reverse`.
@UIParam public var reverse: Double = 0.0
/// Transport sync mode. `1` = beat-quantized (record start / loop close snap to the next
/// beat via the shared clock); `0` = freeform (immediate, loop length is whatever you play).
/// Persisted with the rig. Default `1`.
@UIParam public var syncToBeat: Double = 1.0
// MARK: - Internal live state (read by the audio graph / UI LEDs)
/// `1` while the loop bank is playing, else `0`. Gates the whole player sum and the overdub
@@ -189,6 +194,20 @@ public final class LooperPedal: Pedal {
]
}
/// Beat-sync vs freeform transport mode, as a two-position segmented switch below the knobs.
public override var effectSwitches: [PedalSwitch] {
[
PedalSwitch(
label: "Sync",
node: $syncToBeat,
options: [
PedalSwitch.Option(title: "Free", value: 0.0),
PedalSwitch.Option(title: "Sync", value: 1.0),
]
),
]
}
/// Transport row: the smart Loop footswitch, the two stops, direction, and reset.
public override var effectTransportButtons: [PedalButton] {
[
@@ -657,7 +676,8 @@ public final class LooperPedal: Pedal {
private func runQuantized(_ action: QuantizedAction) {
transportGeneration += 1
let generation: Int = transportGeneration
guard let clock: LyrebirdClock = clock, let engine: SynthesisEngine = hostEngine else {
// Freeform (Sync off) or no clock/engine → apply immediately, un-quantized.
guard syncToBeat >= 0.5, let clock: LyrebirdClock = clock, let engine: SynthesisEngine = hostEngine else {
applyQuantizedTransport(action, generation: generation, at: nil)
return
}