No, you can’t reuse an AudioBufferSourceNode, and you cant
push onto an AudioBuffer. Their lengths are immutable.
This article (www.html5rocks.com/en/tutorials/audio/scheduling/) has some good information about scheduling with the Web Audio API. But you’re on the right track.
I see at least 2 possible approaches.
Setting up a
scriptProcessorNode, which will feed queue of received & decoded data to realtime flow of web-audio.
Exploiting the property of
audioBufferSource.loop– updating audioBuffer’s content depending on the audio time.
Both approaches are implemented in github.com/audio-lab/web-audio-stream. You can technically use that to feed received data to web-audio.
Read more here: Source link