Path: blob/main/files/en-us/web/api/audiobuffer/getchanneldata/index.md
6578 views
------{{ APIRef("Web Audio API") }}
The getChannelData() method of the {{ domxref("AudioBuffer") }} Interface returns a {{jsxref("Float32Array")}} containing the PCM data associated with the channel, defined by the channel parameter (with 0 representing the first channel).
Syntax
Parameters
channel: The channel property is an index representing the particular channel to get data for. An index value of 0 represents the first channel. If the
channelindex value is greater than of equal to {{domxref("AudioBuffer.numberOfChannels")}}, anINDEX_SIZE_ERRexception will be thrown.
Return value
A {{jsxref("Float32Array")}}.
Examples
In the following example we create a two second buffer, fill it with white noise, and then play it via an {{ domxref("AudioBufferSourceNode") }}. The comments should clearly explain what is going on. You can also run the code live, or view the source.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}