[PD] Advantages of using [timer] over [realtime]

Roman Haefeli reduzent at gmail.com
Thu Jan 31 16:58:17 CET 2019

On Thu, 2019-01-31 at 15:13 +0000, Mario Buoninfante wrote:

> What would be the pros and cons in using [timer] instead of
> [realtime].

Do you expect some salesman's answer? I'm not good in that. Asking for
pros and cons sounds like they have similar features where one is
"shining" in one area, while the other is more "brilliant" in this
regard. I'd say they are different by nature.

> I know the latter asks the OS for time, while [timer] deals with
> logical time.
> If I got it right, logical time is tied to the sample rate


>  (and block size)


> , so it's basically the 'Pd time'.


I think you figured out the most significant differences already.
[timer] is always consistent with objects that are able to schedule
something for later, like [metro], [delay], [pipe], [delread~], etc.

However, from what I understand it is not tied to sample rate or
blocksize, since it measures logical time in milliseconds. Its accuracy
is only limited by the 32bit floating point number format. [timer] will
give you the same results, regardless of sample rate.

> Another question would also be, which one is the most accurate?

Only [timer] is accurate regarding logical time. Assuming, Pd is
running without drop-outs, [realtime] and [timer] will give you similar
numbers, but only [timer] reflects the accurate times as they have been
generated by [delay], [metro] and such. [realtime] will suffer jitter
in the range of your delay in your audio settings. Depending on CPU
load, [realtime] will lag behind.

However, if you overload your CPU, because your patch is too demanding
to be running in realtime, [realtime] will reflect the effective
(phyiscal) time that has passed since it was last triggered. Under such
circumstance, the measurements taken by [timer] and [realtime] will
drift apart more and more and [realtime] will give you larger values
than [timer], because [timer] will be consistent with the amount of
audio computed and thus will lag behind realtime.

>  If this question is applicable.

Try this:

[t b b b]
\   |  /
 \  [pd heavy_task]
  \  /
  /  \
 /    \
[timer ]
[0.   \

[timer] will give you always 0. [realtime] will show you the exact
amount of time it took to calculate [pd heavy_task]

Heavy task could be something like:

[pow 3842.39]

Hope this helps.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20190131/be40ee92/attachment-0001.sig>

More information about the Pd-list mailing list