abc2svg
abc2svg copied to clipboard
play-1.js "onendplay" inconsistency
Hello.
There's some inconsistency when 'triggering' onendplay functionality from play-1.js:
- When calling abcPlay.stop(), the followup animation and sound don't stop right away.
- the onendplay callback from abcPlay gets called before the sound & animation finishes
I've made a basic setup to demonstrate the problems:
- if you press 'play' and wait until the end you will notice console.log('end play') gettting called before the play animation ends.
- If you press 'play' and then click on 'stop' you will notice that the play animation don't stop right away.
Here's the gist or see abc2svg.zip
Thanks
Hi, After the samples have been filled to the output buffer (o.start() in play.js), the sound cannot be stopped. At the same time the sound buffer is filled, 2 timeouts are activated to do the animation. Indeed, they could be memorized and stopped with extra computation. At end of tune or at stop time, the play function calls immediately the stop callback function.
So, as the play function is called 0.3s before the end of the output buffer (time needed to do some computation), and as the output buffer is filled for 3s (see 'maxt' setting), there is always 2.7s delay between the stop callback and the end of sound/animation. In my slow machine (ARM 900MHz), these values permit a correct rendering of almost any tune.