AudioBuffer.copyFromChannel()
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.
AudioBuffer
接口的 copyFromChannel 方法将样本从 AudioBuffer 的指定通道复制到目标数组中
语法
myArrayBuffer.copyFromChannel(destination,channelNumber,startInChannel);
参数
- destination
-
将通道数据复制到的
Float32Array
- channelNumber
-
当前 AudioBuffer 的通道号,用于复制通道数据。键入 channelNumber 大于或等于
AudioBuffer.numberOfChannels
,将会抛出INDEX_SIZE_ERR
的错误 - startInChannel 可选
-
用于复制数据的可选偏移量。假如startInChannel 比
AudioBuffer.length
大,将会抛出INDEX_SIZE_ERR
的错误
例子
js
var myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
var anotherArray = new Float32Array();
myArrayBuffer.copyFromChannel(anotherArray, 1, 0);
规范
Specification |
---|
Web Audio API # dom-audiobuffer-copyfromchannel |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
copyFromChannel |
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.