8000 fix(editor): anchor the bar ruler to the song start, not where master-0 plays by johannboehme · Pull Request #52 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

fix(editor): anchor the bar ruler to the song start, not where master-0 plays - #52

Merged
johannboehme merged 1 commit into
mainfrom
claude/pedantic-fermi-32f277
Jun 9, 2026
Merged

johannboehme merged 1 commit into
mainfrom
claude/pedantic-fermi-32f277

Conversation

@johannboehme
Copy link
Copy Markdown
Owner

Problem

Going through a long project Triage → Arrange → Edit, the editor's bar/measure ruler started way back in the song — bar 1 rendered far to the right with empty ruler on the left, the bar numbers crammed against the right edge.

Root cause

The editor keeps one master beat grid for the whole job and projects "beat 0" onto the arrangement-time canvas (where the ruler is drawn). It did that projection with masterToArr(beatPhase).

But beatPhase (beat 0) is a single master instant — ~0.3 s into the source recording. masterToArr returns the arr-time at which that instant is played back, i.e. wherever the chunk covering master-time ≈ 0 sits in the playback order. On a long-form arrangement whose first-played chunk starts late in the source (or whose master-0 chunk plays near the end), beat 0 mapped to a large arr-time → bar 1 anchored far down the timeline.

Fix

Added a dedicated selector arrBeatPhaseS that anchors the grid to the first played segment (beatPhaseMaster − seg0.in), so the bar grid runs continuously from arr-time 0 — the start of the assembled song. Identity for single-take's whole-master [0, dur] segment, so direct-mode jobs are unchanged.

Applied the same anchor at every place that consumes the grid on the arr axis, so they stay locked to the ruler:

  • BeatRuler.tsx — the ruler itself
  • store.ts snapTimelineTime — beat-snapping
  • Timeline.tsx — clip / pill / loop drag-snap

Testing

  • 4 new TDD regression tests in timing.test.ts cover the out-of-order long-form case, single-take identity, and the empty-segments fallback.
  • Full unit suite: 1061/1061 pass; tsc --noEmit clean.

Reviewer notes

  • The grid still uses master bar numbering (a chunk grabbed from mid-song shows its master bar number), consistent with the existing "one master bar grid for every job" design — this PR only fixes where the grid anchors, not the numbering scheme.
  • For out-of-order / gapped arrangements the grid is laid as a single uniform arr-time grid (continuous within the first segment); true per-segment phase across seams is a separate, pre-existing limitation and out of scope here.

🤖 Generated with Claude Code

…-0 plays

The editor keeps one master beat grid for every job and projects beat 0
into the arr-time canvas axis. It did this with masterToArr(beatPhase),
which returns the arr-time at which beat 0 (a single master instant ~0.3s
into the source) is *played* — i.e. wherever the chunk covering master ~0
lands in the playback order. On a long-form arrangement whose first chunk
starts late in the source (or whose master-0 chunk plays last), that
anchored bar 1 far down the timeline: the ruler "started way back in the
song."

Replace the projection with a dedicated selector arrBeatPhaseS, which
anchors the grid to the first PLAYED segment (beatPhaseMaster - seg0.in),
so the bar grid runs continuously from arr-time 0. Identity for
single-take's whole-master [0,dur] segment.

Apply the same anchor everywhere the grid is consumed on the arr axis so
they stay in lockstep with the ruler: BeatRuler, snapTimelineTime, and the
clip/pill/loop drag-snap paths in Timeline.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@johannboehme
johannboehme merged commit 2a3d1d4 into main Jun 9, 2026
1 check passed
@johannboehme
johannboehme deleted the claude/pedantic-fermi-32f277 branch June 9, 2026 16:35
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