hundredrabbits / Orca

Esoteric Programming Language
https://100r.co/site/orca.html
MIT License
4.58k stars 229 forks source link

Increasing clock precision #257

Open giohappy opened 3 years ago

giohappy commented 3 years ago

Testing the MIDI Clock with Reaper and Bitwig I've noticed that it has jitters and it's slightly offest. E.g. 110 bpm results in values jumping around 110.3/110.4 inside the DAWs. This is expected when setIntervalis used, even if the main clock ticks inside a WebWorker.

Have you ever considered a solution where the clock ticks on the base of time measured with performance.now()? A setInterval callback might be set to run, let's say, every 5ms, but a time "integrator" could use performance time to decide when a tick should actually trigger.

From my tests (with an infinite loop in my case) using performanceto decide when to send the MIDI clock pulses I can get a stable and reliable bpm in my DAWs.

neauoire commented 3 years ago

I'd be curious to see your implementation, I implemented that one point but it affected the performance a lot(CPU spiked), I have a slow computer, did you notice that it affected the performance a lot?

giohappy commented 3 years ago

I haven't done a performance test yet, but I will. I also want to test the AudioContext clock as an alternative.

My idea looks pretty similar to this blog post, but I will investigate more and, hopefully, share a proof of concept if anything good comes out.

boonier commented 1 year ago

@giohappy hey did anything good come out of this?

giohappy commented 1 year ago

@boonier I didn't have the chance to move this forward.