// Command line arguments // chuck midi2OSC [midi_device [hostname [port]]] 2 => int MIDI_IN_DEVICE; "localhost" => string HOSTNAME; 6449 => int PORT; if( me.args() ) me.arg(0) => Std.atoi => MIDI_IN_DEVICE; if( me.args() > 1) me.arg(1) => Std.atoi => PORT; // MIDI stuff MidiIn midiIn; MidiMsg midiMsg; if( !midiIn.open( MIDI_IN_DEVICE ) ) { <<< "Couldn't open midi device #", MIDI_IN_DEVICE >>>; me.exit(); } // OSC stuff OscSend xmit; xmit.setHost( HOSTNAME, PORT ); fun void sendMidiOverOSC(int data1, int data2, int data3) { xmit.startMsg( "/midi/message", "i i i" ); data1 => xmit.addInt; data2 => xmit.addInt; data3 => xmit.addInt; } while (true) { midiIn => now; while (midiIn.recv(midiMsg)) { <<< "MIDI: ", midiMsg.data1, midiMsg.data2, midiMsg.data3 >>>; sendMidiOverOSC(midiMsg.data1, midiMsg.data2, midiMsg.data3); } }