AudioData.copyTo()
The copyTo() method of the AudioData interface copies a plane of an AudioData object to a destination buffer.
Syntax
AudioData.copyTo(destination, options)
Parameters
destination-
The
bufferto copy the plane to. options-
An object containing the following:
planeIndex-
The index of the plane to copy from.
-
frameOffsetOptional -
An integer giving an offset into the plane data indicating which plane to begin copying from. Defaults to
0. -
frameCountOptional -
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
-
DOMExceptionInvalidStateError -
Thrown if the
AudioDataobject has been transferred. -
DOMExceptionRangeError -
Thrown if the length of the sample is longer than the destination length.
-
DOMExceptionRangeError -
Thrown if the format of the
AudioDataobject describes a planar format, butoptions.planeIndexis outside of the number of planes available. -
DOMExceptionRangeError -
Thrown if the format of the
AudioDataobject describes an interleaved format, butoptions.planeIndexis greater than0.
Examples
The following example copies the plane at index 1 to a destination buffer.
AudioData.copyTo(AudioBuffer, {planeIndex: 1});
Specifications
| Specification |
|---|
| WebCodecs # dom-audiodata-copyto |
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 |
No |
No |
No |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AudioData/copyTo