#N canvas 584 44 565 521 10;
#X obj 3 336 cnv 3 550 3 empty empty inlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 2 400 cnv 3 550 3 empty empty outlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 2 437 cnv 3 550 3 empty empty arguments 8 12 0 13 #dcdcdc #000000 0;
#X obj 84 410 cnv 17 3 17 empty empty 0 5 9 0 16 #dcdcdc #9c9c9c 0;
#X obj 84 344 cnv 17 3 50 empty empty 0 5 9 0 16 #dcdcdc #9c9c9c 0;
#X msg 230 190 clear;
#X msg 231 211 reset;
#X msg 128 176 1;
#X msg 157 176 2;
#X msg 186 176 3;
#X obj 2 485 cnv 15 552 21 empty empty empty 20 12 0 14 #e0e0e0 #202020 0;
#X text 117 343 float;
#X text 100 446 1) float, f 9;
#X obj 186 266 unpack float float float;
#X text 117 360 clear;
#X text 117 377 reset;
#X text 174 307 previous;
#X text 325 307 occurrence;
#X obj 223 170 nbx 4 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 186 291 nbx 3 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 256 291 nbx 3 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 327 291 nbx 3 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X text 250 307 current;
#X text 123 411 list;
#X text 166 343 - the anal input data, f 60;
#N canvas 748 127 355 307 examples 0;
#X obj 140 79 notein;
#X obj 140 109 stripnote;
#X obj 156 170 bng 19 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X obj 140 146 cyclone/anal;
#X obj 140 198 cyclone/prob;
#C restore;
#N canvas 763 53 569 608 markov_chain 0;
#X obj 330 132 bng 20 250 50 0 empty empty empty 17 7 0 10 #d0d0d0 #404040 #000000;
#X msg 330 324 clear;
#X obj 330 401 cyclone/prob;
#C restore;
#X obj 216 400 unpack f f f, f 13;
#X floatatom 216 422 5 0 0 0 - - - 0;
#X floatatom 253 422 5 0 0 0 - - - 0;
#X floatatom 291 422 3 0 0 0 - - - 0;
#X obj 350 358 bng 25 250 50 0 empty empty empty 17 7 0 10 #d0d0d0 #404040 #000000;
#X obj 399 434 bng 15 250 50 0 empty empty empty 17 7 0 10 #d0d0d0 #404040 #000000;
#X obj 330 460 % 128;
#X obj 330 560 noteout;
#X obj 88 87 nbx 3 14 0 127 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 330 485 nbx 3 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 330 524 makenote 100 500;
#X text 212 35 By default \, [anal] creates a table of transition probabilities from one note to another (1st order Markov chain). This patch shows how we can use it to create transition probabilities from two notes to a third note (2nd order markov chain)., f 50;
#X obj 189 223 t f f;
#X obj 216 291 +;
#X obj 216 316 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 88 26 notein;
#X obj 88 57 stripnote;
#X obj 330 427 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 231 250 * 128;
#X msg 285 324 reset;
#X obj 189 195 cyclone/gate 2;
#X obj 88 138 t f b;
#X obj 231 272 nbx 5 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #dcdcdc #000000 #000000 0 256;
#X obj 216 354 cyclone/anal 16384;
#X msg 189 149 2;
#X msg 232 149 1;
#X obj 133 118 cyclone/onebang 1;
#X text 358 134 <-- restart;
#X text 383 362 <-- BANG;
#X text 93 185 send first number to the right oultet, f 15;
#X text 67 246 store previous note in the high 7-bits of our value, f 19;
#X text 64 294 encode current and previous values into one big number, f 21;
#X text 63 337 max size = 16384 (128*128) because we're shoving 2 MIDI values into 1, f 18;
#X text 61 394 output: transitions from 2-note pairs to other 2-note pairs, f 20;
#X text 169 446 weed out the "previous" note that was stored in the high 7-bits, f 23;
#X text 88 501 Now the playback is comprised of transition probabilities based on the two preceding notes! This should yield results that sound less random than if we're just looking at one note at a time., f 33;
#X connect 0 0 1 0;
#X connect 0 0 22 0;
#X connect 0 0 29 1;
#X connect 1 0 2 0;
#X connect 2 0 20 0;
#X connect 2 1 8 0;
#X connect 3 0 4 0;
#X connect 3 1 5 0;
#X connect 3 2 6 0;
#X connect 7 0 2 0;
#X connect 9 0 12 0;
#X connect 11 0 24 0;
#X connect 12 0 13 0;
#X connect 13 0 10 0;
#X connect 13 1 10 1;
#X connect 15 0 21 0;
#X connect 15 1 16 0;
#X connect 16 0 17 0;
#X connect 17 0 26 0;
#X connect 18 0 19 0;
#X connect 18 1 19 1;
#X connect 19 0 11 0;
#X connect 20 0 9 0;
#X connect 21 0 25 0;
#X connect 22 0 26 0;
#X connect 23 0 15 0;
#X connect 23 1 21 0;
#X connect 24 0 23 1;
#X connect 24 1 29 0;
#X connect 25 0 16 1;
#X connect 26 0 3 0;
#X connect 26 0 2 0;
#X connect 27 0 23 0;
#X connect 28 0 23 0;
#X connect 29 0 27 0;
#X connect 29 1 28 0;
#X restore 94 241 pd markov_chain (2nd order);
#X text 39 26 feed the received two note sequences to [prob] for a 1st order markov-chain, f 39;
#X connect 0 0 1 0;
#X connect 1 0 3 0;
#X connect 2 0 4 0;
#X connect 3 0 4 0;
#X restore 451 290 pd examples;
#X text 81 85 [anal] reports how many times it received a number pair. The output is designed to serve as input to [cyclone/prob] and is composed of: 1) the previously received number \, 2) current input number \, 3) occurrence (how many times this number pair has been received)., f 61;
#X text 166 412 - three floats: <previous number \, current number \, occurrence>;
#X obj 186 236 cyclone/anal 32;
#X text 166 377 - completely erase memory, f 60;
#X text 166 359 - clears analysis but remembers last input, f 60;
#X text 168 446 - Maximum input \, values accepted are between 0 and this;
#X text 180 461 number (default 128 \, max 16384), f 53;
#X text 22 61 Number pairs histogram;
#X obj 4 5 header anal;
#X connect 5 0 28 0;
#X connect 6 0 28 0;
#X connect 7 0 28 0;
#X connect 8 0 28 0;
#X connect 9 0 28 0;
#X connect 13 0 19 0;
#X connect 13 1 20 0;
#X connect 13 2 21 0;
#X connect 18 0 28 0;
#X connect 28 0 13 0;
