#N canvas 0 0 448 509 10; #X floatatom 127 209 0 0 0 0 - - -; #X obj 127 183 + 1; #X msg 127 79 bang; #X obj 127 131 metro 500; #X msg 38 137 stop; #X obj 127 157 float; #X obj 127 105 trigger bang bang; #X msg 226 131 0; #X obj 38 111 select 10; #X text 255 131 first set value to zero; #X text 244 105 initialization is in two steps; #X text 225 150 (before starting the metronome); #X text 15 162 conditionally; #X text 15 179 stop the; #X text 16 193 metronome; #X floatatom 25 321 0 0 0 0 - - -; #X obj 25 347 >= 0; #X obj 25 373 select 0 1; #X obj 25 425 float; #X floatatom 72 451 0 0 0 0 - - -; #X msg 59 399 bang; #X obj 72 425 + 1; #X msg 25 399 -1; #X text 71 347 <-- are we nonnegative? (1 if true \, 0 if false); #X text 100 373 <-- selectively bang the first or second outlet; #X text 100 400 <-- as a result either clear or increment the counter ; #X text 19 37 Here's a counter that counts from 1 to 10:; #X obj 1 1 cnv 15 445 20 empty \$0-pddp.cnv.header more_counters 20 10 1 18 -261139 -33289 0; #X obj 407 2 pddp/pddplink http://puredata.info/dev/pddp -text pddp ; #X obj 1 487 cnv 15 445 20 empty \$0-pddp.cnv.footer empty 20 12 0 14 -233017 -33289 0; #N canvas 76 223 494 284 META 0; #X text 12 105 WEBSITE http://crca.ucsd.edu/~msp/; #X text 12 85 LIBRARY PDDP; #X text 12 5 GENRE tutorial; #X text 12 45 LICENSE SIBSD; #X text 12 25 KEYWORDS control; #X text 12 65 DESCRIPTION examples of simple counters; #X text 12 125 HELP_PATCH_AUTHORS Miller Puckette. Updated for release 0.34. Jonathan Wilkes revised the patch to conform to the PDDP template for Pd version 0.42.; #X restore 382 489 pd META; #X text 164 79 <-- click here to start; #N canvas 12 434 428 143 References 0; #X obj 1 1 cnv 15 425 20 empty \$0-pddp.cnv.subheading empty 3 12 0 14 -261139 -33289 0; #X text 7 2 Counter- Related Help Documents; #X restore 103 489 pd References; #X obj 6 489 pddp/pddplink ../5.reference/pddp/help.pd -text help; #X text 33 232 We're using one new object \, [select] \, which outputs a bang when it gets a matching value (10). This is useful for doing conditional computations \, such as this one which counts while its input is 0 or positive but clears when negative:; #X connect 1 0 0 0; #X connect 1 0 5 1; #X connect 1 0 8 0; #X connect 2 0 6 0; #X connect 3 0 5 0; #X connect 4 0 3 0; #X connect 5 0 1 0; #X connect 6 0 3 0; #X connect 6 1 7 0; #X connect 7 0 5 1; #X connect 8 0 4 0; #X connect 15 0 16 0; #X connect 16 0 17 0; #X connect 17 0 22 0; #X connect 17 1 20 0; #X connect 18 0 21 0; #X connect 20 0 18 0; #X connect 21 0 18 1; #X connect 21 0 19 0; #X connect 22 0 18 0;