8000 feat(editor): conform bar-grid to selected pill's audio onset by johannboehme · Pull Request #36 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

feat(editor): conform bar-grid to selected pill's audio onset - #36

Merged
johannboehme merged 1 commit into
mainfrom
claude/adoring-noether-2237a8
May 6, 2026
Merged

johannboehme merged 1 commit into
mainfrom
claude/adoring-noether-2237a8

Conversation

@johannboehme
Copy link
Copy Markdown
Owner

Summary

  • Adds a CONFORM TO PILL button in the SyncTuner pill-mode panel.
  • Re-anchors the master audioStartNudgeS so beat 0 lands on the selected pill's source-segment audioStartMs.
  • Mirrors triage's per-chunk Conform: re-aligns FX/cut snap-targets against a single pill when small drift has accumulated across many pills (typical for arrangement-mode jobs coming from triage), or when the global audio-start sits in front of a leading pause in the composite.

Why

There's only one bar-timeline in the editor, anchored at the auto-detected first onset of the master audio. With many pills (long-form/arrangement jobs) small additive offsets between FX/cut snap-times and the per-chunk audio onset accumulate, and any leading silence/pause before the first chunk makes "audio-start = first audio in master" a poor anchor for downstream pills. Letting the user re-anchor the bar grid to whichever pill they're currently working on lets them get sample-accurate snap on that pill again, the same way triage's Conform realigns chunk bounds to bar boundaries.

Behavior

  • Button is rendered above RESET PILL inside the pill-mode branch of SyncTuner. Label shows the would-be nudge delta, e.g. CONFORM TO PILL (+59.32 ms).
  • Disabled when:
    • the pill's segment has no detected onset (label becomes CONFORM TO PILL · NO ONSET),
    • the job has no BPM,
    • or the resulting delta < 1 ms (idempotent).
  • One click sets jobMeta.audioStartNudgeS = segment.audioStartMs/1000 - bpm.phase. The Master-Audio panel TOTAL readout reflects the new value; RESET TO ALGO there reverts.

Implementation

  • New store action conformAudioStartToPill(pillId) returning "ok" | "no-pill" | "no-bpm" | "no-audio-start" | "unchanged" — error codes mirror triage's conformChunk.
  • Resolves the pill's source segment via segmentIndexAtArr(pill.originalArrStartS, arrangementSegments) — originalArrStartS so any user drag on the pill doesn't decouple it from its arrangement-item segment.
  • 5 unit tests in store.test.ts covering the happy path (delta math), idempotence, and the three error branches.

Test plan

  • Unit: vitest run src/editor — 717 passed (the 2 unrelated WebGL/WebGPU readback browser perf-bench failures are pre-existing on this hardware).
  • Type check: tsc --noEmit clean (only the pre-existing @webgpu/types resolution warning).
  • Manual: load an arrangement-mode job with multiple chunks → click a pill → press CONFORM → verify BeatRuler snaps to that pill's onset and FX/cut drag snap aligns with the pill's audio.
  • Manual: press CONFORM on a different pill → bar grid jumps to that pill's onset (other pills now drift, expected).
  • Manual: pill with no detected audioStartMs → button disabled with · NO ONSET label.
  • Manual: RESET TO ALGO in Master-Audio panel reverts the conform.

Out of scope

  • No CONFORM button in the Master-Audio branch (no pill context there). Easy to add if needed.
  • No undo snapshot like triage's "Original" button — successive conforms overwrite the nudge; RESET TO ALGO in Master-Audio is the escape.

🤖 Generated with Claude Code

Adds a CONFORM TO PILL button in the SyncTuner pill-mode panel that
re-anchors the master `audioStartNudgeS` so beat 0 lands on the audio
onset of the currently selected pill's source segment. Mirrors triage's
per-chunk Conform: re-aligns FX/cut snap-targets against a single pill
when small drift accumulated across many pills (typical for arrangement-
mode jobs from triage), or when the global audio-start sits in front of
a leading pause in the composite.

The button shows the would-be nudge delta and disables when there is no
detected onset, no BPM, or the delta would be < 1 ms (idempotent).
@johannboehme
johannboehme merged commit 16913e2 into main May 6, 2026
1 check failed
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