Repository navigation
fix(editor): make duplicate pills first-class — playback, FX, cuts, snap all on timeline-time - #38
Merged
Merged
Conversation
…n't snap to first occurrence
The audio walker holds an authoritative `currentSegmentIdx` but exposed
only master-time as `playback.currentTime`. UI consumers projected that
back via `masterToArr`, which scans by master-time and returns the FIRST
occurrence — so when a chunk repeats in the song the playhead bounced
back to the earlier slot ("1 2 1 4" instead of "1 2 3 4") even though
audio playback was correct.
Walker now writes both `currentTime` (master) and `timelineT` (timeline,
computed from the authoritative idx) atomically via `setPlayhead`. The
Timeline playhead and TransportClock LCD read `timelineT` directly. The
in-flight idx-validation that re-scanned on master-time drift is gone:
we trust the explicit advance/seek path and never bounce a duplicate.
Also lays the foundation for the larger pill+lane refactor: introduces
`AudioPill`, `VideoLane`, `groupPillsIntoLanes`, `segmentsToAudioLane`
as the timeline-time data model the walker and renderer will iterate
on directly in subsequent commits.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tor (bug 1 frame-side) Walker change in the previous commit made the playhead UI honour duplicate pills, but the video pool was still computing source-time per cam from `camSourceTimeS(masterT, anchor)`. That bypasses the active pill's `sourceIn/Out` window — so when the same chunk repeats the `<video>` element seeked to the FIRST occurrence's source-time even though the playhead was correctly inside the duplicate. Pool is now target-driven: each tick the runtime collects per-cam `sourceT` from the descriptor's video layers (pill-resolved by `buildPreviewLayersFromPill`) and hands the map to `pool.syncAll`. Cams without a target get paused — they're not on PROGRAM this tick. Anchor + drift are gone from the pool; the descriptor builder is the single place that maps `(pill, tTimeline) → sourceTimeS`. `isInRange(masterT)` becomes `isSourceInRange(sourceT)` — same intent, caller passes the already-resolved value. `buildPreviewFrameDescriptor` now takes an optional `tTimeline` and prefers it over `masterToArr(tMaster)` when present. The runtime threads the walker's authoritative `playback.timelineT` through. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…'t share state (bug 3) Cuts and FX used master-time anchors. When the same chunk repeats in the song an FX recorded inside pill 1 also fired over pill 3, and cuts placed inside the duplicate slot had no way to land there without bleeding back onto pill 1 — both occurrences shared the master-time the cut/fx pointed at. Field semantics flip to timeline-time (no rename): - `Cut.atTimeS` is now song-position, not master-position. - `PunchFx.inS/outS` are now song-position. - `activeCamAtArr` reads cuts directly without `masterToArr`. - `activeFxAt(fx, tTimeline)` queries against the walker's authoritative timeline-position. - Recording sites in Editor.tsx (FX-hold + take-cut keybinds + the cam button) write `playback.timelineT` instead of master-time. Persistence migration: jobs carry `editorSchema: "v1-master" | "v2-timeline"`. On load, `Editor.tsx` projects legacy master-time values to first-occurrence timeline-time using `masterToArr` (the arr-position they would have had during the original recording — same values for non-duplicate jobs, no data loss). Auto-persist stamps `editorSchema: "v2-timeline"` on every write so the migration runs exactly once per persisted job. Added arrangement-pills tests for cut isolation across duplicate-pill slots. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…er correctly in MP4 output Mirrors the live-preview change. The export loop already iterated arr-time linearly through `intervals`; only the FX-lookup argument into `compositor.compositeImage` was master-time. With cuts/fx now stored in timeline-time, the export must query at `tArr` — otherwise an FX placed inside a duplicate-pill slot (timeline 12, master 2) would either fire on every duplicate (legacy semantics) or never fire at all (new semantics, master-time lookup misses every record). Compositor's `tMasterS` parameter keeps its name for compat but its docs flip to "timeline-time"; the only call site is now the export loop and the live preview's path uses `descriptor.tMaster` only for diagnostics. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ere (bug 3 part 2) The first FX timeline-time pass missed three hot consumers: 1. `tickFxHold` (RAF-driven hold-extend) was being fed `playback.currentTime` (master-time) while `beginFxHold` had already written `inS = playback.timelineT`. Capsule's `inS`/`outS` thus ended up on different axes — for duplicate-pill chunks the capsule grew over the wrong region of the song. 2. `eraseFxAt` is correct on its own, but Editor.tsx fed it master-time too. Erase head deleted slices at master-time positions, which on duplicate chunks meant deleting in pill 1 when the user was over pill 3. 3. `FxHardwarePanel`'s pad press also called `snapMasterTime(playback.currentTime)` — same problem as the keyboard hotkey path. Most users record FX from the panel, not from the F-hotkey, so this was the most-visible site. Plus: `activeCamId(t)` was projecting via `masterToArr` even after cuts moved to timeline-time. Defaulting to `playback.timelineT` and treating the optional arg as timeline-time directly fixes the Compositor / Stage / Timeline cam-status reads. Plus: Timeline `stripCuts` / `stripFx` were running cuts and FX through `mastersToArrAll` / `sliceByArrSegments` to project them onto the program strip. Both functions take master-time inputs; with timeline-time-stored values they either drop the entry (no master range matches) or — worse — duplicate it onto every chunk that shares the master-time-numerical-value. The strip now reads cuts/fx 1:1 from the store; FX clips to the song duration. 944 unit tests still green. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…nd-to-end Three more master↔timeline-time mismatches the previous pass missed: 1. ProgramStrip's onCutRemove handler was projecting `atTimeS` through `viewToMaster` before calling `removeCutAt`. Cuts in the store are now keyed by timeline-time; the converted master-time value never matched and the click was a no-op (or matched a different cut that happened to share the master-time numerical value — i.e. the duplicate-pill bug Bugs 1 + 3 are about). 2. onCutDrag was doing the same projection plus a `snapMasterTime` round-trip that pulled the drag target onto the master-time grid. Snap is axis-agnostic — snapMasterTime works on any seconds value — so the projection layer is gone entirely. 3. paintPreview rendered the hold-paint overlay by projecting both endpoints through `masterToView`. `holdGesture.startS` was already timeline-time after the digit-key fix; the projection moved it onto the wrong slot for duplicate pills. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ands on visible bar markers The cut/FX record path was calling `snapMasterTime(playback.timelineT)`. That function snaps a value against the master-time beat phase — but the input is timeline-time and the visible BeatRuler grid is also timeline-time (anchor projected via masterToArr). Result: the snapped value landed on a phantom grid offset from the bars the user can see. Adds `snapTimelineTime(t)` that projects `effectiveBeatPhaseS` through `masterToArr` first, mirroring the BeatRuler's own bijection. Every recording-path snap call (FX-Hold begin in Editor + FxHardwarePanel, cut record / take, cut drag, FX hold release) now goes through it. `snapMasterTime` stays for trim and seek which actually live on the master axis. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks done
johannboehme
added a commit
that referenced
this pull request
May 6, 2026
…t flip flicker (#39) Previous PR (#38) tightened the video pool so cams without a layer in the descriptor get paused. That kept the GPU decoder cold for any cam that wasn't the active one — and as soon as a cut switched to one of those cams, Chrome had to re-warm + re-seek the decoder. Chrome's copyExternalImageToTexture path occasionally lands the first frame after such a (re-)seek upside-down, which presented as every pill flickering between flipped and right-side-up for the first few frames. Switch the target source: instead of reading the descriptor's single active layer, iterate `snapshot.pills` and put EVERY cam whose pill covers the current `tTimeline` into the targets map. The pool keeps all decoders running on their pill-correct source-time, the cut switch becomes a no-op for the decoder, and the upload picks up an already-hot stream — so the first-frame-after-seek path never fires. Source-trim semantics are still pill-aware (each cam's covering pill contributes its own `sourceInS/Out` window), so duplicate-source pills with distinct trims still seek to the right frame for that specific occurrence — the bug 1 fix from #38 is preserved. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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
The user reported three editor bugs that all turned out to be one architectural problem: cuts and FX were master-time-anchored, so when the same chunk repeated in the song every duplicate-pill slot collapsed onto the first occurrence. This branch flips cuts + FX to timeline-time (= song-position) and threads an authoritative `playback.timelineT` from the audio walker through every consumer that decides "what should be on screen / on tape RIGHT HERE".
Bugs fixed:
The export pipeline gets the same axis flip — `compositeImage` now receives `tArr` for FX lookup.
Unrelated: still investigating Bug 2 (one specific clip's first frame upside-down). User couldn't reliably repro yet; deferred until we have the problematic clip + which backend (WebGPU/WebGL2) it appears on.
Test plan
🤖 Generated with Claude Code