[PD] arrays?

Chuckk Hubbard badmuthahubbard at gmail.com
Fri Aug 11 11:38:37 CEST 2006


Hi.
The answer is pretty simple, and might find you smacking your forehead...
In Pure Data, the way most objects work is that any message sent to
the left inlet makes the thing go, and anything sent to any other
inlet sits at that inlet and waits for the left inlet.  In your patch,
when the [metro] object sends a bang, it goes down two different
connections, but you can't tell which way it goes first; it can't go
at the exact same time.  In order to have the quotient be that of the
same two numbers that are shown as dividend and divisor, the... well
the bottom number has to go first, because when the top number gets
sent, the quotient is taken, even if the bottom number isn't there
yet.  If the bottom number isn't there yet, the previous bottom number
is used.

The solution is to use a [trigger] object.  The bang sent by the
[metro] object is then split in two, and sent down the two connections
in a specific order (right to left), sending the bottom number the
whole way before starting the top number.
Also, your setup allowed the possibility of dividing by zero.  I don't
know if you noticed.  My version adjusts the array to be 1-12 instead
of 0-11, and uses a trigger to control the order of bangs.

-Chuckk

#N canvas 579 177 652 425 10;
#N canvas 24 138 595 418 guts 1;
#N canvas 0 0 450 300 graph1 0;
#X array array1 12 float 3;
#A 0 1 2 3 4 5 6 7 8 9 10 11 12;
#X coords 0 0 12 12 200 140 1;
#X restore 336 72 graph;
#N canvas 0 0 450 300 graph1 0;
#X array array2 12 float 3;
#A 0 1 2 3 4 5 6 7 8 9 10 11 12;
#X coords 0 0 12 12 200 140 1;
#X restore 336 254 graph;
#X obj 70 237 tabread array1;
#X obj 68 341 tabread array2;
#X obj 70 263 s array1-disp;
#X obj 68 369 s array2-disp;
#X obj 84 125 metro 2000;
#X obj 84 167 random 12;
#X obj 164 167 random 12;
#X obj 206 342 /;
#X obj 206 372 s result;
#X obj 84 98 inlet;
#X obj 41 17 loadbang;
#X obj 206 276 r array1-disp;
#X obj 222 307 r array2-disp;
#X obj 84 146 t b b;
#X msg 41 40 \; array1 0 1 2 3 4 5 6 7 8 9 10 11 \; array2 1 2 3 4
5 6 7 8 9 10 11 12;
#X connect 2 0 4 0;
#X connect 3 0 5 0;
#X connect 6 0 15 0;
#X connect 7 0 2 0;
#X connect 8 0 3 0;
#X connect 9 0 10 0;
#X connect 11 0 6 0;
#X connect 12 0 16 0;
#X connect 13 0 9 0;
#X connect 14 0 9 1;
#X connect 15 0 7 0;
#X connect 15 1 8 0;
#X restore 18 377 pd guts;
#X obj 76 53 nbx 2 45 -1e+37 1e+37 0 0 empty array1-disp empty 0 -6
0 72 -262144 -1 -1 10 256;
#X obj 74 151 nbx 2 45 -1e+37 1e+37 0 0 empty array2-disp empty 0 -6
0 72 -262144 -1 -1 1 256;
#X text 61 119 --------------------------;
#X text 289 119 =;
#X obj 338 105 nbx 8 45 -1e+37 1e+37 0 0 empty result empty 0 -6 0
14 -44926 -1 -1 10 256;
#X obj 18 356 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
;
#X text 39 355 <- start;
#X connect 6 0 0 0;




More information about the Pd-list mailing list