[PD] Patchmatrix Execution Order Issues

Frank Barknecht fbar at footils.org
Sat Jan 20 13:16:17 CET 2007


Hallo,
Luke Iannini (pd) hat gesagt: // Luke Iannini (pd) wrote:

> Now, the issue I was having crops up when routing the result of a
> single inlet "matrixed" to multiple outlets back into an inlet.  I
> think it occurs in your copy as well: the first outlet to recieve the
> input (let's say it was "10101" again) transmits it to the top of the
> chain, and before your list drip has completed, a new input/row is
> received that overrides the first (also replacing the contents of the
> list append at the bottom).
> 
> I have attached a modified copy of your patch demonstrating this.
> Most mods are in the lower left; use my element definitions to see the
> issue in action.  If you disconnect the "loopback" sends (outputs Y&Z
> >inputs B&C in the lower left) it works fine, but when they are
> connected only one output makes it out.

Okay, this is indeed true and it has to do with Pd's "depth first"
message passing: Pd tries to walk along a message path until this path
ends. E.g. if you have a [t b b] then first everything connected to
the right outlet will be worked out completely before the bang from
the left outlet of the trigger will fire. 

With your loopback setup, walking along will work fine for the
outletY-route at first, but as soon as inletB fires, the counter after
the matrix in [pd count] will be reset to start at 0 again and the
[list] storing the 10101 will be overwritten by what's coming in
through inletB (in this case, a 10101 will come in again, but that's
just luck, it could be something different). So a lot of stuff will be
invalidated by the looped back message.

The solution is to defer the looped back messages until every direct
message has finished operations. You can do this easily with [pipe]
objects between the [r outlet?] and [s inlet?] objects. [pipe] (and
[del] will delay messages for one logical step even, if the delay time
is 0. They kind of insert a temporary end point to the depth first
message operations.

As a bonus I attached a little GUI abstraction to edit 0/1 matrices of
arbitrary size. This might be useful for your patch. It expects Pd at
least 0.40 to look nice. It also seems to trigger a bug in Pd and
makes the red GOP rectangle appear on the parent somehow. 

Ciao
-- 
 Frank Barknecht                 _ ______footils.org_ __goto10.org__
-------------- next part --------------
#N canvas 330 49 806 673 10;
#X obj 246 72 route matrix;
#X obj 246 136 list split 2;
#X obj 276 199 unpack 0 0;
#X obj 246 97 t a b;
#X floatatom 315 401 5 0 0 0 - - -;
#X floatatom 257 401 5 0 0 0 - - -;
#X obj 247 375 mod 3;
#X obj 298 376 div 3;
#X obj 276 292 *;
#N canvas 0 0 450 300 count-to 0;
#X obj 85 145 f 0;
#X obj 113 145 + 1;
#X obj 85 181 outlet;
#X obj 85 89 inlet;
#X obj 128 89 inlet;
#X msg 128 118 0;
#X obj 85 113 until;
#X connect 0 0 1 0;
#X connect 0 0 2 0;
#X connect 1 0 0 1;
#X connect 3 0 6 0;
#X connect 4 0 5 0;
#X connect 5 0 0 1;
#X connect 6 0 0 0;
#X restore 276 312 pd count-to;
#X msg 588 277 clear;
#X obj 276 337 t a a a;
#N canvas 0 0 705 481 drip 0;
#X obj 39 229 list split 1;
#X obj 39 146 until;
#X obj 39 184 list append;
#X obj 169 229 bang;
#X text 121 113 First store list \, then start the loop;
#X text 138 141 "until" bangs its output until told to stop by a "bang"
to its right inlet.;
#X text 157 183 Store the remaining list.;
#X obj 67 76 inlet;
#X obj 65 113 t b a;
#X obj 40 258 outlet;
#X connect 0 0 9 0;
#X connect 0 1 2 1;
#X connect 0 2 3 0;
#X connect 1 0 2 0;
#X connect 2 0 0 0;
#X connect 3 0 1 1;
#X connect 7 0 8 0;
#X connect 8 0 1 0;
#X connect 8 1 2 1;
#X restore 80 390 pd drip;
#N canvas 0 0 450 300 count 0;
#X obj 85 145 f 0;
#X obj 113 145 + 1;
#X obj 85 181 outlet;
#X obj 85 89 inlet;
#X obj 128 89 inlet;
#X msg 128 118 0;
#X obj 85 113 b;
#X connect 0 0 1 0;
#X connect 0 0 2 0;
#X connect 1 0 0 1;
#X connect 3 0 6 0;
#X connect 4 0 5 0;
#X connect 5 0 0 1;
#X connect 6 0 0 0;
#X restore 80 451 pd count;
#X obj 80 498 pack 0 0;
#X obj 80 367 list;
#X obj 246 156 t b a;
#X obj 246 43 inlet;
#X obj 247 580 s pd-\$0-edit-matrix;
#N canvas 127 215 420 390 \$0-edit-matrix 0;
#X coords 0 -1 1 1 150 150 1 5 20;
#X restore 5 25 pd \$0-edit-matrix;
#X msg 305 41 matrix 4 3 1 1 0 1 1 1 1 1 1 0 1 1;
#X obj 247 518 pack 0 0 0 \$0;
#X obj 80 520 s \$0-in;
#X obj 649 397 r \$0-out;
#X obj 649 584 outlet;
#X obj 80 411 t b a;
#X msg 247 547 obj \$1 \$2 matrix-element \$3 \$4;
#X obj 649 422 unpack 0 0;
#X obj 649 447 t a a;
#X obj 649 522 pack 0 0 0;
#X msg 649 550 element \$1 \$2 \$3;
#X obj 649 498 + 1;
#X obj 681 497 + 1;
#X obj 700 471 mod 3;
#X obj 649 470 div 3;
#X obj 247 481 + 5;
#X obj 298 432 * 15;
#X obj 247 433 * 15;
#X obj 298 463 + 20;
#X connect 0 0 3 0;
#X connect 1 0 16 0;
#X connect 1 1 15 1;
#X connect 2 0 8 0;
#X connect 2 1 6 1;
#X connect 2 1 7 1;
#X connect 2 1 8 1;
#X connect 2 1 33 1;
#X connect 2 1 34 1;
#X connect 3 0 1 0;
#X connect 3 1 9 1;
#X connect 3 1 13 1;
#X connect 3 1 10 0;
#X connect 6 0 5 0;
#X connect 6 0 37 0;
#X connect 7 0 4 0;
#X connect 7 0 36 0;
#X connect 8 0 9 0;
#X connect 9 0 11 0;
#X connect 10 0 18 0;
#X connect 11 0 6 0;
#X connect 11 1 7 0;
#X connect 11 2 21 2;
#X connect 12 0 25 0;
#X connect 13 0 14 0;
#X connect 14 0 22 0;
#X connect 15 0 12 0;
#X connect 16 0 15 0;
#X connect 16 1 2 0;
#X connect 17 0 0 0;
#X connect 20 0 0 0;
#X connect 21 0 26 0;
#X connect 23 0 27 0;
#X connect 25 0 13 0;
#X connect 25 1 14 1;
#X connect 26 0 18 0;
#X connect 27 0 28 0;
#X connect 27 1 29 2;
#X connect 28 0 34 0;
#X connect 28 1 33 0;
#X connect 29 0 30 0;
#X connect 30 0 24 0;
#X connect 31 0 29 0;
#X connect 32 0 29 1;
#X connect 33 0 32 0;
#X connect 34 0 31 0;
#X connect 35 0 21 0;
#X connect 36 0 38 0;
#X connect 37 0 35 0;
#X connect 38 0 21 1;
#X coords 0 -1 1 1 150 170 1 5 5;
-------------- next part --------------
#N canvas 416 99 456 436 10;
#X obj 128 170 show-matrix;
#X obj 56 86 mtx;
#X msg 56 60 eye 5 7;
#X msg 237 71 matrix 2 3 1 1 0 1 1 0;
#X obj 128 359 print ELEMENTS;
#X msg 128 72 matrix 9 2;
#X msg 133 94 matrix 10 3;
#X msg 190 121 matrix 10 9;
#X msg 188 140 matrix 10 10 0 0 1 0 0 1;
#X connect 0 0 4 0;
#X connect 1 0 0 0;
#X connect 2 0 1 0;
#X connect 3 0 0 0;
#X connect 5 0 0 0;
#X connect 6 0 0 0;
#X connect 7 0 0 0;
#X connect 8 0 0 0;
-------------- next part --------------
#N canvas 0 0 450 300 10;
#X obj 168 169 list prepend \$1;
#X obj 173 74 route \$1;
#X obj 173 53 r \$2-in;
#X obj 168 199 s \$2-out;
#X obj 100 100 tgl 15 0 \$0-s \$0-r empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj 173 104 s \$0-r;
#X obj 168 143 r \$0-s;
#X connect 0 0 3 0;
#X connect 1 0 5 0;
#X connect 2 0 1 0;
#X connect 6 0 0 0;
#X coords 0 -1 1 1 15 15 2 100 100;


More information about the Pd-list mailing list