#N canvas 311 204 782 431 10;
#X obj 195 55 keyname;
#X obj 195 127 route \$1;
#X obj 274 287 f \$2;
#X obj 58 357 outlet;
#X text 292 68 swap output of [keyname] to be a list: <keyname> <state>
;
#X obj 195 106 list trim;
#X text 294 102 trim the "list" selector;
#X obj 58 61 inlet;
#X text 28 34 pass-through trick to make connecting easier;
#X obj 274 309 mtof;
#X text 38 386 list <freq> <0|1>;
#X obj 195 78 list prepend;
#X obj 274 267 loadbang;
#X obj 195 332 list prepend;
#X text 308 322 prepend the desired frequency from a midi note passed
as argument 2;
#X text 294 118 wait for the key passed as first argument. Output after
this stage is: 1 (down) or 0 (up) for the selected keyname.;
#X obj 195 156 moses 1;
#X msg 195 231 0;
#X msg 232 185 stop;
#X obj 195 186 b;
#X obj 195 251 change;
#X obj 195 210 delay 50;
#X text 296 203 add latency to release events which are stopped again
when a trigger event comes. the delay used here depends on your keyboard
repeat rate \, 50 ms works for me;
#X connect 0 0 11 0;
#X connect 0 1 11 1;
#X connect 1 0 16 0;
#X connect 2 0 9 0;
#X connect 5 0 1 0;
#X connect 7 0 3 0;
#X connect 9 0 13 1;
#X connect 11 0 5 0;
#X connect 12 0 2 0;
#X connect 13 0 3 0;
#X connect 16 0 19 0;
#X connect 16 1 18 0;
#X connect 16 1 20 0;
#X connect 17 0 20 0;
#X connect 18 0 21 0;
#X connect 19 0 21 0;
#X connect 20 0 13 0;
#X connect 21 0 17 0;
