Skip to main content

Module waveform

Module waveform 

Source
Expand description

Waveform bar geometry (M-MEDIA.9 / AUT-105).

Maps an AudioHistogram (M-MEDIA.8) to a list of axis-aligned rectangles that wisp’s graphics pipeline can render directly. The point of this module is the crate-level architecture boundarywisp should NOT know about audio. media produces geometry; wisp draws it.

§Coordinate convention

Rectangles use a y-up convention (matching wisp NDC): x/y is the bottom-left corner, width/height are positive. Callers pass layout values in whatever unit they want — NDC [-1, +1], screen pixels, or normalized [0, 1]. The math is unit-agnostic.

§Display modes

  • mono_bars — one bar per bucket, two arrangement options:
    • WaveformDisplayMode::Anchored — bar’s bottom sits on baseline_y, grows upward by value * max_height. Common for dope-sheet rows above a timeline.
    • WaveformDisplayMode::Mirrored — bar centered on baseline_y, extends value * max_height / 2 in both directions. Common for centered “VU-style” displays.
  • stereo_bars — pairs left + right histograms: left grows up from baseline_y, right grows down. Mode is implicitly anchored; WaveformLayout::mode is ignored.

§Bar metric

BarMetric::Peak uses each bucket’s peak (max |sample|); the visualization feels punchier. BarMetric::Rms uses RMS; the visualization feels smoother.

Structs§

WaveformBarRect
One waveform bar’s rectangle.
WaveformLayout
Layout parameters shared by every bar in one waveform.

Enums§

BarMetric
Which summary statistic to drive bar height with.
WaveformDisplayMode
Arrangement of bars relative to the baseline.

Functions§

i_as_f32 🔒
mono_bars
Layout one mono histogram into a list of bar rectangles.
stereo_bars
Layout stereo histograms: left bars extend up from baseline_y, right bars extend down. Always anchored; layout.mode is ignored.