Hello Geoff, i use setTimout to schedule events in the future, but setTimout isn't exactly precise so playuptime of note may differ quite alot. That is why i compare playup time with the realtime clock as note is played, and then i can set next note to play a little earlier to chew off the latency ***that builds up***.
Imagine a little pacman chewing up the latency by move forward in time "closer to next note"
But although i am far from an expert i can say that most probably there is a bug in javascript using setTimout to playup recursively until last note or stop.
Or i have totally missed the point of recursions. It is weird i get the latency removed when messages played twice just saying.
But can't remove it following plain logic.
https://jonasth.github.io/
The reason for using recursion is that any type of loop would not wait until note played to play next.
I do not know what kind of option there is to recursion in this case, after note "played" next note scheduled. I do not know if you familiar with setTimeout it is just a scheduled timepoint in the future to do something like a function call or execute code.
No i do not think global variables has anything to do with my recursion problems, it is just me picking up some of the complains on my coding "style?" from comp.lang.javascript LoL
There is really no problem with having some global variables, with the memory banks of today. It is naming and knowing what you are doing that is important.
And either i do not know what recursion doing, or someone did a bobo implementing it, i start to lean at the later.
JT