AudioData: copyTo() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Note: This feature is available in Dedicated Web Workers.

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

Syntax

js
copyTo(destination, options)

Parameters

destination

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

options

An object containing the following:

planeIndex

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

Undefined.

Exceptions

InvalidStateError DOMException

Thrown if the AudioData object has been transferred.

RangeError

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.

Examples

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

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

Specifications

Specification
WebCodecs
# dom-audiodata-copyto

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
copyTo
Chrome – Full support
Chrome 94 (Release date: 2021-09-21)
footnote Full support
Edge – Full support
Edge 94 (Release date: 2021-09-24)
footnote Full support
Firefox – Full support
Firefox 130 (Release date: 2024-09-03)
footnote Full support
Opera – Full support
Opera 80 (Release date: 2021-10-05)
footnote Full support
Safari – Full support
Safari 26 (Release date: 2025-09-15)
footnote Full support
Chrome Android – Full support
Chrome Android 94 (Release date: 2021-09-21)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 66 (Release date: 2021-12-15)
footnote Full support
Safari on iOS – Full support
Safari on iOS 26 (Release date: 2025-09-15)
footnote Full support
Samsung Internet – Full support
Samsung Internet 17 (Release date: 2022-05-04)
footnote Full support
WebView Android – Full support
WebView Android 94 (Release date: 2021-09-21)
footnote Full support
WebView on iOS – Full support
WebView on iOS 26 (Release date: 2025-09-15)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support