#N canvas 299 382 555 300 10;
#X obj 182 96 inlet;
#X obj 303 96 inlet index;
#X obj 182 126 send;
#X obj 231 96 initbang;
#N canvas 635 253 727 361 guts 0;
#X obj 66 309 sendcanvas 1;
#N canvas 852 153 450 491 cleanup 0;
#X obj 113 166 inlet;
#X obj 113 187 canvasindex 1;
#X obj 201 231 t f b;
#X obj 201 253 until;
#X obj 123 435 canvasdelete;
#X msg 201 351 delete \$1;
#X obj 201 373 outlet;
#X obj 244 184 r \$0-skipobjects;
#X obj 201 286 i 5;
#X obj 244 206 t f f;
#X obj 201 209 - 5;
#X text 15 62 this uses [canvasindex] to get the number of objects
in the grandparent-patch (the first-level patch of [ib_demux]).;
#X text 32 24 cleanup unwanted objects.;
#X text 15 95 \$0-skipobjects is the number (N) of objects that should
be kept (the fixed objects are created first \, so they occupy the
IDs 0..N. everything after N is a dynamically created object which
we want to remove \, so we can create anew).;
#X connect 0 0 1 0;
#X connect 1 1 10 0;
#X connect 2 0 3 0;
#X connect 3 0 8 0;
#X connect 5 0 6 0;
#X connect 7 0 9 0;
#X connect 8 0 5 0;
#X connect 9 0 10 1;
#X connect 9 1 8 1;
#X connect 10 0 2 0;
#X restore 183 241 pd cleanup;
#X msg 164 95 bang;
#N canvas 568 189 677 449 creator 0;
#X obj 63 89 inlet;
#X obj 62 379 outlet;
#X obj 179 231 r \$0-skipobjects;
#X obj 87 280 + 50;
#X obj 142 254 +;
#X obj 142 276 t f f;
#X obj 174 299 + 1;
#X obj 63 111 t f b;
#X obj 63 133 until;
#X obj 63 155 i;
#X obj 63 177 t f f;
#X obj 94 154 + 1;
#X msg 108 135 0;
#X obj 142 231 * 2;
#X obj 62 203 t f f f b;
#X obj 87 258 * 70;
#X msg 62 357 obj \$2 200 r \$5-\$1 \, obj \$2 230 outlet #\$1 \, connect
\$3 0 \$4 0;
#X obj 62 319 pack 0 0 0 0 \$0;
#X text 63 20 this creates N output structures (a [send \$0-#] and
an [outlet] object which are connected).;
#X text 70 50 for connecting them up \, we need to know their patch-IDs
\, which we can calculate if we know the number of (fixed) objects
in the patch (given via \$0-skipobjects);
#X text 274 266 #1: index;
#X text 274 281 #2: x-position;
#X text 274 296 #3: canvas-ID of [send];
#X text 274 311 #4: canvas-ID of [outlet];
#X text 274 326 #5: \$0 (pre-expanded);
#X connect 0 0 7 0;
#X connect 2 0 4 1;
#X connect 3 0 17 1;
#X connect 4 0 5 0;
#X connect 5 0 17 2;
#X connect 5 1 6 0;
#X connect 6 0 17 3;
#X connect 7 0 8 0;
#X connect 7 1 12 0;
#X connect 8 0 9 0;
#X connect 9 0 10 0;
#X connect 10 0 14 0;
#X connect 10 1 11 0;
#X connect 11 0 9 1;
#X connect 12 0 9 1;
#X connect 13 0 4 0;
#X connect 14 0 17 0;
#X connect 14 1 15 0;
#X connect 14 2 13 0;
#X connect 15 0 3 0;
#X connect 16 0 1 0;
#X connect 17 0 16 0;
#X restore 66 244 pd creator;
#X obj 66 141 i \$1;
#X obj 66 207 t f;
#X msg 66 185 2;
#X obj 67 163 moses 1;
#X obj 66 97 inlet;
#X obj 520 209 max 0;
#X obj 520 231 pack 0 \$0;
#X msg 520 253 symbol \$2-\$1;
#X obj 520 275 outlet;
#X obj 520 155 inlet;
#X obj 66 279 t a a;
#X obj 301 190 s \$0-skipobjects;
#X obj 66 119 t b b b b;
#X obj 520 187 i \$2;
#X msg 183 220 bang;
#X msg 301 168 7;
#X text 100 40 [pd cleanup] removes unwanted objects;
#X text 101 57 [pd creator] creates a number of send/outlet pairs and
connects them.;
#X text 59 17 here's the fun part:;
#X connect 1 0 14 0;
#X connect 2 0 16 0;
#X connect 3 0 14 0;
#X connect 4 0 7 0;
#X connect 5 0 3 0;
#X connect 6 0 5 0;
#X connect 7 0 6 0;
#X connect 7 1 5 0;
#X connect 8 0 16 0;
#X connect 9 0 10 0;
#X connect 10 0 11 0;
#X connect 11 0 12 0;
#X connect 13 0 17 0;
#X connect 14 0 0 0;
#X connect 16 0 4 0;
#X connect 16 1 18 0;
#X connect 16 2 19 0;
#X connect 16 3 17 0;
#X connect 17 0 9 0;
#X connect 18 0 1 0;
#X connect 19 0 15 0;
#X restore 231 126 pd guts;
#X text 85 165 vv- below this line \, everything is created dynamically
-vv;
#X text 38 30 [ib_demux] is an abstraction implementation of a demultiplexer
\, it uses [initbang] to create a dynamic number of outlets.;
#X connect 0 0 2 0;
#X connect 1 0 4 1;
#X connect 3 0 4 0;
#X connect 4 0 2 1;
