copyFromChannel() 方法在 AudioBuffer interface copies the audio sample data from the specified channel of the AudioBuffer to a specified Float32Array .

句法

myArrayBuffer.copyFromChannel(destination, channelNumber, startInChannel);
					

参数

destination
Float32Array to copy the channel's samples to.
channelNumber
The channel number of the current AudioBuffer to copy the channel data from.
startInChannel 可选

An optional offset into the source channel's buffer from which to begin copying samples. If not specified, a value of 0 (the beginning of the buffer) is assumed by default.

返回值

undefined .

异常

indexSizeError
One of the input parameters has a value that is outside the accepted range:
  • channelNumber specifies a channel number which doesn't exist (that is, it's greater than or equal to the value of numberOfChannels on the channel).
  • startInChannel is outside the current range of samples that already exist in the source buffer; that is, it's greater than its current length .

范例

This example creates a new audio buffer, then copies the samples from another channel into it.

var myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
var anotherArray = new Float32Array(length);
myArrayBuffer.copyFromChannel(anotherArray, 1, 0);
					

规范

规范 状态 注释
Web 音频 API
The definition of 'copyFromChannel' in that specification.
工作草案

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
copyFromChannel Chrome 14 Edge 13 Firefox 25 IE 不支持 No Opera 15 Safari 6 WebView Android Yes Chrome Android 18 Firefox Android 26 Opera Android 14 Safari iOS ? Samsung Internet Android 1.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: