Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Sat May 16, 2009 12:05 am Post subject:
|
|
|
What immediately comes to me is routing it over the local network. I think writing a ChucK program that does this wouldn't be very hard - if you want I can give it a go (if no one else beats me to it ).
Googling for MIDI over LAN or MIDI of network gives some hits as well, you might want to check those out. I'm not aware of any application that does PC to PC communication over USB, but I may just not be informed well enough.
/Stefan _________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|
Antimon
Joined: Jan 18, 2005 Posts: 4145 Location: Sweden
Audio files: 371
G2 patch files: 100
|
Posted: Sat May 16, 2009 3:27 am Post subject:
|
|
|
[color=brown]Edit: Grr, I edited to attach files and it activated htm and smilies and made a mess of my code. If you read this five minutes ago and was confused, please read again.[/color]
OK, I felt like trying this out. It works, kind of. I realize that a ChucK solution maybe isn't what you're after - maybe there is something else out there on the net.
You need some kind of virtual midi device, like Midi Yoke, to route to and from. Sometimes DAWs offer these virtual midi devices as part of them, if you got one of those you should try that because I think midi yoke introduced some kind of weird lag in my tests (they emphasise on the homepage that Midi Yoke isn't really supported for Windows NT/2000/XP etc).
You need to also install ChucK. If you don't feel comfortable with command lines, use MiniAudicle. To find out which device to use (a midi yoke or other virtual device), run probe ("chuck --probe" on the command line).
This runs on the computer you want to send midi from, let's call it the client:
Code: | // 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) => HOSTNAME;
if( me.args() > 2) me.arg(2) => 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);
}
}
|
This accepts arguments (though I don't know how to do args on the command line). The first arg is the midi device (a virtual one, like midi yoke), the second is the hostname you want to ssend midi to, the last is the port.
This runs on the computer you want to receive midi events, let's call it the server.
Code: | // 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_IN_DEVICE;
if( me.args() > 1) me.arg(1) => 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);
}
}
|
Again, this accepts arguments. The first argument is the midi device that is to receive the midi events sent from the client (a virtual device again, midi yoke or other), the second is the port (which should be equal to the port specified for the client). If you get some error like "port not available" or "could not open network connection", try changing the ports to some other number.
I am attaching these two pieces of source code as files, that you can save and run.
If this turns out to be usable, please say how it worked out. :)
Edit: forgot the attachements.
/Stefan
Description: |
|
Download |
Filename: |
midi2OSC.ck |
Filesize: |
904 Bytes |
Downloaded: |
597 Time(s) |
Description: |
|
Download |
Filename: |
osc2midi.ck |
Filesize: |
1.02 KB |
Downloaded: |
603 Time(s) |
_________________ Antimon's Window
@soundcloud @Flattr home - you can't explain music |
|