Jezzamonn / fourier

An Interactive Introduction to Fourier Transforms
http://www.jezzamon.com/fourier
MIT License
2.47k stars 217 forks source link

Sound stops working / AudioContext object stays open blocking resources #4

Closed zoombahh closed 5 years ago

zoombahh commented 5 years ago

thanks for the very nice demo. I ran into an audio Problem trying the different buttons:

synth.js:23 Uncaught DOMException: Failed to construct 'AudioContext': The number of hardware contexts provided (6) is greater than or equal to the maximum bound (6). at playSoundWave (http://www.jezzamon.com/fourier/main.bundle.js:1051:24) at HTMLButtonElement. (http://www.jezzamon.com/fourier/main.bundle.js:1442:36) playSoundWave @ synth.js:23 (anonymous) @ main.js:59

it seems the number of open AudioContext's allowed varies. to test I used a connditional breakpoint to close them 100 ms after the decay ends: window.setTimeout(() => audioContext.close(), decay*1000+100) && 0

Im not sure if closing the contexts or reusing one would be the better Route, its probably just a matter of style.

Jezzamonn commented 5 years ago

Interesting. Just around that time I made some tweaks to the way audio is handled. Right now it reuses the same audio context for all sound, so do you still run into this?

Also, what browser were you running into this on?

zoombahh commented 5 years ago

now it works a treat, thanks.

I ran into it on a stale xubuntu machine with integrated onboard audio:

Chromium | 65.0.3325.181 (Official Build) Built on Ubuntu , running on Ubuntu 14.04 (64-bit)

on a different pc i could spam the button 50 times and it still worked fine.

Fixed and tested live :thumbsup: