// Command line arguments // chuck osc2midi [midi_device [hostname [port]]] 0 => int MIDI_OUT_DEVICE; "localhost" => string HOSTNAME; 6449 => int PORT; if( me.args() ) me.arg(0) => Std.atoi => MIDI_OUT_DEVICE; if( me.args() > 1) me.arg(1) => HOSTNAME; if( me.args() > 2) me.arg(2) => Std.atoi => PORT; // MIDI stuff MidiOut midiOut; MidiMsg midiMsg; if (!midiOut.open(MIDI_OUT_DEVICE)) { <<< "Couldn't open midi device #", MIDI_OUT_DEVICE >>>; me.exit(); } fun void sendMidi(int data1, int data2, int data3) { data1 => midiMsg.data1; data2 => midiMsg.data2; data3 => midiMsg.data3; midiOut.send(midiMsg); } // OSC stuff OscRecv oscRecv; PORT => oscRecv.port; oscRecv.listen(); oscRecv.event("/midi/message i i i") @=> OscEvent oscEvent; while (true) { oscEvent => now; while (oscEvent.nextMsg() != 0) { oscEvent.getInt() => int data1; oscEvent.getInt() => int data2; oscEvent.getInt() => int data3; <<< "Got event: ", data1, data2, data3>>>; sendMidi(data1, data2, data3); } }