Expand description
Waveform pass — MD2 modes 0..7 wired into the renderer.
WaveformRenderer owns four pipelines (alpha vs additive × lines vs
dots) that share a uniform + storage layout. Per frame the host:
- Smooths the audio samples (CPU IIR) and uploads them to
WaveformRenderer::update_wave_samples. - Updates the
WaveUniformspayload fromWaveParams. - Calls
WaveformRenderer::renderinto the warp output texture so the wave participates in the feedback loop (matches MD2’s order).
Mode 6 (double_line) is drawn in two passes: the second call sets
flip_y = 1 so the wave mirrors around wave_y. Modes 0..5 and 7
ignore flip_y.
Structs§
- Wave
Point - Legacy storage element kept for backwards-compatibility with older
tests that referenced
WavePoint. The new pipeline streams a flatarray<f32>and does NOT consumeWavePoint; the type is retained only so external code that still uses it keeps compiling. - Wave
Uniforms - Per-frame uniforms consumed by the waveform shader. Field order
MUST match
Uniformsinwaveform_advanced.wgsl. - Waveform
Renderer - GPU waveform pass — owns its pipelines, uniforms, and a sample
storage buffer of fixed length
NUM_WAVE_SAMPLES.
Enums§
- Waveform
Mode - MilkDrop 2 waveform mode (
nWaveMode, 0..7).
Constants§
- DEFAULT_
SMOOTHING_ 🔒ALPHA - Default IIR smoothing factor when
wave_smoothingis 0. MD2 uses a 5-tap moving average; a single-pole IIR with α≈0.5 is a cheap visual match. - NUM_
WAVE_ SAMPLES - Standard MD2 waveform sample length — 512 samples per channel before
downmix. The shader treats
wave_samplesas mono; the host is responsible for the L/R mix.
Functions§
- apply_
smoothing - Apply a single-pole IIR low-pass to a buffer of waveform samples,
matching MD2’s
f_wave_smoothing.smoothing∈[0, 1]: 0 = no smoothing, 0.9 ≈ heavy attenuation. Mutates in place. - build_
uniforms - Build the
WaveUniformspayload from aWaveParamssnapshot, the current frame’s instantaneous volume (used forb_mod_wave_alpha_by_volume), and the current frame resolution + aspect. - pipeline_
index 🔒