Skip to content

feat(timeline): show more waveform detail as the timeline is zoomed in - #1719

Draft
Kiddo4993 wants to merge 1 commit into
getopenscreen:mainfrom
Kiddo4993:fix/issue-1628
Draft

Kiddo4993 wants to merge 1 commit into
getopenscreen:mainfrom
Kiddo4993:fix/issue-1628

Conversation

@Kiddo4993

@Kiddo4993 Kiddo4993 commented Dec 2, 2026 •

Copy link
Copy Markdown

Closes #1628 (the main part: "more detail as the timeline is zoomed in").

Problem

ClipWaveform always drew one sample per ~125 ms of source (capped at 400), whatever the zoom level. The peak data underneath is much finer (up to 200 blocks/s), but zooming in only stretched the same coarse curve. Word boundaries and short pauses got folded into one bump, so placing a precise cut was hard.

Change

  • New waveformSampleCount(spanSec, detailPxPerSec, rangeBlocks): the sample count now follows how wide the clip is on screen, at one sample per 3 px. It is bounded:
    • It never drops below the old zoom-independent rule, so a zoomed-out timeline looks exactly as before.
    • It never goes above the resolution the peak data actually holds.
    • It never goes above 4000 samples, so a deep zoom on a long clip can't build a huge path.
  • New waveformDetailScale(pxPerSec): rounds the timeline scale up to a power of two (0 while the timeline is unmeasured). The memoised waveforms therefore only rebuild each time the zoom doubles, not on every wheel tick. Rounding up means the detail is never coarser than what is on screen.
  • The scale is passed to every ClipWaveform (clip pills, audio-lane pills and their ghosts) as a prop, the same way gain is, so the per-clip memo stays intact.

The drawing style is unchanged (the same smoothed filled area). The spline passes through every sample, so once samples are this dense the peaks and the dips between words show up directly.

I did not implement the optional taller track / vertical zoom. That is a separate UI/design decision.

Tests

V4Timeline.waveform.test.tsx:

  • Added unit tests for both helpers: bucketing, the unmeasured and zoomed-out fallback, growth with zoom, and both caps.
  • Updated the expected bar count in the existing gain tests. In that test the 10 s clip fills the 900 px viewport, so it now draws one sample per peak block (200) instead of 80. The gain/clamp assertions themselves are unchanged.

I could not run the tests here; the expected values were worked out by hand.

Fixes #1628


Happy to adjust anything or close it if it isn't a fit.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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.

[Feature]: More detailed audio waveform for precise cutting

1 participant