我应该能够使用相同AudioBufferSourceNode
的声音多次播放吗?出于某种原因,第二次调用noteGrainOn
不会播放音频,即使有noteOff
.
此代码仅播放一次声音:
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)