-
Notifications
You must be signed in to change notification settings - Fork 311
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
Multiple players playing simultaneously #502
Comments
I thought there was only one global Transport available (i.e. the global Tone.Transport). Are there instances? How would that look like? |
The docs say that Transport is a singleton. But looking at the code, I don't see anything that would keep me from instantiating it (it has a public constructor). 🤔 |
Each Context has one Transport created with it, so you could create multiple Tone.Context's. You might run into browser implementation constraints. For example, i know Safari can only have something like 4 or 5 AudioContext instances running at once, so you'll have to be mindful to close the unused contexts before creating a new one. |
@tambien Thanks for chiming in. So I guess my idea was bad. 😒 Then I see two possible ways to implement playback:
The first option seems cleaner to me, but it would probably be more work to implement it. What do you think? |
I think I want to push back a little and understand why you need several players so i can give you a qorkaround -- is it to turn on and off some instruments? in that case, we can just make some utility methods that concatenate these note sequences into the one "played" one. The complicated part here will be to dynamically add notes to it, but even switching the part that a player is using shouldn't be thaaaat bad. I'm not sure I understand why just stopping the Part is bad or won't work. Reimplementing Transport/Part is almost definitely not what we want to do (whatever problems Tone has we will eventually have, only then we can't look to @tambien to fix it 😅), so using whatever Tone is giving us is crucial imo |
It's not hard to imagine that there will be more than one player on the page, see e.g. my interpolation demo or the html-midi-player demo. I don't need them playing simultaneously. But the user will try to fiddle with multiple players at the same time and expect some reasonable behavior (ideally the same as with the
By that I didn't mean actually writing a new implementation of
I didn't have that in mind, but that would be awesome too. In my application, I just disable the instrument checkboxes while playing (which is OK as a workaround, but can be a bit annoying). |
It is currently not possible to have multiple players playing (or even paused) simultaneously because they are implemented using
Tone.Transport
(see #403, #418). This leads to the following problems:Tone.Transport
.@tambien suggested using
Clock
instead ofTransport
, but that would basically mean re-implementing aTransport
. So I think the best would be to just instantiate oneTransport
for each player. Is something preventing that?The text was updated successfully, but these errors were encountered: