Poly demo.ck
From CSWiki
MidiIn min; MidiMsg msg; Event noteoffs[127]; // open midi receiver, exit on fail if ( !min.open(1) ) me.exit(); while( true ) { // wait on midi event min => now; // receive midimsg(s) while( min.recv( msg ) ) { // print content <<< msg.data1, msg.data2, msg.data3 >>>; if(msg.data3 > 0) spork ~ mand_note(Std.mtof(msg.data2), msg.data3/127., noteoffs[msg.data2]); else noteoffs[msg.data2].signal(); } } fun void mand_note(float freq, float amplitude, Event mynoteoff) { Mandolin mand => dac; mand.freq(freq); mand.pluck(amplitude); mynoteoff => now; mand =< dac; }