#N canvas 562 31 635 661 12; #X obj 72 345 choice; #X msg 49 151 print; #X msg 107 217 clear; #X msg 72 184 add 1 0 0 \, add 0 1 0 \, add 0 0 1 \, add 1 1 1 \, add 1 1 0; #X floatatom 172 251 5 0 0 0 - - - 0; #X floatatom 72 378 5 0 0 0 - - - 0; #X obj 147 346 choice 1; #X floatatom 147 378 5 0 0 0 - - - 0; #X obj 23 14 choice; #X text 79 13 - search for a best match to an incoming list; #X text 52 455 You can use this to choose interactively between a number of behaviors depending on their attributes. For example \, you might have stored a number of melodies \, of which some are syncopated \, some chromatic \, some are more than 100 years old \, some are bugle calls \, and some are Christmas carols. You could then ask to find a syncopated bugle call (1 \, 0 \, 0 \, 1 \, 0) and you'll get the thing most closely matching the request., f 76; #X text 52 553 You can use numbers other than 0 and 1 to indicate relative strengths of the attributes \, or even use negative numbers to indicate opposites \, either in the incoming lists or in the stored ones., f 76; #X text 151 216 delete all stored vectors; #X text 457 184 add vectors; #X text 97 151 debugging printout; #X text 341 247 tweak the numbers and hit "bang" to input a list, f 25; #X text 217 346 creation argument to avoid repeated output; #X text 193 377 output is the index of best match \, counting from zero; #X obj 147 251 bng 19 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000; #X obj 147 300 pack float float float; #X obj 147 275 f, f 4; #X floatatom 298 251 5 0 0 0 - - - 0; #X floatatom 222 251 5 0 0 0 - - - 0; #X text 542 13 <= click; #N canvas 694 154 569 239 reference 0; #X obj 8 49 cnv 5 550 5 empty empty INLET: 8 18 0 13 #202020 #000000 0; #X obj 8 128 cnv 2 550 2 empty empty OUTLET: 8 12 0 13 #202020 #000000 0; #X obj 8 167 cnv 2 550 2 empty empty ARGUMENT: 8 12 0 13 #202020 #000000 0; #X obj 7 209 cnv 5 550 5 empty empty empty 8 18 0 13 #202020 #000000 0; #X obj 33 14 choice; #X text 89 13 - search for a best match to an incoming list; #X text 100 62 print - post debugging information in the print out window., f 61; #X text 65 82 add - add vectors into the objects., f 66; #X text 100 102 clear - delete all stored vectors., f 61; #X text 100 137 float - index of best match (from zero).; #X text 116 178 1) float - non zero avoids repeated output (default 0).; #X restore 448 14 pd reference; #X obj 5 47 cnv 1 620 1 empty empty empty 8 12 0 13 #000000 #000000 0; #X obj 4 616 cnv 1 620 1 empty empty empty 8 12 0 13 #000000 #000000 0; #X text 52 60 The [choice] object holds a list of vectors \, each having up to ten elements. When sent a list of numbers \, it outputs the index of the known vector that matches most closely. The quality of the match is the dot product of the two vectors after normalizing them \, i.e. \, the vector whose direction is closest to that of the input wins., f 76; #X text 52 416 If given a nonzero creation argument \, [choice] tries to avoid repetitious outputs by weighting less recently output vectors preferentially., f 76; #X text 416 629 updated for Pd version 0.3; #X connect 0 0 5 0; #X connect 1 0 0 0; #X connect 2 0 0 0; #X connect 2 0 6 0; #X connect 3 0 0 0; #X connect 3 0 6 0; #X connect 4 0 20 1; #X connect 6 0 7 0; #X connect 18 0 20 0; #X connect 19 0 0 0; #X connect 19 0 6 0; #X connect 20 0 19 0; #X connect 21 0 19 2; #X connect 22 0 19 1;