AudioBuffer.copyFromChannel()

The copyFromChannel() method of the AudioBuffer interface copies the samples from the specified channel of the AudioBuffer to the destination array.

Syntax

myArrayBuffer.copyFromChannel(destination, channelNumber, startInChannel);

Parameters

destination
A Float32Array to copy the channel data to.
channelNumber
The channel number of the current AudioBuffer to copy the channel data from. If channelNumber is greater than or equal to AudioBuffer.numberOfChannels, an INDEX_SIZE_ERR will be thrown.
startInChannel Optional
An optional offset to copy the data from. If startInChannel is greater than AudioBuffer.length, an INDEX_SIZE_ERR will be thrown.

Return value

Void.

Example

var myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);  
var anotherArray = new Float32Array;
myArrayBuffer.copyFromChannel(anotherArray, 1, 0);

Specification

Specification Status Comment
Web Audio API
The definition of 'copyFromChannel' in that specification.
Working Draft  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support14 Yes25 No156
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic support Yes14 Yes26 No15 ?

See also

Document Tags and Contributors

 Last updated by: Jedipedia,