increpare/PuzzleScript — pull request #114 by shghs (2014-04-13 13:18:50+00:00)
Title: Reduce sfx latency in Safari

This fixes #75. Try loading the "Notsnake" example in the editor and move around really fast.

What I've done is to try avoid cloning Audio nodes when possible. Each sound effect has its own collection of Audio instances and when you call `play()` it'll reuse one if it's not currently playing, otherwise if they're all playing, it'll revert to the cloning technique.

The implementation is very simple, so there might be ways to improve it like preallocation, more sophisticated cache management, sometimes deciding not to play a sound when one was already played very recently, etc. but unless we run into bugs I think most of that is needless complicatery.