Reputation: 740
I'm using WebAudio API to play and visualise sound and my code is based on this example. The problem with it is when you pause the sound the analyser does not update. If you getByteFrequencyData
you can see that it returns non-zero values even though there's no sound present. I want analyser keep updating data when the audio is paused just like any real life visualiser would do.
I know it's not the issue when you use <audio>
element + createMediaElementSource
instead of createBufferSource
but the last has better browser support.
Upvotes: 1
Views: 110
Reputation: 1555
Simply continue to call requestAnimationFrame
for your draw loop, and keep drawing using the data from the AnalyserNode
.
The bit of code that makes this demo "freeze" is this:
if (this.isPlaying) {
requestAnimFrame(this.draw.bind(this));
}
If you drop the if(
, it's work as you want.
Upvotes: 1