Tone.js
Tone.js copied to clipboard
Part re-start behavior issues
There seems to be some strange behavior with starting and stopping parts.
Here is one issue where changing the BPM on the transport can introduce a long delay when start
and stop
have no parameters.
I then thought the issue might have to do with lacking the first argument to those methods but noticed that if I add a time arg, the events duplicate upon starting again.
The issue is caused by you stopping the part while keeping the transport running.
That is not how you should implement starting and stopping parts, once you start a part, it becomes a part(pun unintended) of the transport and if you want you can simply mute it while the transport is running.
I changed your fiddle a bit and everything is working properly - https://jsfiddle.net/mo9urpab/
Not sure i got what you are trying to do though.
thanks for jumping in @Seanitzel, but this does seem like a situation that we'd like to support. Though there are ways around this specific issue as you mentioned.
I looked into it a little, it seems like the toTicks
calculation that the part uses to calculate it's start time when no argument is given is not accounting for the tempo change which is why it doesn't calculate the correct time. i'm seeing what might be a good fix for this
Thanks for the tip @Seanitzel -- I think I can actually accomplish the same things I'm trying to do by just using the Transport like you suggest.
@tambien thanks for checking and that's sort of what I assumed. Does that also explain the issue with the second problem?
That is not how you should implement starting and stopping parts, once you start a part, it becomes a part(pun unintended) of the transport and if you want you can simply mute it while the transport is running.
This explains a lot of confusion I've been facing the past couple days! Unfortunately, I need to be able to cancel / stop a Part completely to free resources (as opposed to muting it).
I'm working on a feature simliar to Ableton's Clip Launching view, where you can stop and start quantized midi clips while the Transport is running.
I wonder if using Loop
or re-creating the Part
functionality with custom ToneEvents
is the best way to achive this?