Skip to content

feat(timeline): draw the waveform at the zoom's detail - #1715

Open
My-Denia wants to merge 1 commit into
getopenscreen:mainfrom
My-Denia:feat/waveform-detail-1628
Open

My-Denia wants to merge 1 commit into
getopenscreen:mainfrom
My-Denia:feat/waveform-detail-1628

Conversation

@My-Denia

@My-Denia My-Denia commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The timeline waveform now gets more detailed as you zoom in, so you can see where a word starts and ends, and the short pause between two words, where you place a cut. Long recordings keep that detail, and the clip track grows when you drag the timeline taller, so quiet speech has more room.

Before this change:

  • ClipWaveform picked its sample count from the clip's duration alone: about 8 samples per second, capped at 400 per clip. A 2-minute clip was drawn at 300 ms per sample at any zoom.
  • The peak data stopped at 24 000 blocks per recording, 75 ms per block on a 30-minute take.
  • Zoom stopped at 50×, which on a 30-minute take is 36 s across the screen.

Detail follows the zoom

  • The timeline already knows pxPerSec. The waveform now draws one sample every 2–4 px, rounded up to a power of two samples per second, so a wheel zoom (×1.12 per notch) changes the density only every few notches. It never uses more samples than the recording has peak blocks.
  • Samples sit on the recording's clock, not the clip's. A move, slip or trim, or the ghost of an audio pill clipped at the timeline's end, moves the SVG. Its path is rebuilt only when an end of the drawn range crosses a 16-sample step or a 256-sample tile.
  • Only what is on screen is built: the visible span plus 24 px on each side, which covers the timeline's 20 px gutters, snapped out to 256-sample tiles. Each clip draws only its own samples. The cost follows the screen, not the length of the recording. This applies to clip cards, audio-lane pills and their ghosts. During a reorder drag, a sliding neighbour also draws up to one screen past where it slides, so a slide of up to one screen shows no blank strip.
  • It is still the smooth curve through the per-bucket peaks, not bars. Gain, clipping and the 8 % floor are unchanged. Before the panel is measured (first paint), the old 20/400 rule is kept.

Long recordings

  • Peak data: the block cap goes from 24 000 to 720 000 in all three pipelines (native ffmpeg, the decode worker, the streaming decoder). That is 5 ms per block for up to an hour, 10 ms at two hours. The disk cache key moves from v2: to v3:, so old, coarser entries are not served. The cost is in the table below.
  • Zoom: a timeline longer than 120 s can now zoom in until 2.4 s fill the panel, the depth a 2-minute take already reached. A timeline of 120 s or less keeps today's 2 % floor. The nav-bar grips follow the same floor. The nav thumb keeps a 28 px minimum width so it stays grabbable. Ruler labels keep their fraction past one hour. The canvas offset is kept to 6 decimals, so a deep zoom on an hour-long take pans smoothly.

