W3cubDocs

/DOM

AudioBufferSourceNode.constructor

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The AudioBufferSourceNode() constructor creates a new AudioBufferSourceNode object.

Syntax

var audioBufferSourceNode = new AudioBufferSourceNode(context, options)

Parameters

context
A reference to an AudioContext.
options Optional
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. It's nominal range is (-∞, ∞);
  • loop: A boolean indicating whether the audio should play in a loop. The default is false. If 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. The default is 0. It's 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 may usefully be set to any 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 parameter.
  • loopStart: An optional value in seconds where looping should end if the loop attribute is true. The default is 0. It may usefully be set to any 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 parameter.
  • 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 (-∞, ∞).

Specifications

Specification Status Comment
Web Audio API
The definition of 'AudioBufferSourceNode()' in that specification.
Working Draft Initial definition.

Browser Compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 55.0 ? ? 42 ?
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 55.0 ? ? ? 42 ? 55.0

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/AudioBufferSourceNode