Skip to main content

Function: resample()

function resample(
peaks,
bars,
options?
): Float32Array;

Defined in: display.ts:267

Aggregates peaks into bars values (0…1) for drawing. Every value covers an equal share of the range; buckets are aggregated, never skipped, so the waveform stays stable when the bar count changes. When zoomed in beyond the analyzed resolution, neighbouring bars repeat the bucket they fall into.

Runs in time linear in the buckets of the range plus bars.

Parameters​

ParameterType
peaksPeaks
barsnumber
options?ResampleOptions

Returns​

Float32Array

Example​

const bars = normalize(resample(peaks, 48)); // 48 bars, whole file
const zoomed = resample(peaks, 200, { start: 30, end: 40, metric: 'peak' });