Taller track (the issue's second point)

  • Dragging the timeline's existing height handle above its default now grows the main clip track, and the waveform with it. At the 560 px maximum, the card goes from 66 to 234 px and the waveform from 38 to 135 px.
  • The default layout is unchanged. No new control or text: the handle already persists its height.
  • Imported music and voiceover rows keep their height.
  • There is no vertical zoom on purpose: the output-gain slider already owns the waveform's amplitude, and the waveform shows what you will hear.
  • Someone whose saved height is already above the default will see a taller clip track after updating.

Known limits

  • The shape changes visibly at each density step, every few notches. This is the cost of not recomputing on every notch.
  • A looping audio pill stretches its source across the loop span, as before, so it is drawn sparser than 2–4 px per sample.
  • The peak cache in the app's user data has no eviction (unchanged). An hour-long recording's entry is now 5.76 MB instead of 192 kB, and the v2 files are left in place.

Related issue

Fixes #1628

Type of change

  • Bug fix
  • Feature
  • Enhancement
  • Documentation
  • Refactor / maintenance
  • Performance
  • Security

Release impact

  • Patch
  • Minor
  • Major / breaking change
  • No release note needed

Desktop impact

  • Windows
  • macOS
  • Linux
  • Installer / packaging
  • Not platform-specific

Renderer and main-process TypeScript only, with no platform branch.

  • Tested on Windows 11 (dev build, real app).
  • Tested on Linux: Ubuntu 24.04 under WSL2/WSLg, dev build. There the compositor addon was not built, so the preview showed no video; the timeline and its waveform were unaffected.
  • macOS was not run.

Screenshots / video

The test recordings are synthetic:

  • A 2.4 s phrase of four tone bursts 0.20–0.35 s long, separated by 80 ms, 150 ms and 250 ms gaps and followed by 820 ms of silence. It is repeated for 120 s, and also for 30 minutes.
  • 82 s of a text-to-speech voice: six sentences with 700 ms breaks.

Each view is reached with the same number of Ctrl+wheel notches from fully zoomed out, centred on the middle of the timeline. The Windows timeline is 1707 px wide.

View Before After
120 s, ~10 s on screen (22 notches)
120 s, deepest zoom, 2.4 s on screen
30 min, deepest zoom (before: 36 s; after: 2.4 s)
audio pill with its ghost
timeline dragged to its maximum height —
speech, ~10 s on screen / deepest zoom —
Linux, 120 s, ~10 s on screen

What can be told apart, checked against the ruler and the known word times:

  • 120 s, ~10 s on screen.
    • Before: about 8 points per phrase, and none of the gaps show.
    • After: 16 of 16 words and 12 of 12 gaps (80, 150 and 250 ms) are separate. Word starts land within 6 ms of the true time (median; max 12.5 ms), and ends within 3.7 ms (max 9.5 ms).
  • 120 s, deepest zoom.
    • Before: two smooth bumps for three words.
    • After: 4 of 4 words and 2 of 2 gaps, all edges within 7.5 ms.
  • 30 min.
    • Before, at the 50× limit (36 s on screen), the waveform is nearly flat: the clip has 400 samples, 4.5 s each, so about 8 fall on the screen.
    • After, with 19 s on screen, all 24 gaps in view are separate. At the deepest zoom (2.4 s), the 80, 150 and 250 ms gaps in view are each separate, edges within 2.5 ms.
  • Fully zoomed out. About 250 ms per sample on the 120 s take, so words are not separated, before or after. At that width a sample is 2–4 px.
  • Audio pill. The pill's words line up with the clip's, and the dimmed ghost carries the same pattern past the trimmed edge.
  • Taller timeline. At the default 392 px nothing moves: card 66 px, waveform 37.5 px. At 560 px the card is 234 px and the waveform 135 px, for the 120 s take and for speech alike.
  • Speech (after only).
    • About 10 s on screen: words and syllables are separate bumps with flat gaps, and the sentence breaks are clear.
    • Deepest zoom: each word shows its attack and decay.
    • Fully zoomed out: only the sentences show.
  • Linux. Same views on a 2560 px timeline. The ~10 s view draws the same samples as on Windows (viewBox 3328 0 1024 100, same path length), with 16 of 16 words and 12 of 12 gaps. The deepest zoom matches too. Dragging the panel to its maximum gives a 234 px card and a 134.5 px waveform.
  • Reorder drag. Six 500 px steps of a duplicated clip at ~10 s on screen. The carried card keeps its waveform, and no neighbour shows a blank strip.

Testing

  • npx tsc --noEmit and npx tsc -p tsconfig.test.json --noEmit: pass.

  • npx biome check on the changed TypeScript files: pass.

  • npm run test (Windows 11, Node 22.22.1): 6027 passed, 14 skipped, 6 failed.

    • All 6 failures are in .github/scripts/build-plugin-mirror.test.mjs and .github/scripts/stable-release-notes.test.mjs.
    • They come from Windows path separators (\ instead of /) and line-ending assertions.
    • This PR does not touch .github/ or the files those tests read. CI runs them on Linux.
  • New tests, each failing on the code before it:

    • Zoomed in, a 150 ms pause reaches the floor.
    • The drawn window puts a known block where it is in the clip.
    • A 50 ms trim leaves the path untouched.
    • Two halves of a cut take each draw only their own samples.
    • An unmeasured panel keeps the old rule (this one guards a fallback main already has).
    • A 30-minute timeline zooms until 2.4 s fill the panel, while 60 s keeps 2 %, and a grip drag holds that floor.
    • Ruler labels past one hour are distinct at the deepest zoom.
    • The clip track grows only by the height dragged past the default.
    • peakBlockCount follows the new cap.
  • Real app, Windows 11 dev build of the PR's head commit, measured through CDP:

    • Ctrl+wheel zoom sweeps (35 notches, 3 runs) and Shift+wheel pan sweeps (40 notches);
    • a 70-notch sweep to the new deepest zoom on the 30-minute take;
    • 10 s of playback;
    • an audio-pill move drag of 60 × 4 px;
    • a reorder drag.

    The display runs at 240 Hz, so 8.33 ms (two frames) is the floor of the per-notch time.

Per-notch time, median / p95 / max in ms:

main this PR
Zoom sweep, 35 notches, 120 s 8.2 / 8.5 / 8.6 8.2 / 8.4 / 10.2
Zoom sweep, 35 notches, 30 min 8.2 / 8.5 / 10.4 8.3 / 9.2 / 13.0
Zoom sweep to the new deepest zoom, 70 notches, 30 min — 8.2 / 8.6 / 16.1
Pan sweep, 40 notches, 120 s 8.2 / 8.7 / 12.4 8.2 / 8.4 / 8.5
Pan sweep, 40 notches, 30 min 8.2 / 8.4 / 8.5 8.3 / 8.4 / 10.2

Main-thread time per sweep, script / layout / task in ms (Chrome performance metrics):

main this PR
Zoom, 120 s 105 / 7 / 159 115 / 8 / 173
Zoom, 30 min 107 / 7 / 166 123 / 8 / 181
Pan, 120 s 130 / 6 / 182 123 / 7 / 175
Pan, 30 min 125 / 7 / 178 130 / 7 / 184

Other measurements:

main this PR
Waveform d length after 36 notches (2 paths), 120 s / 30 min 25 482 / 21 716 chars 56 322 / 57 138 chars
Path rewrites per sweep not counted (waveform props do not change on zoom) zoom: 13–14 of 35 notches; pan: 8 of 40
d changes during 10 s of playback 0 0
Audio-pill move, 60 × 4 px, bed running past the timeline end: ghost rebuilds 58 of 60 moves 1 of 60 moves
Same drag, per-move median / p95 / max (ms) 19.4 / 21.8 / 40.7 19.6 / 22.3 / 39.8
Audio-pill move, 30 s bed inside the timeline: rebuilds; per-move ms 0; 8.2 / 8.5 / 12.4 0; 8.3 / 8.4 / 8.6

Peak decoding (native ffmpeg path, median of 3 fresh processes):

24 000-block cap 720 000-block cap
120 s recording: time / cache file / process RSS 153 ms / 192 kB / 42.0 MiB 168 ms / 192 kB / 42.2 MiB (byte-identical peaks)
30 min: time / cache file / RSS 1013 ms / 192 kB / 43.3 MiB 992 ms / 2.88 MB / 45.4 MiB
60 min: time / cache file / RSS 1844 ms / 192 kB / 43.6 MiB 1705 ms / 5.76 MB / 48.2 MiB
30 min: min |peak| inside an 80 ms gap 0.44 (the gap shares its block with speech) 0.002–0.003 (noise floor)

The decode time is set by ffmpeg, not by the number of blocks, so it doesn't change. What grows is the size of the peaks: 8 bytes per block, held once per recording in the renderer and in the disk cache.

The cost that remains is on zoom. While the density changes or the window crosses a tile, a notch rebuilds a path a few hundred samples longer than before. On the 30-minute take, the 35-notch sweep's p95 rises from 8.5 to 9.2 ms and its worst notch from 10.4 to 13.0 ms. Over the full 70-notch sweep to the new deepest zoom, the worst notch is 16.1 ms. Every notch stays under a 60 Hz frame (16.7 ms). Pan stays at a median of 8.2–8.3 ms and a p95 of 8.4 ms, and playback rewrites no path.

Summary by CodeRabbit

  • New Features

    • Timeline clips can use additional vertical space when the timeline is expanded.
    • Waveforms show detail that adjusts with zoom and focus on the visible portion of the timeline.
    • Zoom supports finer views while retaining readable ruler labels, including fractional seconds on long timelines.
    • Audio peak detail is preserved at a higher resolution for recordings up to one hour.
  • Improvements

    • Timeline zoom and navigation remain consistent when adjusting the visible range or moving clips.

Copilot AI balanced review requested due to automatic review settings December 2, 2026 14:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 94fb461a-720a-47e2-a356-9aad209eb4b1
Commits

Reviewing files that changed from the base of the PR and between 8d665bd and e7eaaa4.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The change raises the audio peak cap and updates cache versioning. It also adjusts timeline clip-track sizing and navigation geometry, and renders waveform samples according to zoom and the visible timeline window.

Changes: Timeline Waveforms

Layer / File(s) Summary
Increase audio peak capacity
electron/media/audioPeaks.ts, electron/media/audioPeaks.test.ts, src/hooks/audioPeaksWorker.ts, src/hooks/streamingAudioPeaks.ts
The peak-block cap increases from 24,000 to 720,000. The cache key version changes from v2 to v3, and tests check the higher cap.
Update timeline sizing and navigation
src/components/ai-edition/NewEditorShell.tsx, src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx, src/components/ai-edition/v4/V4Timeline.tsx, src/components/ai-edition/v4/EditorShellV4.module.css, src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
The editor passes clip-track growth to V4Timeline. The timeline applies the growth to clip and snap-guide geometry, updates zoom and navigation limits, and retains fractional ruler labels at deep zoom. Tests cover sizing, zoom limits, navigation dragging, and ruler labels.
Render zoom-aware waveform windows
src/components/ai-edition/v4/V4Timeline.tsx, src/components/ai-edition/v4/EditorShellV4.module.css, src/components/ai-edition/v4/V4Timeline.waveform.test.tsx
Waveforms use zoom-dependent sampling and render a visible window with a gutter. Audio pills, ghosts, split clips, and reordered clips receive windowed waveform inputs. Tests cover zoom detail, viewport bounds, trimming, split clips, and the unmeasured-panel fallback.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant streamingAudioPeaks
  participant V4Timeline
  participant ClipWaveform
  streamingAudioPeaks->>V4Timeline: provide peak samples
  V4Timeline->>ClipWaveform: pass sample density and visible window
  ClipWaveform->>V4Timeline: render clipped waveform SVG
Loading
Merge Risk: Minimal · previous review ae93a

This change makes the timeline waveform follow zoom detail, raises the peak resolution for long recordings, and lets the clip track grow when the timeline is dragged taller. I found no concrete defect in the supplied changes, and the existing tests cover the new zoom, windowing and height behavior. It looks ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(timeline): draw the waveform at the zoom's detail" matches the main change. The PR makes the timeline waveform draw more detail as the user zooms in, and it also raises the peak block …
Description check Passed The description follows the template's main sections: Summary, Related issue, Type of change, Release impact, Desktop impact, Screenshots/video, and Testing. It links the issue with "Fixes #1628" and …
Linked Issues check Passed Direct issue #1628 asks for (1) a more detailed waveform with peaks visible, gaining detail as the timeline zooms in, and (2) optionally, a taller audio track or vertical zoom. The PR summary and the …
Out of Scope Changes check Passed All listed changes relate to the waveform detail, the zoom range needed to reach that detail, or the clip-track height. These are: peak block cap and cache key version (audioPeaks.ts, audioPeaksWorker…
Full details: Title check

Explanation

The title "feat(timeline): draw the waveform at the zoom's detail" matches the main change. The PR makes the timeline waveform draw more detail as the user zooms in, and it also raises the peak block cap for long recordings. The title names the primary change and uses a conventional commit prefix. It does not mention the taller clip track or the zoom floor change, which are secondary.

Full details: Description check

Explanation

The description follows the template's main sections: Summary, Related issue, Type of change, Release impact, Desktop impact, Screenshots/video, and Testing. It links the issue with "Fixes #1628" and gives detailed testing and measurement results. The Summary is long and includes known limits. The template's Type of change section marks Feature, and Release impact marks Minor. The Desktop impact section lists Windows and Linux, and it states that macOS was not run. The Screenshots section contains a table of images. The description is thorough, and nothing required is missing.

Full details: Linked Issues check

Explanation

Direct issue #1628 asks for (1) a more detailed waveform with peaks visible, gaining detail as the timeline zooms in, and (2) optionally, a taller audio track or vertical zoom. The PR summary and the raw summary show: (1) the waveform sample density follows pxPerSec (2-4 px per sample, power-of-two samples per second), and peak block caps rise from 24,000 to 720,000 in the native ffmpeg, decode-worker, and streaming-decoder paths (electron/media/audioPeaks.ts, src/hooks/audioPeaksWorker.ts, src/hooks/streamingAudioPeaks.ts), so word and pause detail is available at zoom. Zoom floor for timelines over 120 s is lowered to 2.4 s (V4Timeline.tsx, tested in V4Timeline.geometry.test.tsx). (2) The optional taller-track option is implemented: clipTrackGrowPx from NewEditorShell.tsx feeds --tl-clip-grow in EditorShellV4.module.css, so the clip track grows when the height handle is dragged above default. The issue lists vertical waveform zoom as optional and the PR states it is not added, which the issue permits. Tests cover zoom-dependent detail, drawing windows, trims, and track height. The objectives are met from the summary; no unmet coding requirement is identified. Source-level verification was not performed beyond the summary, so this verdict relies on the stated changes and reported tests.

Full details: Out of Scope Changes check

Explanation

All listed changes relate to the waveform detail, the zoom range needed to reach that detail, or the clip-track height. These are: peak block cap and cache key version (audioPeaks.ts, audioPeaksWorker.ts, streamingAudioPeaks.ts, needed for finer blocks); zoom floor, nav-grip floor, canvas offset precision, and ruler labels past one hour (V4Timeline.tsx and its geometry tests, needed for deep zoom on long recordings); waveform windowing and sample density (V4Timeline.tsx and waveform tests); clipTrackGrowPx prop and CSS variable (NewEditorShell.tsx, EditorShellV4.module.css, needed for the taller-track option). The PR description states that it does not touch .github/ scripts. The 6 failing tests in .github/scripts are reported as pre-existing platform issues and are not part of this PR's code changes, so they do not establish out-of-scope work. No unrelated change is demonstrated.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c5a9a638-8b07-4ccc-8b7a-b852c19d843f
Commits

Reviewing files that changed from the base of the PR and between e0a5f4b and ae93afc.

Files selected for processing: 10

  • electron/media/audioPeaks.test.ts
  • electron/media/audioPeaks.ts
  • src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx
  • src/components/ai-edition/NewEditorShell.tsx
  • src/components/ai-edition/v4/EditorShellV4.module.css
  • src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
  • src/components/ai-edition/v4/V4Timeline.tsx
  • src/components/ai-edition/v4/V4Timeline.waveform.test.tsx
  • src/hooks/audioPeaksWorker.ts
  • src/hooks/streamingAudioPeaks.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@EtienneLescot

Copy link
Copy Markdown
Member

Thanks a lot for this, and for the detailed measurements! Features here need to work on macOS, Windows and Linux. The change has no platform branch, so no port should be needed, but macOS was not run: if you can, could you add a short end-to-end video on macOS (a real capture, then zooming the timeline waveform and an export)?

Draw the clip and audio-pill waveforms at a density that follows the zoom, keep 5 ms peak blocks for recordings up to an hour (cache key v3), let long timelines zoom until 2.4 s fill the panel, and grow the clip track when the timeline is dragged taller.

Fixes getopenscreen#1628
@My-Denia
My-Denia force-pushed the feat/waveform-detail-1628 branch from 8d665bd to e7eaaa4 Compare December 2, 2026 16:12
@My-Denia

My-Denia commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

@EtienneLescot I don't have a Mac, so I can't record the macOS run. Could someone on your side check it there?

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

3 participants