increpare/PuzzleScript — pull request #123 by shghs (2014-04-14 15:48:27+00:00)
Title: Use Web Audio API for sound effects

Okay, I'm spending way too much time clicking those sfx buttons!

I've used the Web Audio API instead of `` elements to fix latency issues and also speed up generating sound effects from scratch. This is obviously meant foremost for Safari, but it should also be noticeably snappier in Chrome and Firefox too, especially generating sounds from the console toolbar. So I believe this PR fixes #75 and #84.

(It's might still be worth looking into #84 for browsers that don't support the Web Audio API, since they'll get the fallback `` implementation instead. Though aside from IE, the latest versions of all other browsers should have the required API support.)

However, some sound effects do sound a bit different now that they're bumped up to 44,100 Hz. After quite a bit of experimenting, I think this is the closest I can manage to get to the original sound effects. I've used a filter to mimic a 5k sample rate, and I've also made a branch [sfx-webaudio-4x-sample](https://github.com/shghs/PuzzleScript/tree/sfx-webaudio-4x-sample)
using the "zero-order hold" technique and 22,050 Hz to compare with – though I much prefer the filter!

@increpare Please let me know if you come across any other audio issues and I'm always happy to help.