Difference between revisions of "Poly demo.ck"
From CSWiki
Line 7: | Line 7: | ||
// open midi receiver, exit on fail | // open midi receiver, exit on fail | ||
// need to set this argument depending on your MIDI config | // need to set this argument depending on your MIDI config | ||
− | // try chuck --probe in the Terminal to see what MIDI devices are present | + | // try "chuck --probe" in the Terminal to see what MIDI devices are present |
if ( !min.open(1) ) me.exit(); | if ( !min.open(1) ) me.exit(); | ||
Revision as of 12:49, 26 February 2008
MidiIn min; MidiMsg msg; Event noteoffs[127]; // open midi receiver, exit on fail // need to set this argument depending on your MIDI config // try "chuck --probe" in the Terminal to see what MIDI devices are present 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; //think about how to make this better with an envelope or ADSR }