[PD] metro and drift

Frank Barknecht fbar at footils.org
Sat Apr 1 11:08:17 CEST 2006


Hallo Damian, 
Damian Stewart hat gesagt: // Damian Stewart wrote:

> I set up three metros, one to bang once every beat, one to bang every 
> 27th of a beat (triplet-based time), and one to bang every 49th of a 
> beat (1/7th-based time). Then I left it running for a while, using timer 
> and realtime to measure drift over each beat. The patch I used is attached.
> 
> Over 60 minutes:
> 
> Between whole beat and beat counted from 27ths:
> realtime 0.002ms drift
> timer 0.144ms drift
> 
> Between whole beat and beat counted from 49ths:
> realtime 0.01ms drift
> timer 0.149ms drift
> 
> Between whole beat counted from 27ths and from 49ths:
> realtime 0.002ms drift
> timer 0.007ms drift
> 
> Now, I'm not totally sure how to interpret these numbers, and certainly 
> don't understand the huge discrepancies between realtime and timer 
> outputs, but it seems like drift isn't going to be any problem for this 
> amount of time.

You have a kind of bug in your patch because at several points the
execution order isn't well defined. The [timer] output actually should
not drift at all, as the clock used by timer to read the time is the
same as the clock used by metro to "set the time", that is, its own
period. The interesting number is the realtime measurement. Here also
it is important to take care of execution order using [t b b] and such
objects. Otherwise it will for example happen, that you get the time
of different beat numbers. 

I attached a version of your patch that uses a well-defined execution
order. The drift measuremeants are initiated by a delayed bang, so it
will always measure the drift of the same beat. 

With that patch I get no time drift with [timer] as expected.  The
results for the intervals between beats measured with [realtime]
however ocillate regularily up to about 5 msec on my linux system for
every metro period. As this happens in a very regular pattern I
suppose this is some kind synchronisation problem between the Pd clock
and the realtime clock of the operating system used in [realtime].
Check the table "drift" to see the regularity of the pattern.

Ciao
-- 
 Frank Barknecht                 _ ______footils.org_ __goto10.org__
