8000 fix(editor): correct long-form loop placement (arr-time anchoring) by johannboehme · Pull Request #48 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

fix(editor): correct long-form loop placement (arr-time anchoring) - #48

Merged
johannboehme merged 1 commit into
mainfrom
fix/editor-loop-arr-anchoring
May 25, 2026
Merged

johannboehme merged 1 commit into
mainfrom
fix/editor-loop-arr-anchoring

Conversation

@johannboehme
Copy link
Copy Markdown
Owner

Summary

Loop regions live in arr-time on the composed timeline, but several loop-set sites derived the anchor from master-time. These are no-ops for single-take (arr == master) and only misbehave in long-form arrangements.

  • TransportBar (toggleLoop, set in/out points) and SyncTuner (loop-around-playhead) used masterToArr(currentTime), which scans for the first segment whose master range contains the playhead and snaps onto the first occurrence of a repeated chunk. They now use the authoritative playback.timelineT, so the loop lands where the playhead actually is.
  • SyncTuner.setLoopAroundPlayhead built the loop straight from master-time (offset by the segment delta in long-form). Extracted a tested loopAroundPlayhead() helper that works purely in arr-time.
  • useAudioMaster parks the idle <audio> at arrToMaster(loop.start) instead of the raw arr value, so a wrap firing right after a loop is set doesn't start from a cold/wrong decoder position.
  • Timeline: while a loop is active, a pill click only selects (no seek), so the walker's immediate-wrap doesn't yank playback out of the loop.

Notes

Test plan

  • tsc clean
  • Unit suite green (1014 tests), incl. new loopAroundPlayhead cases
  • Manual (long-form): set a loop via the transport Loop button → loop sits at the playhead and plays the right region
  • Manual: with a loop active, click a pill outside the loop → it selects without disrupting the loop
  • Manual (single-take): loop behaviour unchanged

🤖 Generated with Claude Code

Loop regions live in arr-time on the composed timeline, but several
loop-set sites derived the anchor from master-time. These are no-ops for
single-take (arr == master) and only misbehave in long-form arrangements.

- TransportBar (toggleLoop, set in/out points) and SyncTuner
  (loop-around-playhead) used masterToArr(currentTime), which scans for
  the first segment whose master range contains the playhead and snaps
  onto the FIRST occurrence of a repeated chunk. They now use the
  authoritative playback.timelineT so the loop lands where the playhead
  actually is.
- SyncTuner.setLoopAroundPlayhead built the loop straight from master-time
  (offset by the segment delta in long-form). Extracted a tested
  loopAroundPlayhead() helper that works purely in arr-time.
- useAudioMaster parks the idle <audio> at arrToMaster(loop.start) instead
  of the raw arr value, so a wrap firing immediately after a loop is set
  doesn't start from a cold/wrong decoder position.
- Timeline: while a loop is active, a pill click only selects (no seek),
  so the walker's immediate-wrap doesn't yank playback out of the loop.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@johannboehme
johannboehme merged commit 57a5b63 into main May 25, 2026
1 check passed
@johannboehme
johannboehme deleted the fix/editor-loop-arr-anchoring branch May 25, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0