Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

play-1.js "onendplay" inconsistency #27

Open
zepedrorocha opened this issue Sep 6, 2017 · 1 comment
Open

play-1.js "onendplay" inconsistency #27

zepedrorocha opened this issue Sep 6, 2017 · 1 comment

Comments

@zepedrorocha
Copy link

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

@moinejf
Copy link
Owner

moinejf commented Sep 6, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants