AudioBuffer:copyToChannel() 方法
AudioBuffer 介面的 copyToChannel() 方法將源陣列的樣本複製到 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();
// Copy channel data from second channel of myArrayBuffer.
myArrayBuffer.copyFromChannel(anotherArray, 1, 0);
// Copy data from anotherArray to first channel of myArrayBuffer. Both channels have the same data now.
myArrayBuffer.copyToChannel(anotherArray, 0, 0);
規範
| 規範 |
|---|
| Web Audio API # dom-audiobuffer-copytochannel |
瀏覽器相容性
載入中…