-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
[osc] mysterious clock drifting #119
Comments
This happened on a MacBook Pro with chip Apple M1 Max, memory 32 GB running Ventura 13.2.1. Drifting started after around 45 seconds. |
same drifting seems to happen with midi too. the midi clock fell ~15ms behind after roughly a minute. Midi uses WebMidi.time which is based on performance.now() and the scheduler uses AudioContext.currentTime, so these clocks are probably also not running in sync |
the scheduler is clock agnostic, so it might make sense to test what happens when it uses performance.now(). My guess is that midi will run perfectly but web audio will get out of sync.. |
this could be the solution for the clock drift: https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/getOutputTimestamp |
fixed with #666 |
this is not fixed.. it seems to be related to accumulating float rounding errors. this seems to only happen for certain cps numbers: .5 1 2 is fine, while .75 is not.. The problematic bit is most likely: const begin = this.lastEnd;
this.lastBegin = begin;
const end = round(begin + duration * this.cps);
this.lastEnd = end;
const haps = this.pattern.queryArc(begin, end); the calculation |
It doesn't necessarily need fractions, you can avoid accumulating rounding errors with a calculation like: begin = lastend
end = time_of_cps_change + (number_of_frames_since_change * time_per_frame) |
workaround const loopAx = register('loopAx',
(l, pat) => pat.loopAt(l).chop(l*8).legato(1).mul(speed(0.99))
); |
Under some unknown circumstances, the osc messages will arrive late in supercollider.
On lowend machines, this seems to happen more easily, though it could be a separate problem.
There seems to be some clock drifting going on, most likely that osc uses the system clock and strudel uses Date.now (on page load) + audio time since since page load. So far, I was only able to get late messages after a longer time of inactivity without refreshing the repl. after a refresh, the clocks are aligned again.
The clock drifting could be avoided if .osc would use performance.now instead of audio time.
The text was updated successfully, but these errors were encountered: