Function: downmixToMono()
ts
function downmixToMono(channels: Float32Array<ArrayBufferLike>[]): Float32Array;Defined in: src/lib/utils/audio.ts:57
Downmixes one or more PCM channels to a single mono channel by averaging samples across channels.
Parameters
| Parameter | Type | Description |
|---|---|---|
channels | Float32Array<ArrayBufferLike>[] | The per-channel PCM sample arrays, all the same length. |
Returns
Float32Array
The mono PCM samples, the same length as each input channel.
Remarks
A single channel is returned as-is (a copy, not the original reference — callers may safely mutate the result). Two or more channels are averaged sample-by-sample: mono[i] = mean(channels .map(c => c[i])), using each channel's own length contribution (data[i] / channels.length accumulated across channels) so the result is numerically identical regardless of channel order.