I recently dug up an old MIDI sustain extern that I wrote, which takes packed MIDI note/velocity pairs, and outputs the same, while treating them with sustain according to received MIDI sustain controller messages.
I'm attaching this extern, in the hopes that someone can show that the way I implemented it was much verbose than need be. There must be an easier way! Along these lines, shouldn't such an extern be in the core PD distribution? After all, it would seem to be a very common need for anyone using MIDI input to drive audio processes.
Larry
#N canvas 0 0 618 492 10; #X obj 18 49 ctlin; #X obj 20 92 pack f f; #X msg 24 133 $2 $1; #X obj 24 167 route 64; #X obj 26 206 !=; #X floatatom 62 193 4 0 0; #X obj 185 98 pack f f; #X obj 31 244 moses 1; #X obj 204 166 demux 0 1; #X obj 215 69 t f f; #X obj 271 93 !=; #X floatatom 302 75 4 0 0; #X obj 183 260 demux 0 1; #X obj 233 358 bag; #X msg 233 313 $1 1; #X msg 133 317 flush; #X msg 249 414 $1 0; #X obj 453 370 outlet; #X obj 101 17 inlet; #X obj 105 40 unpack f f; #X connect 0 0 1 0; #X connect 0 1 1 1; #X connect 1 0 2 0; #X connect 2 0 3 0; #X connect 3 0 4 0; #X connect 4 0 7 0; #X connect 4 0 12 1; #X connect 5 0 4 1; #X connect 6 0 8 0; #X connect 7 0 15 0; #X connect 8 0 12 0; #X connect 8 1 17 0; #X connect 9 0 6 1; #X connect 9 1 10 0; #X connect 10 0 8 1; #X connect 11 0 10 1; #X connect 12 0 17 0; #X connect 12 1 14 0; #X connect 13 0 16 0; #X connect 14 0 13 0; #X connect 15 0 13 0; #X connect 16 0 17 0; #X connect 18 0 19 0; #X connect 19 0 6 0; #X connect 19 1 9 0;