/Web APIs

AudioData: copyTo() method

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The copyTo() method of the AudioData interface copies a plane of an AudioData object to a destination buffer.


copyTo(destination, options)



An ArrayBuffer, a TypedArray, or a DataView to copy the plane to.


An object containing the following:


The index of the plane to copy from.

frameOffset Optional

An integer giving an offset into the plane data indicating which plane to begin copying from. Defaults to 0.

frameCount Optional

An integer giving the number of frames to copy. If omitted then all frames in the plane will be copied, beginning with the frame specified in frameOffset.

Return value



InvalidStateError DOMException

Thrown if the AudioData object has been transferred.


Thrown if one of the following conditions is met:

  • The length of the sample is longer than the destination length.
  • The format of the AudioData object describes a planar format, but options.planeIndex is outside of the number of planes available.
  • The format of the AudioData object describes an interleaved format, but options.planeIndex is greater than 0.


The following example copies the plane at index 1 to a destination buffer.

AudioData.copyTo(AudioBuffer, { planeIndex: 1 });


Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
copyTo 94 94 No No 80 No 94 94 No 66 No 17.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.