#N canvas 584 196 796 628 12;
#X declare -lib iemmatrix;
#X obj 106 327 osc~ 100;
#X obj 106 350 *~ 0.2;
#X obj 145 380 osc~ 1000;
#X obj 145 403 *~ 1.5;
#X obj 182 356 osc~ 432;
#X obj 68 471 env~;
#X floatatom 68 495 4 0 0 0 - - - 0;
#X obj 127 470 env~;
#X floatatom 127 494 4 0 0 0 - - - 0;
#X obj 187 470 env~;
#X floatatom 187 494 4 0 0 0 - - - 0;
#X floatatom 286 402 4 0 0 0 - - - 0;
#X text 332 413 fade time in [ms];
#X msg 48 140 bang;
#X msg 170 140 bang;
#X msg 69 219 bang;
#X msg 190 218 bang;
#X text 174 24 matrix-multiply m IN~signals to n OUT~signals;
#X text 173 41 matrices are interpolated a la line~;
#X text 304 170 matrix-messages to control the gains;
#X text 303 183 of the matrix~;
#X text 334 380 the last inlet gets the fade-time between two matrix-messages.;
#X obj 98 32 mtx_*~;
#X obj 69 431 mtx_*~ 4 3 100 .......;
#X obj 253 471 env~;
#X floatatom 253 495 4 0 0 0 - - - 0;
#X obj 69 301 t a;
#X obj 70 539 mtx_*~;
#X text 147 536 creation: "mtx_*~ [<#out> [<#in> [<fade_time>] [<...>]];
#X text 302 154 the first inlet eats;
#X text 316 314 the 2nd...one-before-last inlets get the signals to be multiplied.;
#X text 328 487 Output signals;
#X text 207 68 OUT~^ = A * IN~^;
#X obj 48 167 mtx_eye 4 3;
#X obj 170 167 mtx_egg 4 3;
#X obj 190 245 mtx_zeros 4 3;
#X obj 69 246 mtx_ones 4 3;
#X msg 699 33 \; pd dsp 1;
#X text 127 96 or \, with dimensions: OUT~^[1*n] = A[n*m] * IN~^[m*1];
#N canvas 34 69 925 425 LEGACY 0;
#X obj 51 160 sig~;
#X floatatom 180 166 5 0 0 0 - - - 0;
#X text 286 127 this object \, accepted the signals at the first inputs \, then the matrix (and finally the fade-time);
#X text 295 163 OUT~^[n] = IN~^[m] * B[m*x];
#X obj 192 307 sig~;
#X msg 97 303 time 100;
#X obj 93 160 sig~;
#X obj 50 188 matrix~ 2 3 100;
#X obj 136 138 mtx 2 3;
#X obj 25 346 matrix_mul_line~ 2 3 100;
#X obj 235 307 sig~;
#X text 288 262 this object \, accepted the signals at the inlets \; all! messages went to the 1st inlet;
#X obj 25 304 mtx 3 2;
#X text 297 298 OUT~^[n] = B[n*m] * IN~^[m];
#X text 288 183 this is a _very_ unusual way to notate signal matrix multiplications;
#X text 290 318 this conforms to the way how signal matrix multiplications is usually notated \, however \, we didn't like that the incoming matrix had different dimensions than the object ([mtx N M] vs [matrix_mul_line~ M N]) \; and the 1st inlet was a bit overloaded.;
#X text 84 18 [mtx_*~] is the successor of 2 similar objects \, which we believe to have had some design flaws:;
#X connect 0 0 7 0;
#X connect 1 0 7 3;
#X connect 4 0 9 0;
#X connect 5 0 9 0;
#X connect 6 0 7 1;
#X connect 8 0 7 2;
#X connect 10 0 9 1;
#X connect 12 0 9 0;
#X restore 65 587 pd LEGACY;
#N canvas 468 154 486 187 META 0;
#X text 12 135 HELP_PATCH_AUTHORS IOhannes m zmölnig;
#X text 12 25 LICENSE GPL-2+;
#X text 11 4 KEYWORDS signal matrix;
#X text 11 43 DESCRIPTION multiply signals with a matrix;
#X text 12 65 INLET_0 matrix;
#X text 12 82 INLET_n signal;
#X text 12 97 OUTLET_m signal;
#X obj 13 160 declare -lib iemmatrix;
#X text 12 116 AUTHOR IOhannes m zmölnig;
#X restore 731 586 pd META;
#N canvas 112 13 1011 803 multichannel 0;
#X text 39 17 With recent versions of Pd (>=0.54) \, you can use multichannel connections.;
#X text 38 56 To do so \, give '0' as the number of rows (outlets) and/or columns (inlets);
#X obj 427 268 mtx_*~ 0 0 100;
#X obj 474 234 snake~ in 2;
#X obj 474 209 sig~ 1;
#X obj 427 318 snapshot~;
#X floatatom 427 343 5 0 0 0 - - - 0;
#X obj 507 318 snapshot~;
#X floatatom 507 343 5 0 0 0 - - - 0;
#X obj 376 298 r .\$0;
#X msg 99 200 eye 2;
#X obj 774 62 tgl 20 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000 0 1;
#X msg 774 87 \; pd dsp \$1;
#X obj 547 209 sig~ 2;
#X obj 99 273 mtx_print;
#X obj 427 293 snake~ out 3;
#X obj 587 318 snapshot~;
#X floatatom 587 343 5 0 0 0 - - - 0;
#X msg 56 126 ones 3 2;
#X text 43 368 With multichannel signals \, the number of input/output channels is variable.;
#X text 37 411 The following limitations apply:;
#X text 61 441 - while the DSP is running \, the number of I/O-channels cannot be changed., f 58;
#X text 62 478 - the number of input channels is dictated by the incoming connection.;
#X text 64 519 - if the number of I/O-channels changes (during a DSP restart) \, the multiplication matrix is resized accordingly;
#X obj 204 745 mtx_*~ 4 0 100;
#X obj 679 715 mtx_*~ 0 4 100;
#X obj 679 740 snake~ out 7;
#X obj 251 721 snake~ in 2;
#X text 90 619 it's possible to select multichannel and/or discrete channels per direction, f 76;
#X text 97 696 multichannel input \, discrete outputs:;
#X text 136 645 the dimension of the matrix must match the discrete channels;
#X msg 91 749 eye 5 7;
#X obj 91 774 mtx;
#X msg 91 725 eye 4 3;
#X text 33 728 good;
#X text 36 750 BAD;
#X obj 601 764 mtx;
#X text 543 718 good;
#X text 546 740 BAD;
#X msg 600 715 eye 3 4;
#X msg 601 739 eye 4 5;
#X text 577 693 discrete inputs \, multichannel output:;
#X text 533 437 (however \, you can turn off the DSP \, send a new NxK matrix and the number of outputs will be N \, once the DSP is started again);
#X text 530 482 (while you can send a NxK matrix \, if you also connect a [snake~ in 7] object to [mtx_*~] \, the number of input channels will be 7 \, regardless of the value of K);
#X obj 56 102 loadbang;
#X text 125 106 initialize before the DSP starts;
#X text 127 127 (here: 3 output and 2 input channels);
#X msg 159 200 egg 3;
#N canvas 905 436 444 359 restart 0;
#X obj 105 54 inlet;
#X obj 105 79 t b a b;
#X obj 128 178 outlet;
#X obj 256 81 r pd-dsp-stopped;
#X obj 223 56 r pd-dsp-started;
#X msg 223 81 1;
#X msg 256 106 0;
#X obj 105 252 select 1;
#X obj 205 191 t f f;
#X obj 237 252 select 1;
#X msg 237 277 0;
#X msg 237 306 \; pd dsp \$1;
#X msg 105 277 1;
#X obj 205 166 i 0;
#X obj 105 222 i;
#X text 78 17 restart the DSP (iff it's already running);
#X obj 223 139 t f f;
#X obj 355 139 metro 50;
#X obj 355 164 s .\$0;
#X text 352 119 snapshot tick;
#X connect 0 0 1 0;
#X connect 1 0 14 0;
#X connect 1 1 2 0;
#X connect 1 2 13 0;
#X connect 3 0 6 0;
#X connect 4 0 5 0;
#X connect 5 0 16 0;
#X connect 6 0 16 0;
#X connect 7 0 12 0;
#X connect 8 0 14 1;
#X connect 8 1 9 0;
#X connect 9 0 10 0;
#X connect 10 0 11 0;
#X connect 12 0 11 0;
#X connect 13 0 8 0;
#X connect 14 0 7 0;
#X connect 16 0 13 1;
#X connect 16 1 17 0;
#X connect 17 0 18 0;
#X restore 262 222 pd restart DSP;
#X msg 262 197 eye 2;
#X msg 322 197 egg 3;
#X obj 99 225 matrix;
#X obj 736 268 mtx_*~ -m 3;
#X text 722 194 force multichannel-mode with the '-m' flag. the optional dimensions are tentative and can change while the DSP is stopped., f 32;
#X obj 737 318 snapshot~;
#X floatatom 737 343 5 0 0 0 - - - 0;
#X obj 817 318 snapshot~;
#X floatatom 817 343 5 0 0 0 - - - 0;
#X obj 737 293 snake~ out 3;
#X obj 897 318 snapshot~;
#X floatatom 897 343 5 0 0 0 - - - 0;
#X obj 99 248 t a a a;
#X connect 2 0 15 0;
#X connect 3 0 2 1;
#X connect 3 0 52 1;
#X connect 4 0 3 0;
#X connect 5 0 6 0;
#X connect 7 0 8 0;
#X connect 9 0 5 0;
#X connect 9 0 7 0;
#X connect 9 0 16 0;
#X connect 9 0 54 0;
#X connect 9 0 59 0;
#X connect 9 0 56 0;
#X connect 10 0 51 0;
#X connect 11 0 12 0;
#X connect 13 0 3 1;
#X connect 15 0 5 0;
#X connect 15 1 7 0;
#X connect 15 2 16 0;
#X connect 16 0 17 0;
#X connect 18 0 51 0;
#X connect 25 0 26 0;
#X connect 27 0 24 1;
#X connect 31 0 32 0;
#X connect 32 0 24 0;
#X connect 33 0 32 0;
#X connect 36 0 25 0;
#X connect 39 0 36 0;
#X connect 40 0 36 0;
#X connect 44 0 18 0;
#X connect 47 0 51 0;
#X connect 48 0 51 0;
#X connect 49 0 48 0;
#X connect 50 0 48 0;
#X connect 51 0 61 0;
#X connect 52 0 58 0;
#X connect 54 0 55 0;
#X connect 56 0 57 0;
#X connect 58 0 54 0;
#X connect 58 1 56 0;
#X connect 58 2 59 0;
#X connect 59 0 60 0;
#X connect 61 0 14 0;
#X connect 61 1 2 0;
#X connect 61 2 52 0;
#X restore 673 264 pd multichannel;
#X text 142 589 <-- DEPRECATED uses;
#X connect 0 0 1 0;
#X connect 1 0 23 1;
#X connect 2 0 3 0;
#X connect 3 0 23 2;
#X connect 4 0 23 3;
#X connect 5 0 6 0;
#X connect 7 0 8 0;
#X connect 9 0 10 0;
#X connect 11 0 23 4;
#X connect 13 0 33 0;
#X connect 14 0 34 0;
#X connect 15 0 36 0;
#X connect 16 0 35 0;
#X connect 23 0 5 0;
#X connect 23 1 7 0;
#X connect 23 2 9 0;
#X connect 23 3 24 0;
#X connect 24 0 25 0;
#X connect 26 0 23 0;
#X connect 33 0 26 0;
#X connect 34 0 26 0;
#X connect 35 0 26 0;
#X connect 36 0 26 0;
