Send sysex message with Java

1.5k Views Asked by At

I'd like to send a Sysex message to a MIDI Port. Unfortunately there is no response at all when I send it. Sending regular MIDI messages (ShortMessage) works just fine, but as soon as I replace the ShortMessage with the SysexMessage things stop working.

MidiDevice midiIn = MidiSystem.getMidiDevice(midiDeviceList[NUMBER]);
Receiver rcvr = midiIn.getReceiver
byte[] clearMsg = {(byte) 0xf0, 0x47, 0x7f, 0x15, 0x1e, 0x00, 0x00, (byte) 0xf7 };

SysexMessage sysMsg = new SysexMessage();    
sysMsg.setMessage(clearMsg, clearMsg.length);

rcvr.send(sysMsg, -1);

Why doesn't the port receive the message or why isn't it being sent?

2

There are 2 best solutions below

1
TomTom On

The reason SysEx messages were not sent is because OSX is has a broken MIDI system. It cannot send SysEx messages. MMJ seems to be a library to workaround this problem.

0
Bart Schuller On

A more recent solution is https://github.com/DerekCook/CoreMidi4J which is just another dependency you add which will make Midi on OSX work (and do no harm on other platforms).