Debian Codegraph @

examples/midi/gomidi.ck

raw
1 // number of the device to open (see: chuck --probe)
2 0 => int device;
3 // get command line
4 if( me.args() ) me.arg(0) => Std.atoi => device;
5
6 // the midi event
7 MidiIn min;
8 // the message for retrieving data
9 MidiMsg msg;
10
11 // open the device
12 if( !min.open( device ) ) me.exit();
13
14 // print out device that was opened
15 <<< "MIDI device:", min.num(), " -> ", min.name() >>>;
16
17 // infinite time-loop
18 while( true )
19 {
20 // wait on the event 'min'
21 min => now;
22
23 // get the message(s)
24 while( min.recv(msg) )
25 {
26 // print out midi message
27 <<< msg.data1, msg.data2, msg.data3 >>>;
28 }
29 }