taisel / GameBoy-Online

JavaScript GameBoy Color emulator.
http://taisel.github.io/GameBoy-Online/
593 stars 175 forks source link

Fix audio pops when loading rom and switching between tabs by ramping gain #22

Open chrismaltby opened 5 years ago

chrismaltby commented 5 years ago

I had a look into the issue I raised at https://github.com/taisel/GameBoy-Online/issues/21 and came across this article http://alemangui.github.io/blog//2015/12/26/ramp-to-value.html which suggested using the web audio exponentialRampToValueAtTime function which I've added when the audio is first being set up and also when the visibility of the page changes (from switching tab). This seems to help quite a lot. I've only tested on Chrome as I'm using my fork in an Electron app. Hopefully this is useful.