Function: resampleTo()
ts
function resampleTo(
pcm: Float32Array,
fromRate: number,
toRate: number,
): Float32Array;Defined in: src/lib/utils/audio.ts:29
Linearly resamples a mono PCM buffer from one sample rate to another.
Parameters
| Parameter | Type | Description |
|---|---|---|
pcm | Float32Array | The source mono PCM samples. |
fromRate | number | The source sample rate, in Hz. |
toRate | number | The target sample rate, in Hz. |
Returns
Float32Array
The resampled mono PCM samples, Math.floor(pcm.length * toRate / fromRate) long.
Remarks
Pure resample only — no channel/downmix logic lives here (see downmixToMono for that). Uses linear interpolation between the two nearest source samples for each output sample; a no-op (returns pcm as-is) when fromRate === toRate.