-------------- next part --------------
#N canvas 489 -6 761 694 10;
#X obj 123 249 metro;
#X obj 332 229 / 27;
#X obj 302 254 metro;
#X obj 154 323 + 1;
#X msg 143 301 0;
#X obj 123 324 f 0;
#X floatatom 347 254 5 0 0 0 - - -;
#X obj 509 240 / 49;
#X obj 480 264 metro;
#X obj 187 322 % 1;
#X obj 123 375 select 0;
#X msg 359 130 117;
#X text 395 130 bpm;
#X text 338 403 27 * 1/27th;
#X text 511 403 49 * 1/49th;
#X floatatom 523 264 5 0 0 0 - - -;
#X obj 333 337 + 1;
#X msg 322 315 0;
#X obj 302 338 f 0;
#X obj 511 336 + 1;
#X msg 500 314 0;
#X obj 480 337 f 0;
#X obj 544 335 % 49;
#X obj 480 370 select 0;
#X obj 366 336 % 27;
#X obj 302 375 select 0;
#X obj 153 278 r \$0-rst;
#X obj 325 293 r \$0-rst;
#X obj 502 290 r \$0-rst;
#X obj 392 111 s \$0-rst;
#X floatatom 168 251 8 0 0 0 - - -;
#X obj 359 156 expr 60000/$f1;
#X obj 359 76 select 1;
#X obj 123 10 tgl 32 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
;
#X obj 123 59 t a a;
#X obj 153 222 t a;
#N canvas 0 0 450 300 time-realtime 0;
#X obj 141 102 t b b;
#X obj 141 134 realtime;
#X obj 88 101 t b b;
#X obj 88 133 timer;
#X obj 88 163 outlet;
#X obj 88 58 t b b;
#X obj 141 165 outlet;
#X obj 89 38 inlet;
#X connect 0 0 1 0;
#X connect 0 1 1 1;
#X connect 1 0 6 0;
#X connect 2 0 3 0;
#X connect 2 1 3 1;
#X connect 3 0 4 0;
#X connect 5 0 2 0;
#X connect 5 1 0 0;
#X connect 7 0 5 0;
#X restore 123 419 pd time-realtime;
#X obj 130 400 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X text 187 395 1 * 1;
#N canvas 0 0 450 300 time-realtime 0;
#X obj 141 102 t b b;
#X obj 141 134 realtime;
#X obj 88 101 t b b;
#X obj 88 133 timer;
#X obj 88 163 outlet;
#X obj 88 58 t b b;
#X obj 141 165 outlet;
#X obj 89 38 inlet;
#X connect 0 0 1 0;
#X connect 0 1 1 1;
#X connect 1 0 6 0;
#X connect 2 0 3 0;
#X connect 2 1 3 1;
#X connect 3 0 4 0;
#X connect 5 0 2 0;
#X connect 5 1 0 0;
#X connect 7 0 5 0;
#X restore 302 423 pd time-realtime;
#X obj 309 404 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#N canvas 0 0 450 300 time-realtime 0;
#X obj 141 102 t b b;
#X obj 141 134 realtime;
#X obj 88 101 t b b;
#X obj 88 133 timer;
#X obj 88 163 outlet;
#X obj 88 58 t b b;
#X obj 141 165 outlet;
#X obj 89 38 inlet;
#X connect 0 0 1 0;
#X connect 0 1 1 1;
#X connect 1 0 6 0;
#X connect 2 0 3 0;
#X connect 2 1 3 1;
#X connect 3 0 4 0;
#X connect 5 0 2 0;
#X connect 5 1 0 0;
#X connect 7 0 5 0;
#X restore 480 421 pd time-realtime;
#X obj 487 402 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
-1;
#X floatatom 123 450 8 0 0 0 - - -;
#X floatatom 230 451 8 0 0 0 - - -;
#X floatatom 302 452 8 0 0 0 - - -;
#X floatatom 409 453 8 0 0 0 - - -;
#X floatatom 480 450 8 0 0 0 - - -;
#X floatatom 587 451 8 0 0 0 - - -;
#X obj 214 569 -;
#X obj 214 521 f;
#X obj 393 523 f;
#X floatatom 214 615 10 0 0 0 - - -;
#X msg 22 469 get drifts;
#X obj 571 528 f;
#X obj 555 562 -;
#X floatatom 555 615 10 0 0 0 - - -;
#X obj 393 565 -;
#X floatatom 393 614 10 0 0 0 - - -;
#X obj 214 486 t b b b;
#X obj 214 591 * 1000;
#X obj 393 587 * 1000;
#X obj 555 587 * 1000;
#X obj 22 416 del 100;
#X text 113 614 1/1000 msec;
#X obj 279 509 -;
#X obj 279 485 t f f;
#X floatatom 279 528 8 0 0 0 - - -;
#X obj 431 503 -;
#X obj 431 479 t f f;
#X floatatom 431 522 8 0 0 0 - - -;
#X obj 608 507 -;
#X obj 608 483 t f f;
#X floatatom 608 526 8 0 0 0 - - -;
#X obj 123 517 -;
#X obj 123 493 t f f;
#X floatatom 123 536 8 0 0 0 - - -;
#X obj 494 61 table drift 100;
#N canvas 0 0 459 405 table-stuff 0;
#X obj 83 269 s drift;
#X obj 84 124 f 0;
#X obj 141 123 mod 100;
#X obj 84 96 t b a;
#X obj 83 145 pack 0 0;
#X msg 205 125 const 0;
#X obj 159 63 r \$0-rst;
#X msg 141 98 0;
#X obj 111 123 + 1;
#X msg 204 209 bounds 0 6 99 -6;
#X obj 204 175 loadbang;
#X obj 84 37 r to-table;
#X connect 1 0 4 0;
#X connect 1 0 8 0;
#X connect 2 0 1 1;
#X connect 3 0 1 0;
#X connect 3 1 4 1;
#X connect 4 0 0 0;
#X connect 5 0 0 0;
#X connect 6 0 5 0;
#X connect 6 0 7 0;
#X connect 7 0 1 1;
#X connect 8 0 2 0;
#X connect 9 0 0 0;
#X connect 10 0 9 0;
#X connect 11 0 3 0;
#X restore 597 264 pd table-stuff;
#X obj 279 573 s to-table;
#X connect 0 0 5 0;
#X connect 1 0 2 1;
#X connect 1 0 6 0;
#X connect 2 0 18 0;
#X connect 3 0 9 0;
#X connect 4 0 5 1;
#X connect 5 0 3 0;
#X connect 5 0 10 0;
#X connect 7 0 8 1;
#X connect 7 0 15 0;
#X connect 8 0 21 0;
#X connect 9 0 5 1;
#X connect 10 0 37 0;
#X connect 10 0 36 0;
#X connect 10 0 63 0;
#X connect 11 0 31 0;
#X connect 16 0 24 0;
#X connect 17 0 18 1;
#X connect 18 0 16 0;
#X connect 18 0 25 0;
#X connect 19 0 22 0;
#X connect 20 0 21 1;
#X connect 21 0 19 0;
#X connect 21 0 23 0;
#X connect 22 0 21 1;
#X connect 23 0 41 0;
#X connect 23 0 42 0;
#X connect 24 0 18 1;
#X connect 25 0 39 0;
#X connect 25 0 40 0;
#X connect 26 0 4 0;
#X connect 27 0 17 0;
#X connect 28 0 20 0;
#X connect 31 0 7 0;
#X connect 31 0 1 0;
#X connect 31 0 35 0;
#X connect 32 0 29 0;
#X connect 32 0 11 0;
#X connect 33 0 34 0;
#X connect 34 0 0 0;
#X connect 34 0 2 0;
#X connect 34 0 8 0;
#X connect 34 1 32 0;
#X connect 35 0 30 0;
#X connect 35 0 0 1;
#X connect 36 0 43 0;
#X connect 36 1 44 0;
#X connect 39 0 45 0;
#X connect 39 1 46 0;
#X connect 41 0 47 0;
#X connect 41 1 48 0;
#X connect 43 0 75 0;
#X connect 44 0 50 1;
#X connect 44 0 66 0;
#X connect 46 0 51 1;
#X connect 46 0 69 0;
#X connect 48 0 54 1;
#X connect 48 0 72 0;
#X connect 49 0 60 0;
#X connect 50 0 49 0;
#X connect 50 0 57 0;
#X connect 51 0 49 1;
#X connect 51 0 55 0;
#X connect 53 0 59 0;
#X connect 54 0 55 1;
#X connect 54 0 57 1;
#X connect 55 0 62 0;
#X connect 57 0 61 0;
#X connect 59 0 50 0;
#X connect 59 1 51 0;
#X connect 59 2 54 0;
#X connect 60 0 52 0;
#X connect 61 0 58 0;
#X connect 62 0 56 0;
#X connect 63 0 53 0;
#X connect 65 0 67 0;
#X connect 66 0 65 1;
#X connect 66 1 65 0;
#X connect 67 0 79 0;
#X connect 68 0 70 0;
#X connect 69 0 68 1;
#X connect 69 1 68 0;
#X connect 71 0 73 0;
#X connect 72 0 71 1;
#X connect 72 1 71 0;
#X connect 74 0 76 0;
#X connect 75 0 74 1;
#X connect 75 1 74 0;


More information about the Pd-list mailing list