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
@@ -163,7 +163,7 @@ struct LooperPedalTests {
@Test func exposesLooperControls() throws {
let pedal: LooperPedal = LooperPedal()
#expect(pedal.effectKnobs.map { $0.label } == ["Crossfade", "Playback", "Overdub", "Feedback"])
#expect(pedal.effectSwitches.isEmpty)
#expect(pedal.effectSwitches.map { $0.label } == ["Sync"])
#expect(pedal.effectButtons.isEmpty)
#expect(pedal.effectTransportButtons.map { $0.label } == ["Loop", "Stop", "Cue Stop", "Reverse", "Reset"])
}
@@ -510,6 +510,26 @@ struct LooperPedalTests {
} }
}
@Test func freeformModeRecordsImmediatelyDespiteClock() throws {
let (engine, clock, pedal): (SynthesisEngine, LyrebirdClock, LooperPedal) =
try makeQuantizedFixture(bpm: 120.0, sampleRate: 44100.0)
withExtendedLifetime(engine) { withExtendedLifetime(clock) {
// Sync off: even with a clock present, transport is immediate — no armed/waiting state.
pedal.syncToBeat = 0.0
pedal.pressLoop()
#expect(pedal.transportState == .recordingMaster, "freeform record starts immediately")
pedal.pressLoop()
#expect(pedal.transportState == .playing)
#expect(pedal.loopLengthBeats == 0.0, "freeform loops aren't beat-measured")
// Flip to Sync: the next take arms for the beat instead.
pedal.resetLoop()
pedal.syncToBeat = 1.0
pedal.pressLoop()
#expect(pedal.transportState == .armedRecord, "sync record arms for the next beat")
} }
}
@Test func stopResumeAndCueStop() throws {
let (engine, clock, pedal): (SynthesisEngine, LyrebirdClock, LooperPedal) =
try makeQuantizedFixture(bpm: 120.0, sampleRate: 44100.0)