AudioBuffer: copyToChannel() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
copyToChannel()
は AudioBuffer
インターフェイスのメソッドで、元の配列から指定の AudioBuffer
のチャンネルへとコピーします。
構文
js
copyToChannel(source, channelNumber)
copyToChannel(source, channelNumber, startInChannel)
引数
source
-
コピー元となるチャンネルデータの
Float32Array
です。 channelNumber
-
チャンネルデータのコピー先となる現在の
AudioBuffer
のチャンネル番号です。 channelNumber がAudioBuffer.numberOfChannels
以上の場合はINDEX_SIZE_ERR
例外が発生します。 startInChannel
省略可-
オプションで、データをコピーする先のオフセット位置です。 startInChannel が
AudioBuffer.length
より大きければ、INDEX_SIZE_ERR
例外が発生します。
返値
なし (undefined
)。
例
js
const myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
const anotherArray = new Float32Array();
// myArrayBuffer の 2 番目のチャンネルからコピーする
myArrayBuffer.copyFromChannel(anotherArray, 1, 0);
// anotherArray から、 myArrayBuffer の 1 番目のチャンネルにコピーする。これで 2 つのチャンネルのデータは同じになる
myArrayBuffer.copyToChannel(anotherArray, 0, 0);
仕様書
Specification |
---|
Web Audio API # dom-audiobuffer-copytochannel |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
copyToChannel |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.