Repository navigation
feat(waveform): Ableton-grade hi-res waveforms (Triage + Editor) - #59
Merged
Merged
Conversation
Replace the coarse, over-smoothed waveform sources with a shared, transient-accurate engine used by Triage, the Editor and SeamStrip. Root causes fixed: - Coarse source data — Triage drew a 10 Hz RMS envelope (100 ms/value); the Editor drew 4000 fixed buckets over the whole song (~0.9 s/bucket on hour-long recordings). Now both read a multi-resolution min/max peak pyramid built off the full PCM (2.9 ms base buckets, transient-preserving). - RMS averaging — replaced by min/max so beat onsets keep their attack edge. - 3-tap smoothing — removed; the body is drawn crisp. - Retina under-sampling — the draw loop now steps DEVICE pixels (one vertex per device pixel at x=i/dpr) instead of CSS pixels. New shared modules (pure, unit-tested): - local/waveform/peak-pyramid.ts — buildPeakPyramid + pickLevel / bucketRangeForTime / aggregateColumn / rawPcmColumn, plus an envelope-derived fallback for the cached-open race. - local/waveform/draw-waveform.ts — device-pixel draw engine; returns the per-CSS-column max so Triage's silence tint/dB guides stay locked to the body. - local/waveform/build-pyramid-async.ts — chunked build so hour-long PCM doesn't jank the main thread. Per-view: Editor normalizes absolute (Ableton-honest), Triage peak (lane stays filled, silence threshold consistent). Editor keeps its per-arrangement-segment projection via a mapXToTime closure; long-form gaps stay gaps. Retired timeline-waveform.ts and the 4000-bucket waveform-peaks.ts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
At sub-sample zoom the raw-PCM path returns min==max per column, so the filled body had zero height and vanished — only the centre line remained and the Triage waveform read as a flat stroke. Enforce a minimum body half-height (expandToMinThickness) so a too-thin column is expanded symmetrically around its value; the band then traces the real sample values as a thin line instead of collapsing. No effect at normal zoom where bodies are far taller than the floor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reported: the Triage waveform went flat as soon as you zoomed in even a
little (fine when zoomed out; reload reproduced it). Root cause, confirmed
live via console: the triage store detaches its PCM buffer a few seconds
after load (BPM re-detection / worker transfer), leaving a length-0 — but
still truthy — Float32Array. The draw engine's raw-PCM path was gated on
`!!pcm`, which stays true for an empty array; zooming in dropped
samples-per-pixel below the bucket size, switched to the raw path, and
rawPcmColumn(empty) returned {0,0} for every column → a flat line.
- Guard useRaw on `pcm.length > 0` so a detached buffer falls back to the
pyramid instead of producing zeros (regression test added).
- Keep the crisp PCM pyramid once built instead of dropping to the coarse
10 Hz envelope when `pcm` later empties (Triage + SeamStrip).
Verified live at full / 12 s / 1.5 s zoom: crisp transient-accurate body
at every level.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Triage showed a coarse envelope first and then "snapped" to the high-res waveform after a while: it rebuilt the pyramid in-memory on every open, and the chunked build yields to a busy load thread, so the swap-in was visibly delayed. Precompute it once where the master PCM is already decoded (jobs.ts, next to the audio-analysis step) and persist it per job in a new IDB store. Triage now reads it from cache on open → instant high-res, no coarse→sharp pop. - New "waveform-pyramid" IDB store (created whenever missing in `upgrade`, so it self-heals; additive, no data migration). Accessors on jobsDb. - pyramid-cache.ts: getCachedPyramid / savePyramid / getOrComputePyramid (mirrors the audio-analysis cache; payload carries its own version + sr). - jobs.ts sync step builds + persists the pyramid (non-blocking, from the clean non-detached decode PCM). - Triage + SeamStrip prefer the cached pyramid; lazy in-memory build is the fallback for jobs synced before this existed, and backfills the cache — but only when the source PCM survived the whole build (guard against persisting a half-zeroed pyramid if the store detaches its buffer mid-build). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
johannboehme
added a commit
that referenced
this pull request
Jun 20, 2026
Resolves the jobs-db.ts conflict: keeps the new ColorGradeRecord / FilterSlotRecord + VITE_DB_NAME override AND adopts main's DB_VERSION 11 (waveform-pyramid store from #59). Other files auto-merged. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Was & warum
Die Waveforms in Triage und im Editor wirkten beim Reinzoomen niedrig aufgelöst und stark geglättet — schlecht zum Arbeiten im Non-Snap-Modus, weil man Beat-Onsets optisch nicht präzise trifft. Ziel: Ableton-Qualität — scharfe, transienten-genaue Waveform, bei der Zoom echtes Detail freilegt.
Root causes (im Code bestätigt)
Ansatz
Ein gemeinsamer, transienten-genauer Waveform-Engine für Triage, Editor und SeamStrip.
Neue Module (rein, unit-getestet):
local/waveform/peak-pyramid.ts— Multi-Resolution Min/Max-Pyramide aus dem vollen PCM (Basis 64 Samples ≈ 2,9 ms; transienten-erhaltend). PluspickLevel/bucketRangeForTime/aggregateColumn/rawPcmColumnund ein Hüllkurven-Fallback.local/waveform/draw-waveform.ts— Zeichen-Engine auf Geräte-Pixel-Granularität, ohne Smoothing; gibt das Spalten-Max zurück, damit Triages Silence-Tint an der Silhouette klebt.local/waveform/build-pyramid-async.ts— chunked Build (kein Jank bei stundenlangem PCM).local/waveform/pyramid-cache.ts+ neuer IndexedDB-Store — Pyramide wird im Sync-Schritt vorberechnet und persistiert, Triage lädt sie sofort (kein Coarse→Sharp-Pop).Per-View: Editor normalisiert absolut (Ableton-ehrlich), Triage peak (Lane bleibt gefüllt, Silence-Threshold konsistent). Editor behält seine Per-Arrangement-Segment-Projektion via
mapXToTime-Closure; Long-form-Lücken bleiben Lücken. Retired:timeline-waveform.tsund das 4000-Bucketwaveform-peaks.ts.Während des Live-Tests gefundene & gefixte Bugs
{0,0}→ flache Linie. Fix:useRawaufpcm.length > 0absichern; gebaute Pyramide behalten statt auf die Hüllkurve zurückzufallen.min == max) hatte die gefüllte Fläche null Höhe und verschwand. Fix: garantierte Mindesthöhe, die die echten Sample-Werte als dünne Linie nachzeichnet.Verifikation
tsc -bsauber.Hinweise für Review
waveform-pyramid;DB_VERSIONlandete bei 11 (Dev-Iteration). Der Store wird inupgradeangelegt, sobald er fehlt — die exakte Nummer ist egal. Bei Bedarf auf 8→9 umnummerierbar.🤖 Generated with Claude Code