[PD] Make timer / clock

Frank Barknecht fbar at footils.org
Fri May 6 19:31:05 CEST 2005


Hallo,
sara kolster hat gesagt: // sara kolster wrote:

> I want to make a clock [stopwatch] which counts down from [for example] 
> 30 minutes till zero, but I have a very hard time making it. For so far 
> I made a counter with a metro of 1000 which counts the seconds and 
> connected a select 60 to count the minutes. [counter 1] I can combine 
> the message via pack, which prints out [for example] time: 30 min 15 sec 
> in the terminal. [counter 2]
> 
> But it gets weird when it comes close to 60:
> 
> time: 9 min 59 sec
> time: 10 min 1 sec
> time: 10 min 1 sec
> time: 10 min 60 sec
> time: 10 min 2 sec
> time: 10 min 3 sec
> 
> Cannot figure out why it is doing this.

I now could look at your patch, too. The reason for this strange
behaviour is, that the outlet of the [+ 1] in the counter can never be
0 and also the order of execution is undefined in some states of
execution. Some more triggers should help. 

But you are also using an unusual way to count. This is hard to
explain in ascii-patching, so maybe you want to take a look at
attached explanation in Pd-format.

Basically when you do the [f 0] X [+ 1] counters it's better to use
the outlet of the float object for the counter value. If you don't
want to start counting at 0, you can always add or substract some
values after the counter.

Ciao
-- 
 Frank Barknecht                               _ ______footils.org__
             
          _ __latest track: "scans" _ http://footils.org/cms/show/41
-------------- next part --------------
#N canvas 248 25 581 856 10;
#X obj 59 21 cnv 15 300 30 empty empty Counters_in_Pd 20 12 0 14 -233017
-66577 0;
#X obj 174 132 + 1;
#X obj 172 276 + 1;
#X obj 130 276 f 0;
#X obj 272 132 + 1;
#X obj 236 132 f 0;
#X obj 114 132 float 0;
#X text 207 133 ==;
#X text 311 135 ~=;
#X obj 380 132 + 1;
#X obj 344 132 f;
#X text 66 168 Every bang sent to the float will first output the current
value of the float to its outlet and to the [+ 1] \, which then adds
1 to the internally stored value of the float *without* outputting
it immediatly.;
#X text 64 226 The new value will be emitted on the next bang.;
#X floatatom 130 307 5 0 0 0 current_output - -;
#X msg 130 254 bang;
#X floatatom 172 308 5 0 0 1 next_output - -;
#X obj 192 497 + 1;
#X obj 150 497 f 0;
#X floatatom 150 528 5 0 0 0 current_output - -;
#X msg 150 432 bang;
#X floatatom 192 528 5 0 0 1 next_output - -;
#X msg 166 460 0;
#X text 193 459 <= RESET using left inlet of float;
#X obj 70 340 cnv 15 300 20 empty empty Resetting_Counters 20 10 0
12 -233017 -66577 0;
#X obj 67 588 cnv 15 300 20 empty empty From-To-Counters_(Modulo-n)
20 10 0 12 -233017 -66577 0;
#X obj 197 757 + 1;
#X obj 155 757 f 0;
#X floatatom 155 817 5 0 0 0 current_output - -;
#X msg 155 699 bang;
#X msg 171 726 0;
#X obj 155 784 mod 4;
#X text 92 634 If you want to count from 0 to a max-value and then
start over \, use a "Modulo N" counter. Note \, that the [mod] is inserted
*between* the float and the [+ 1] addition. To count until N use a
[mod N-1] object:;
#X text 65 75 Counting in Pd doesn't require externals \, you can also
count with the builtin objects. The basic idiom to remember is [f 0]
x [+ 1]:;
#X text 212 785 <= count from 0 to 3 (where 3 == 4 - 1);
#X text 87 376 To start over \, send the new starting value to the
left outlet of the float:;
#X floatatom 111 774 5 0 0 0 - - -;
#X connect 1 0 6 1;
#X connect 2 0 3 1;
#X connect 2 0 15 0;
#X connect 3 0 2 0;
#X connect 3 0 13 0;
#X connect 4 0 5 1;
#X connect 5 0 4 0;
#X connect 6 0 1 0;
#X connect 9 0 10 1;
#X connect 10 0 9 0;
#X connect 14 0 3 0;
#X connect 16 0 17 1;
#X connect 16 0 20 0;
#X connect 17 0 16 0;
#X connect 17 0 18 0;
#X connect 19 0 17 0;
#X connect 21 0 17 1;
#X connect 25 0 26 1;
#X connect 26 0 30 0;
#X connect 26 0 35 0;
#X connect 28 0 26 0;
#X connect 29 0 26 1;
#X connect 30 0 27 0;
#X connect 30 0 25 0;


More information about the Pd-list mailing list