Play an AudioBufferSourceNode twice?
Posted
by
alltom
on Stack Overflow
See other posts from Stack Overflow
or by alltom
Published on 2012-02-24T23:35:48Z
Indexed on
2012/03/23
17:30 UTC
Read the original article
Hit count: 164
JavaScript
|web-audio
Should I be able to use the same AudioBufferSourceNode
to play a sound multiple times? For some reason, calling noteGrainOn
a second time doesn't play audio, even with an intervening noteOff
.
This code only plays the sound once:
var node = audioContext.createBufferSource()
node.buffer = audioBuffer
node.connect(audioContext.destination)
var now = audioContext.currentTime
node.noteGrainOn(now, 0, 2)
node.noteOff(now + 2)
node.noteGrainOn(now + 3, 0, 2)
node.noteOff(now + 5)
© Stack Overflow or respective owner