Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.39k stars 976 forks source link

Tone.Transport.scheduleRepeat cannot be disposed of until page-reload #1095

Closed Smashcat closed 2 years ago

Smashcat commented 2 years ago

After using the scheduleRepeat function, attempting to use another scheduleRepeat in the same page will cause the previous version to tick, along with the new one. This throws an error about Start time must be strictly greater than previous start.

Example: https://jsfiddle.net/oabcdnm6/

Expected behavior Should allow new values to be entered, and tones played, as they are the first time.

What I've tried Tried initialising, clearing vars etc. Seems like some global vars are being stored in the Tone.js library and cannot be cleared until a page reload.

Additional context Tried in Chrome and Firefox. Same result.

dirkk0 commented 2 years ago

The demo doesn't work for me.

Something that helped me in a similar situation was using transport.cancel(0) which cancels all scheduleRepeats. https://tonejs.github.io/docs/14.7.77/Transport#cancel

abswiz commented 2 years ago

Hey, I think you can also make a note of the eventId for the scheduleRepeat and individually clear it using transport.clear(eventId)