Everyone who worked with Java and MIDI was having problems when it comes to MIDI support on Mac OS X. It is simply not supported. So we were running into the same issue. Luckily Java has two nice features. The first is called Service Provider Interface (SPI) which allows you to create your own provider of MIDI devices for instance. The second feature is called Java Native Interface (JNI) which allows you to execute platform specific code.
Now I do not really know why there is no MIDI support on the Mac because the implementation is fairly simple. OS X comes with a lot of easy-to-use system libraries. One of those libraries is CoreMIDI. Now the only thing you have to do is wire everything together. Use SPI to talk over JNI with CoreMIDI and you are set.
I am not a Java programmer and not a Mac user at all. But I think I learned some common things during the last days.
- Synergy is awesome. A good friend told me about it half a year ago and now I finally tried it. One mouse and keyboard to control four screens which are connected to my Laptop and Macbook is pure luxury — but for free! Synergy is open-source and absolutely superior to a VNC solution.
- JNI is not hard to handle. It was not my first time using it but when it comes to threading you have to keep in mind that references to Java objects have to be marked global and everything from the call to your JNI method becomes invalid. Keeping a reference to the JVM and attaching the thread to it works very well.
- The Ant Jar task has a bug. Defining a service using the <service/> tag does not work because the folder in the jar will be named “service” and not “services“.
I am definitly not an expert when it comes to this kind of stuff but I had my problems especially with the Ant bug and calling a Java method from a different thread. The result is very nice on the one hand because it works for all kinds of MIDI messages now but on the other hand I still have to ask myself why nobody included this feature for the OS X Java VM in the first place.
The good news is that we will have a very robust MIDI implementation which will work crossplatform without the need to install any additional libraries.




