AudioBufferSourceNode() 构造函数创建新 AudioBufferSourceNode 对象实例。

句法

var audioBufferSourceNode = new AudioBufferSourceNode(context, options)
					

参数

Inherits parameters from the AudioNodeOptions dictionary .

context
A reference to an AudioContext .
选项 可选
Options are as follows:
  • buffer : An instance of AudioBuffer to be played.
  • detune : A value in cents to modulate the speed of audio stream rendering. Its nominal range is (-∞ to +∞). The default is 0 .
  • loop : A boolean indicating whether the audio should play in a loop. The default is false . If the loop is dynamically modified during playback, the new value will take effect on the next processing block of audio.
  • loopEnd : An optional value, in seconds, where looping should end if the loop attribute is true 。默认为 0 . Its value is exclusive to the content of the loop. The sample frames, comprising the loop, run from the values loopStart to loopEnd -(1/ sampleRate ). It's sensible to set this to a value between 0 and the duration of the buffer. If loopEnd is less than 0, looping will end at 0. If loopEnd is greater than the duration of the buffer, looping will end at the end of the buffer. This attribute is converted to an exact sample frame offset within the buffer, by multiplying by the buffer's sample rate and rounding to the nearest integer value. Thus, its behavior is independent of the value of the playbackRate 参数。
  • loopStart : An optional value in seconds, where looping should begin if the loop attribute is true 。默认为 0 . It's sensible to set this to a value between 0 and the duration of the buffer. If loopStart is less than 0, looping will begin at 0. If loopStart is greater than the duration of the buffer, looping will begin at the end of the buffer. This attribute is converted to an exact sample frame offset within the buffer, by multiplying by the buffer's sample rate and rounding to the nearest integer value. Thus, its behavior is independent of the value of the playbackRate 参数。
  • playbackRate : The speed at which to render the audio stream. Its default value is 1 . This parameter is k-rate. This is a compound parameter with detune. Its nominal range is (-∞ to +∞).

返回值

新的 AudioBufferSourceNode 对象实例。

规范

规范 状态 注释
Web 音频 API
The definition of 'AudioBufferSourceNode()' 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
AudioBufferSourceNode() 构造函数 Chrome 55 注意事项
55 注意事项
Before version 59, the default values were not supported.
Edge ≤79 Firefox 53 IE 不支持 No Opera 42 Safari ? WebView Android 55 注意事项
55 注意事项
Before version 59, the default values were not supported.
Chrome Android 55 Firefox Android 53 Opera Android 42 Safari iOS ? Samsung Internet Android 6.0 注意事项
6.0 注意事项
Before Samsung Internet 7.0, the default values were not supported.

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

见实现注意事项。

元数据

  • 最后修改: