Skip to main content

Module wavegen

Module wavegen 

Source
Expand description

Geometry generation for the main waveform (CPlugin::DrawWave) and custom-wave helpers (DrawCustomWaves, SmoothWave). Pure functions: no GPU.

Coordinate convention of the outputs: clip space, x right, y up (so y = 1 is the top of the screen). MD2 draws through an ortho projection with a flipped Y; DrawWave negates all y values at the end (“to stay consistent with the pre-VMS milkdrop”), which cancels the projection flip — the y it computes is the clip-space y.

Structs§

CustomWaveSampling
Parameters of one custom wave’s sample preparation (CWave fields + fWaveScale).
PmWaveGeom
Output of main_wave_geometry_projectm.
PmWaveScratch
Reusable vertex buffers of main_wave_geometry_projectm (contents are overwritten every call).
WaveGeom
Result of main_wave_geometry.

Constants§

NUM_FREQ_SAMPLES
Length of the spectrum arrays (fSpecLeft/fSpecRight).
NUM_WAVEFORM_SAMPLES
NUM_WAVEFORM_SAMPLES (MD2: 480).
NUM_WAVES_DRAWN
Number of wave modes this port draws (0..=7 are MD2 classic; 8 is the spectrum line).
NUM_WAVE_INPUT
Length of the raw waveform arrays the renderer reads (mysound.fWave[ch][576]).
PM_WAVE_MODES
Number of main-wave modes in projectM (WaveformMode::Count); the preset value is wrapped with it.
PM_WAVE_POINTS
Largest wave buffer length in projectM (WaveformMaxPoints).

Functions§

custom_wave_values_into
Port of the sample-preparation block of DrawCustomWaves: resampling, forward + backward smoothing and scaling. Fills out (cleared first) with (value1, value2) per point for the engine’s per-point code. data1/data2 are m_sound.fWaveform[0/1] (480 valid samples) or fSpectrum[0/1] (512).
main_wave_geometry
Port of the single-waveform part of DrawWave (no preset blending: its == 1).
main_wave_geometry_projectm
Port of projectM’s main waveform (Waveform::Draw minus the GL calls): vertex generation, SmoothWave, alpha and colour for wave modes 0..PM_WAVE_MODES (mw.mode already wrapped).
main_wave_geometry_raw
The per-wave part of DrawWave’s loop (for it in 0..its): the vertices and the alpha of one wave before MD2’s “don’t draw wave if alpha < 0.004” test, which only applies to the (possibly blended) final alpha. blending is m_pState->m_bBlending: the wave modes that close their loop by duplicating the first vertex do not while blending. None for an unsupported mode.
prepare_main_waveform
RenderFrame: scale (fWaveScale/128) and IIR-smooth the raw 576-sample waveform.
prepare_main_waveform_projectm
WaveformMath::GetVertices’ sample preparation: copy, scale by scale/128, IIR smoothing over 512 slots.
smooth_wave
SmoothWave: “better-than-linear” smoothing, roughly doubles the vertex count.
smooth_wave_into
smooth_wave into a reusable buffer (cleared first).

Type Aliases§

PmWaveTail
Slots NUM_WAVEFORM_SAMPLES..PM_WAVE_POINTS of projectM’s per-channel wave buffers (WaveformMath::m_pcmDataL/R).