Repository navigation
fix(transport): L shortcut clamps loop region into trim - #20
Merged
Merged
Conversation
…udio>/<TransportBar>
EditorShell rendered the desktop and mobile layouts side-by-side and
relied on `hidden lg:grid` / `lg:hidden` to swap them. Both branches
received the SAME `videoArea`/`transport`/`timeline` ReactNodes, so
React mounted each twice — including <MasterAudio> (= a second WebAudio
ping-pong wired into ctx.destination) and <TransportBar> (= a second
window keydown listener). Two effects:
- Loop "phasing" across the whole region: two parallel ping-pong
setups decoded the same source with independent decoder latencies
and summed into the same destination, producing constant comb-
filtering through every loop iteration. Verified via React fiber
walk: 2× MasterAudio + 4 <audio> elements before, 1× and 2 after.
- Arrow-key snap navigation stepped 2× the snap distance: each
keypress fired both TransportBars' onKey, dispatching
stepByActiveSnap twice. Verified live: 0.43s → 2.43 → 4.43 → 6.43
after the fix (was 0.43 → 4.43 → 8.43 → 12.43 before).
Fix: gate each layout branch on `useIsLargeViewport()` so only the
matching one mounts. Also tighten stepByActiveSnap's eps fallback from
`step * 0.01` (= 20ms at 1-bar / 120bpm, wide enough to falsely fire
when the playhead lands within 1% of a snap) to `step * 1e-9` (FP
tolerance only — the fallback exists solely to absorb Math.round's
round-half-toward-+∞ asymmetry on negative half-tick probes).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`toggleLoop` blindly proposed `{currentTime, currentTime+2}` which
`setLoop` then clamps against the trim region (`clampLoopRegion` in
OffsetScheduler). When the playhead sits before/after the trimmed audio
— typical right after opening the editor, where currentTime defaults to
0 but `trim.in` is the audio start (e.g. 6.4 s) — the proposal is
entirely outside trim, the clamp returns null, and L appears to do
nothing.
Verified live: with trim={6.43, 10.43} and playhead at 0, pressing L
produced a `setLoop({0, 2})` that clamped to null. After this fix the
proposal becomes `{6.43, 8.43}` and the loop activates.
Anchor strategy:
start = clamp(currentTime, trim.in, trim.out − 1 frame)
end = min(trim.out, start + 2)
Same handler is used for the LOOP button click and the L shortcut, so
clicking from the same out-of-trim playhead position was equally broken
— the click bug just hadn't been caught because typical use clicks the
LOOP button after the playhead is already inside trim.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
10 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.
Summary
toggleLoopproposed{currentTime, currentTime+2}blindly.setLoopthen clamps that against the trim region viaclampLoopRegion— and when the playhead sits outside trim (typical right after opening the editor:currentTime = 0,trim.in= the audio start, e.g. 6.4 s), the proposal lies entirely outside trim, the clamp returnsnull, and L appears to do nothing.Verified live: with
trim = {6.43, 10.43}and the playhead at 0, pressing L produced asetLoop({0, 2})that clamped to null. After the fix the proposal becomes{6.43, 8.43}and the loop activates as expected.Same handler is used for the LOOP button click and the L shortcut, so clicking from the same out-of-trim playhead position was equally broken — it just wasn't caught because typical use clicks LOOP after the playhead is already inside trim.
Anchor strategy
trim.intrim.out − 1 frame(loop is at least one frame long)Test plan
🤖 Generated with Claude Code