Skip to content

Scale waveform bars from stored amplitudes to the renderer's range - #5815

Open
lukemelia wants to merge 1 commit into
mainfrom
cs-12556-audio-waveforms-render-flat-projection-passes-01-amplitude
Open

Scale waveform bars from stored amplitudes to the renderer's range#5815
lukemelia wants to merge 1 commit into
mainfrom
cs-12556-audio-waveforms-render-flat-projection-passes-01-amplitude

Conversation

@lukemelia

Copy link
Copy Markdown
Contributor

What this does

Every audio waveform rendered as a flat dashed line of identical minimum-height slivers — indistinguishable from silence — regardless of the track's dynamics. The cause is a scale mismatch across the projection seam:

  • Every envelope producer persists bars as 0..1 amplitudes: the decoded path's RMS of float samples, MP3's side-info envelope normalized to its own peak, and the WAV streaming envelope.
  • AudioPreview draws bar heights from 0–100 percentages ((v / 100) * 96) with a 1.5 minimum sliver, so a full-scale 1.0 bar computes a 0.96 height — below the minimum — and every bar clamps to the identical sliver.
  • The converting seam is waveformBarsFor in file-view-model.ts, whose contract (per AudioPreview's own comment) is to deliver bars "already normalized to 0–100". It clamped into [0, 100] but never rescaled.

waveformBarsFor now scales by 100 before clamping. There is no compatibility concern: no producer ever emitted the 0–100 scale the clamp implied, so every persisted envelope is 0..1.

Test plan

  • packages/host/tests/unit/file-view-model-test.ts: new contract test — a full-scale 1.0 bar projects to 100 (full height rather than the minimum sliver), out-of-range values clamp to [0, 100]; the existing resample and under-budget tests now feed 0..1 amplitudes and assert the projected scale. Full Unit | file-formats module: 23 tests, 58 assertions, passing locally against a full dev stack.
  • Host typecheck and eslint clean.

Fixes CS-12556.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Preview deployments

Every envelope producer persists bars as 0..1 amplitudes — decoded RMS
of float samples, MP3's peak-normalized side-info envelope, the WAV
streaming envelope — while AudioPreview draws bar heights from 0-100
percentages with a minimum sliver height. The projection clamped values
into [0, 100] but never rescaled, so a full-scale 1.0 bar computed a
height below the sliver minimum and every waveform rendered as an
identical flat dashed line, indistinguishable from silence.

waveformBarsFor now scales by 100 before clamping. No stored data ever
used the 0-100 scale the clamp implied, so there is no compatibility
concern. Tests pin the contract: a full-scale bar projects to 100,
out-of-range values clamp, and resampling operates on the projected
scale.

Fixes CS-12556.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lukemelia
lukemelia force-pushed the cs-12556-audio-waveforms-render-flat-projection-passes-01-amplitude branch from 4867aa4 to 9010dc9 Compare August 18, 2026 20:58
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.

1 participant