Skip to main content

Function: decodeVisualizerFrame()

function decodeVisualizerFrame(
capture: VisualizerCapture,
options: Required<VisualizerOptions>,
state: VisualizerDecodeState
): VisualizerFrame | undefined;

Defined in: packages/player/src/visualizer.ts:346

Turn one native capture into a paintable VisualizerFrame.

Parameters

ParameterTypeDescription
captureVisualizerCaptureExactly what the native sampler delivered: linear magnitudes calibrated so a full-scale sinusoid is 1.0.
optionsRequired<VisualizerOptions>Resolved options (see resolveVisualizerOptions).
stateVisualizerDecodeStateMutable smoothing/auto-gain state; updated in place.

Returns

VisualizerFrame | undefined

The decoded frame, or undefined when the capture carried no bins.

Remarks

The chain is: band power (the sum of squared magnitudes over the band's bins, i.e. the physically real quantity, not the loudest bin) → dB → the display window → asymmetric smoothing → peak ballistics. Aggregating by power rather than by maximum is what makes a band respond to how much energy is in it instead of to whichever bin happened to spike — the difference between bars that track the music and bars that flicker.

Spectral tilt and auto-gain sit in that chain too, between dB and the window, and both are off by default. What comes out of a default subscription is the measured spectrum of the audio: no cosmetic curve, no moving reference, nothing but a dB axis and a smoothing filter.