abc2svg icon indicating copy to clipboard operation
abc2svg copied to clipboard

play-1.js "onendplay" inconsistency

Open zepedrorocha opened this issue 7 years ago • 1 comments

Hello.

There's some inconsistency when 'triggering' onendplay functionality from play-1.js:

  1. When calling abcPlay.stop(), the followup animation and sound don't stop right away.
  2. 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

zepedrorocha avatar Sep 06 '17 17:09 zepedrorocha

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.

moinejf avatar Sep 06 '17 18:09 moinejf