# [PD] specifying time

Mathieu Bouchard matju at artengine.ca
Thu Feb 16 17:12:08 CET 2012

```Le 2012-02-15 à 12:07:00, Miller Puckette a écrit :

> That's an open question; I'm not sure whether computing the length of a
> blockin msec and then sending it to "delay", for instance, would always
> round back to the exact number of Pd ticks in a block.

It depends on how you do it. See attached patch to see that [int] helps
find a lot of cases of (1/x)*x = 0.999999... But there are less than how I
think there would be.

If replacing truncation by actual rounding, then the problem disappears.

C's (int) and C++'s int() are the same as Pd's [int].

> (A pd tick, internally, is small enough that one millisecond and one
> sample both are integer numbers of ticks, at least provided the SR is
> one of the "standard" ones.)

That's actually the ppcm of 192 and 88,2 kHz.

> There would still be the problem of round-off errors for larger delays -
> the only way I can see to manage that is to have the time objects have a
> notion of unit.

Would a similar things happen to all objects that take frequencies ?

[osc~ 4 kHz]        means 4000

[osc~ 1382.3 rad/s] means 220

[osc~ 36000 deg/s]  means 100

[osc~ 2 ms]         means 500

[osc~ 69 midi]      means 440

[osc~ 180 bpm]      means 3

and don't forget barks...

______________________________________________________________________
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
-------------- next part --------------
#N canvas 823 402 450 300 10;
#X obj 86 155 /;
#X obj 86 176 *;
#X floatatom 86 217 5 0 0 0 - - -;
#X floatatom 167 99 5 0 0 0 - - -;
#X obj 86 197 i;
#X obj 167 118 t b f;
#X msg 86 135 1;
#X obj 86 256 f;
#X obj 86 276 print;
#X obj 167 59 metro 20;
#X obj 167 79 f;
#X obj 192 80 + 1;
#X obj 167 41 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 86 236 sel;
#X connect 0 0 1 0;
#X connect 1 0 4 0;
#X connect 2 0 13 0;
#X connect 3 0 5 0;
#X connect 4 0 2 0;
#X connect 5 0 6 0;
#X connect 5 1 0 1;
#X connect 5 1 1 1;
#X connect 5 1 7 1;
#X connect 6 0 0 0;
#X connect 7 0 8 0;
#X connect 9 0 10 0;
#X connect 10 0 11 0;
#X connect 10 0 3 0;
#X connect 11 0 10 1;
#X connect 12 0 9 0;
#X connect 13 0 7 0;
```

More information about the Pd-list mailing list