#N canvas 265 41 787 709 12;
#X declare -stdpath ./;
#X floatatom 226 250 5 57 83 0 - - - 0;
#X obj 226 290 t b f, f 9;
#X obj 226 316 f;
#X msg 404 334 next \$1;
#X msg 412 383 this \$1;
#X msg 419 431 set \$1;
#X msg 432 479 all \$1;
#X text 467 308 "next" forwards a message to the next instance (incrementing and repeating circularly)., f 37;
#X text 475 363 "this" forwards a message to the previous instance sent to by "this" or "next", f 42;
#X obj 226 548 output~;
#X obj 30 8 clone;
#X obj 226 378 pack f f;
#X listbox 226 406 5 0 0 0 - - - 0;
#X obj 40 572 declare -stdpath ./;
#X obj 6 37 cnv 1 775 1 empty empty empty 8 12 0 13 #000000 #000000 0;
#X obj 6 668 cnv 1 775 1 empty empty empty 8 12 0 13 #000000 #000000 0;
#X obj 255 316 + 1;
#N canvas 696 57 567 608 reference 0;
#X obj 8 43 cnv 5 550 5 empty empty INLETS: 8 18 0 13 #202020 #000000 0;
#X obj 8 76 cnv 1 550 1 empty empty 'n': 8 12 0 13 #9f9f9f #000000 0;
#X obj 8 299 cnv 2 550 2 empty empty OUTLETS: 8 12 0 13 #202020 #000000 0;
#X obj 7 586 cnv 5 550 5 empty empty empty 8 18 0 13 #202020 #000000 0;
#X obj 28 13 clone;
#X obj 8 393 cnv 2 550 2 empty empty ARGUMENTS: 8 12 0 13 #202020 #000000 0;
#X obj 7 418 cnv 1 550 1 empty empty flags: 8 12 0 13 #7c7c7c #000000 0;
#X text 104 84 list -;
#X text 55 189 next <list> -;
#X text 55 223 this <list> -;
#X text 62 255 set <list> - sets the "next"/"this" counter., f 67;
#X text 28 443 "-s <float>" - sets starting voice number (default 0)., f 70;
#X text 84 426 "-x" - avoids including a first argument setting voice number., f 62;
#X text 113 524 1) symbol - abstraction name., f 49;
#X text 113 542 2) float - number of copies., f 49;
#X obj 7 519 cnv 1 550 1 empty empty args: 8 12 0 13 #7c7c7c #000000 0;
#X text 113 560 3) list - optional arguments to the abstraction., f 49;
#X text 153 85 first number sets the copy number and the rest of the list is sent to that instance's inlet., f 54;
#X text 153 188 forwards a message to the next instance's inlet (incrementing and repeating circularly)., f 54;
#X text 153 223 forwards a message to the previous instance's inlet sent to by "this" or "next"., f 54;
#X text 62 273 all <list> - sends a message to all instances' inlet., f 67;
#X text 79 52 (number and type depends on the abstraction);
#X text 90 116 signal -;
#X text 153 117 for signal inlets \, audio is sent to all copies., f 54;
#X text 75 13 - make multiple copies of an abstraction.;
#X obj 8 329 cnv 1 550 1 empty empty 'n': 8 12 0 13 #9f9f9f #000000 0;
#X text 62 154 vis <list> -;
#X text 153 155 opens a copy \, takes copy number and visualization status (1 to open \, 0 to close)., f 54;
#X text 34 136 resize <float> -;
#X text 153 137 resizes the number of copies., f 54;
#X text 61 335 control outlets - message with a prepended copy number., f 68;
#X text 68 353 signal outlets -, f 16;
#X text 187 353 either a multichannel output with signals from all copies or the sum of all copies as a mono output., f 50;
#X text 91 460 -di - distribute multichannel input signals across cloned patches., f 66;
#X text 91 475 -do - combine signal outputs to make a multichannel signal.;
#X text 98 491 -d - set both -di and -do flags.;
#X text 84 304 (number and type depends on the abstraction);
#X restore 592 8 pd reference;
#X text 685 8 <= click;
#X text 271 245 A list beginning with a number dispatches the rest of the list as a message to a copy of the abstraction defined by the first number., f 69;
#X text 94 519 click to open --> (first copy only), f 17;
#X text 78 9 - make multiple copies of an abstraction;
#X text 15 678 see also:;
#X obj 87 679 inlet;
#X obj 135 679 snake~;
#X text 468 576 mutichannel signal support ----------->, f 20;
#X floatatom 419 409 5 0 3 0 - - - 0;
#N canvas 452 86 828 543 multichannel 0;
#X obj 361 338 output~;
#X obj 361 296 snake~ out;
#X msg 361 221 next \$1;
#X floatatom 361 189 5 57 83 0 - - - 0;
#X text 583 46 The '-d' flag sets both -di and -do flags \, so it takes and generates multichannel signals., f 27;
#X obj 95 340 output~;
#X obj 95 256 snake~ in;
#X obj 95 217 osc~ 444;
#X obj 167 217 osc~ 666;
#X floatatom 95 189 5 0 0 0 - - - 0;
#X floatatom 167 189 5 0 0 0 - - - 0;
#X obj 361 258 clone -do clone-abs-a 2;
#X obj 95 298 clone -di clone-abs-b 2;
#X text 54 118 The '-di' flag distributes a multichannel signal to different copies inside [clone]., f 32;
#X obj 615 203 snake~ in;
#X obj 615 164 osc~ 444;
#X obj 687 164 osc~ 666;
#X floatatom 615 136 5 0 0 0 - - - 0;
#X floatatom 687 136 5 0 0 0 - - - 0;
#X obj 615 335 output~;
#X obj 615 293 snake~ out;
#X obj 615 245 clone -d clone-abs-b 2;
#X text 322 118 The '-do' flag combines the audio of all copies into a multichannel signal output., f 27;
#X text 46 20 By default \, for signal inlets \, [clone] expects a single mono channel and distributes it to all copies of the abstraction. If you have a multichannel input you need to use a flag to split and distribute the channels separately to each copy. By default \, an outlet connection gets the sum of all copies \, but you can also get a multichannel output that combines the output of all copies with a flag., f 70;
#X text 73 440 When distributing a mutichannel input into copies \, if the number of channels is less than the number of copies \, [clone] will wrap around and copy the first channels until reaching the number of copies. This is specially useful if you have like an actual multichannel input in the leftmost inlet and other secondary signal inlets that just receive a single channel signal \, in which case the single channels are sent to all copies., f 97;
#X connect 1 0 0 0;
#X connect 1 1 0 1;
#X connect 2 0 11 0;
#X connect 3 0 2 0;
#X connect 6 0 12 0;
#X connect 7 0 6 0;
#X connect 8 0 6 1;
#X connect 9 0 7 0;
#X connect 10 0 8 0;
#X connect 11 0 1 0;
#X connect 12 0 5 0;
#X connect 14 0 21 0;
#X connect 15 0 14 0;
#X connect 16 0 14 1;
#X connect 17 0 15 0;
#X connect 18 0 16 0;
#X connect 20 0 19 0;
#X connect 20 1 19 1;
#X connect 21 0 20 0;
#X restore 619 591 pd multichannel;
#X obj 226 352 mod 4;
#X msg 47 462 vis 2 0;
#X msg 111 463 vis 2 1;
#X floatatom 432 457 4 57 83 0 - - - 0;
#X floatatom 412 361 5 0 3 0 - - - 0;
#X floatatom 404 312 5 0 3 0 - - - 0;
#X text 370 518 <-- file name and number of copies;
#X obj 226 518 clone clone-abs-a 4;
#X floatatom 320 289 5 0 0 0 - - - 0;
#X msg 320 329 resize \$1;
#X text 475 408 "set" sets the "next" and "this" counter, f 15;
#X text 489 457 "all" sends a message to all instances, f 13;
#X text 367 286 <-- resize the number of instances;
#X text 24 46 [clone] creates any number of copies of an abstraction (a patch loaded as an object in another patch). By default "\$1" is set to the instance number within each copy (counted from 0 unless overridden by the "-s" flag). You can prevent '\$1' from reflecting the instance number with the "-x" flag. Arguments must be filename and number of copies \, additional arguments are passed to the copies and appear as \$2 and onward (or \$1 and onward with the "-x" flag)., f 104;
#X listbox 356 546 7 0 0 0 - - - 0;
#X text 413 546 control data is preceded by instance number;
#X obj 193 679 poly;
#X text 80 623 Note: for backwards compatibility \, you can also invoke this as "clone 16 clone-abstraction" (for instance) \, swapping the abstraction name and the number of voices., f 91;
#X text 57 424 Open or close copy number 2:, f 14;
#X floatatom 172 365 5 0 3 0 - - - 0;
#X text 26 347 Just a float sends an empty list to the instance \, which becomes a bang!, f 19;
#X text 23 121 [clone]'s inlets/outlets correspond to those of the contained patch and may be control and/or signal inlets/outlets. This example has one control inlet. It also has a signal and another control outlet. You can click on the [clone] object to see the first of the cloned instances. At least one control inlet is present even if the abstraction has none \, so [clone] can receive the 'vis' and 'resize' messages. The way control inlets/outlets forward messages is shown below., f 104;
#X text 23 197 Signal inlets can get non float control messages via their 2nd outlet in the same way \, but signals are sent to all the instances. See [pd multichannel] example for more details on how signal distribution works in [clone]., f 104;
#X obj 236 678 notein;
#X text 22 261 Check [poly]'s help for a polyphonic synth example with [clone] and a list input, f 22;
#X obj 147 311 poly;
#X text 626 419 Example on how to use [clone] with [savestate], f 17;
#N canvas 689 137 421 453 savestate 0;
#X obj 131 244 clone clone-abs-d 4;
#A set 0;
#A saved 0;
#A set 1;
#A saved 0;
#A set 2;
#A saved 0;
#A set 3;
#A saved 0;
#A set 3;
#X msg 131 173 0 0 \, 1 10 \, 2 20 \, 3 30;
#X obj 154 312 bng 19 250 50 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000;
#X obj 131 347 snapshot~;
#X floatatom 131 382 5 0 0 0 - - - 0;
#X obj 154 281 loadbang;
#X msg 149 207 0 0 \, 1 11 \, 2 22 \, 3 33;
#X text 79 45 When using a [savestate] object inside the abstraction \, each copy saves its own state separately. In this example we set values for all instances and they get saved. The output is then the sum of all values (60 or 66)., f 38;
#X msg 268 346 \; pd dsp \$1;
#X obj 268 311 set-dsp-tgl;
#X text 267 287 DSP on/off;
#X connect 0 0 3 0;
#X connect 1 0 0 0;
#X connect 2 0 3 0;
#X connect 3 0 4 0;
#X connect 5 0 2 0;
#X connect 6 0 0 0;
#X connect 9 0 8 0;
#X restore 650 473 pd savestate;
#X text 555 677 updated for Pd version 0.56-0;
#X obj 293 678 savestate;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 1 1 11 1;
#X connect 2 0 28 0;
#X connect 3 0 35 0;
#X connect 4 0 35 0;
#X connect 5 0 35 0;
#X connect 6 0 35 0;
#X connect 11 0 12 0;
#X connect 12 0 35 0;
#X connect 16 0 2 1;
#X connect 26 0 5 0;
#X connect 28 0 11 0;
#X connect 28 0 16 0;
#X connect 29 0 35 0;
#X connect 30 0 35 0;
#X connect 31 0 6 0;
#X connect 32 0 4 0;
#X connect 33 0 3 0;
#X connect 35 0 9 0;
#X connect 35 1 42 0;
#X connect 36 0 37 0;
#X connect 36 0 28 1;
#X connect 37 0 35 0;
#X connect 47 0 35 0;
