strudel
strudel copied to clipboard
REPL sync between windows
using a shared worker, there are still two problems:
the clock has some jitter on both browsers, Im not sure if its because of a calculation error or delays in the message api for workers
also the animation frames can drop above 1 cps for some reason, Im assuming it is a calculation error somewhere as well
FIxed the animation drops
the clock jitter is probably happening because the worker uses performance.now()
(system clock) as a clock source instead of AudioContext.currentTime
(audio clock). Sadly, an AudioContext cannot exist in a worker, so some other solution is needed to make sure the deadline / target time is accurate in the context of the audio clock
@felixroos this should be ready now, the clock is stabilized in firefox, and chrome behaves the same as before. Animations are working correctly. The clock no longer dies when window is unfocused. multiple windows can now sync together. I added a setCycles function as well, which we can integrate later.
not sure what is going on with these test failures though...
not sure what is going on with these test failures though...
self was not defined in node, I've wrapped it in a check
it's magic btw
I can review / test this in the coming days ok? on first sight it works great on my machine, I can also test it on my other machine then.
I can review / test this in the coming days ok? on first sight it works great on my machine, I can also test it on my other machine then.
Sounds good!
I've added a sync
flag to opt-in to the NeoCyclist, which is set by the Repl in the website. Flok also uses the repl so maybe set sync to false by default. When the next version is released, we can test if it also works in flok.
i'll try to fiddle around and see if there is a way to reuse zyklus, as it is identical to neozyklus
we should test this on mobile before merging i think. mobile browsers often suck at supporting some apis, so might need to disable it on mobile if it doesn't work
we should test this on mobile before merging i think. mobile browsers often suck at supporting some apis, so might need to disable it on mobile if it doesn't work
It works on IPhone but not on Chrome on Android for some reason...
@felixroos I added a condition to use cyclist if the client does not support shared workers and now android works again.
@felixroos I added a condition to use cyclist if the client does not support shared workers and now android works again.
great! one more thing i've noticed is that with the neo cyclist, the time won't reset when you stop and start again, which might not always be desirable when you want to listen to the same place over and over again when writing. maybe we add a checkbox to allow switching sync off? Or maybe there is also a way to detect if all repls are stopped?
@felixroos I added a condition to use cyclist if the client does not support shared workers and now android works again.
great! one more thing i've noticed is that with the neo cyclist, the time won't reset when you stop and start again, which might not always be desirable when you want to listen to the same place over and over again when writing. maybe we add a checkbox to allow switching sync off? Or maybe there is also a way to detect if all repls are stopped?
Good idea, I updated the behavior to stop the clock if all instances are stopped :) If a client disconnects while it is started would be the edge case I'm not sure how to solve. I don't think that is that much of a concern though
Good idea, I updated the behavior to stop the clock if all instances are stopped :) If a client disconnects while it is started would be the edge case I'm not sure how to solve. I don't think that is that much of a concern though
cool! so maybe a checkbox to toggle sync on or off is not required then? I guess then this could be merged (finally). I've created https://github.com/tidalcycles/strudel/issues/988 as a follow up to potentially simplify the clock sync
Good idea, I updated the behavior to stop the clock if all instances are stopped :) If a client disconnects while it is started would be the edge case I'm not sure how to solve. I don't think that is that much of a concern though
cool! so maybe a checkbox to toggle sync on or off is not required then? I guess then this could be merged (finally). I've created #988 as a follow up to potentially simplify the clock sync
sounds good! yes I hope there is a more straightforward way to simplify the this in the future. I will go ahead and merge :)