Web/API/AudioBufferSourceNode/AudioBufferSourceNode
The AudioBufferSourceNode()
constructor creates a new AudioBufferSourceNode
object instance.
Syntax
var audioBufferSourceNode = new AudioBufferSourceNode(context, options)
Parameters
Inherits parameters from the AudioNodeOptions
dictionary.
- context
- A reference to an
AudioContext
. - options Optional
- Options are as follows:
buffer
: An instance ofAudioBuffer
to be played.detune
: A value in cents to modulate the speed of audio stream rendering. Its nominal range is (-∞ to +∞). The default is0
.loop
: A boolean indicating whether the audio should play in a loop. The default isfalse
. 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 istrue
. The default is0
. Its value is exclusive to the content of the loop. The sample frames, comprising the loop, run from the valuesloopStart
toloopEnd
-(1/sampleRate
). It's sensible to set this to a value between 0 and the duration of the buffer. IfloopEnd
is less than 0, looping will end at 0. IfloopEnd
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 theplaybackRate
parameter.
loopStart
: An optional value in seconds, where looping should begin if the loop attribute istrue
. The default is0
. It's sensible to set this to a value between 0 and the duration of the buffer. IfloopStart
is less than 0, looping will begin at 0. IfloopStart
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 theplaybackRate
parameter.playbackRate
: The speed at which to render the audio stream. Its default value is1
. This parameter is k-rate. This is a compound parameter with detune. Its nominal range is (-∞ to +∞).
Return value
A new AudioBufferSourceNode
object instance.
Specifications
Specification | Status | Comment |
Web Audio APIThe definition of 'AudioBufferSourceNode()' in that specification. | Working Draft | Initial definition. |
Browser Compatibility
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
AudioBufferSourceNode() constructor
|
Chrome Full support 55 Full support 55 Notes' Before version 59, the default values were not supported. |
Edge
Full support 79 |
Firefox
Full support 53 |
IE
No support No |
Opera
Full support 42 |
Safari
No support No |
WebView Android Full support 55 Full support 55 Notes' Before version 59, the default values were not supported. |
Chrome Android Full support 55 Full support 55 Notes' Before version 59, the default values were not supported. |
Firefox Android
Full support 53 |
Opera Android
Full support 42 |
Safari iOS
No support No |
Samsung Internet Android Full support 6.0 Full support 6.0 Notes' Before Samsung Internet 7.0, the default values were not supported. |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.'
- See implementation notes.
AudioBufferSourceNode.AudioBufferSourceNode() by Mozilla Contributors is licensed under CC-BY-SA 2.5.