I'm working on a web app that displays (and highlights) music notation as a song plays. Unfortunately, setInterval
falls short of expectations as it's highly unreliable and skippy, even on relatively low redraw resolutions.
See this demo - all I'm doing is 'activating' a bar every x msec, and some of the blocks skip. It might not be bad on fast PCs, but once actual work is done in the loop, it will definitely fall apart.
I'm looking for a solution that will let me run a ui redraw reliably and quickly, without the unacceptable delays. If it helps, the HTML5 audio
element is the master node, and all the data will be pulled from it during playback (i.e. audio.currentTime
).
Any suggestions are appreciated - perhaps I'm looking for some sort of javascript threading (that doesn't seem to exist). No matter if it's not widely supported, I'm just looking to get the job done on a proof of concept here.