Currently, I’m in the midst of a project where I’d like to store GUI values with information about how long they have been set. I could potentially do this with either the AppClock or the SystemClock - though the System clock purports to be more accurate.
I’m thinking about having a continual control bus with a constant feed of time values that I can pull from, as necessary.
Are there major CPU disadvantages to this approach? Are there better ways of accomplishing the same goal? How much accuracy would be sacrificed?
Thanks for the advice.
The current logical time is SystemClock.seconds. I would recommend this.
AppClock.seconds may or may not be subject to drift. I wouldn’t try to read an accurate time value from it.
Main.elapsedTime is the current physical time, which includes the time taken to execute instructions so far. (There is a difference between logical and physical time. I have a feeling that many recommendations for Main.elapsedTime are not deliberately choosing to measure physical time, but rather choosing the method name that sounds more like it has to do with timing. I generally prefer to measure logical time with SystemClock.)
Would it be better perhaps to have the button send a trigger to a synth, and let the synth continually measure time (using Sweep)? “Constant feed” sounds like a signal. If you’re sending time measurements from the language, either you’ll have to send them many times per second (CPU drain) or less often, but they’ll be inaccurate.
Just to clarify, you would use Sweep as the clock here - it wouldn’t be a scenario using Sweep to poll SystemClock.
Also, re: logical vs. physical - if I understand correctly, the distinction here is that Main.elapsedTime will have slightly imperfect measurements due to latency, whereas measuring from SystemClock (or using Sweep?) would be an “objective” relationship to universal time.