Repository navigation
Slice 13 — Manual BPM/offset correction (#14) - #33
Merged
Merged
Conversation
- tapToBpm: median inter-tap interval → BPM + first-beat offset; robust against single mis-taps via median (not mean) - manualBeatGridFromBpm: numeric-entry path producing an identical BeatGrid so AC3 (numeric == tapping) holds by construction - resolveEffectiveBeatGrid: manual override wins over auto-detected cache; re-analysis never evicts the manual value — only explicit clear (undefined) does; satisfies AC2 persistence requirement - SlideshowJson.manualBeatGrid added to schema for persistence across reopens - All exports wired through beat-grid/index.ts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14
Approach
Two pure functions added to the Beat Grid module, plus a schema field for persistence.
tapToBpm(tapTimestampsMs)— takes ≥8 tap timestamps (ms from track start), computes inter-tap intervals, takes their median (robust against one mis-tap), and derives BPM + first-beat offset. Requires ≥8 taps to match the AC minimum; throws on non-positive medianMs (duplicate/stuck timestamps).manualBeatGridFromBpm(bpm, firstBeatOffsetSecs)— numeric-entry path that constructs aBeatGriddirectly. Throws onbpm ≤ 0. Produces results identical totapToBpmwith perfectly-spaced taps at the same tempo (AC3 by construction).resolveEffectiveBeatGrid(manual, cache)—manual ?? cachepriority logic: manual override always wins; re-analysis (cache update) never evicts it; clearing is explicit (passundefined).SlideshowJson.manualBeatGrid— schema field for persistence across project reopens. Wiring intoslidesToJsonand the editor shell is intentional follow-on work (the UI detection slice).Acceptance criteria
tapToBpmproduces aBeatGridaccepted byplan(..., beatGrid)from the prior sliceresolveEffectiveBeatGrid+SlideshowJson.manualBeatGridschema field; persistence wiring is a follow-upmanualBeatGridFromBpmproduces the same BPM/interval/offset astapToBpmwith perfect taps (tested directly)Code review findings fixed
medianMs ≤ 0guard added (duplicate timestamps → throw instead of Infinity BPM)bpm ≤ 0guard added inmanualBeatGridFromBpm(prevents InfinitybeatIntervalSecs)Follow-ups
tapToBpm/manualBeatGridFromBpminto the editor UI (tap button + BPM/offset fields)manualBeatGridthroughslidesToJsonand read it back in the Project Store