by davem » Thu Sep 17, 2009 10:41 pm
Hi Ken,
Sysex calls - or anything else to do with Java for that matter - on a standard installation will not work because Apple doesn't provide a Java wrapper for CoreMIDI anymore - I believe they stopped at 10.4.something. Literally without an external library you cannot even see the MegaDrum from Java. Up until this point I've been using mmj which has worked great, but since that no longer works on Snow Leopard I've written my own wrapper. The other library elrules linked I found just doesn't work with MCT in terms of Sysex messages.
I am pleased to report that after two days of reasonably hard coding, I have something to show for my efforts. Now, I am at the point where I can get MCT to reliably send and receive Sysex messages to/from MD. Standard MIDI messages are also transmitted without issue. As far as I can tell, it works great for short periods, long periods are completely untested. And the interface is hugely inefficient and needs quite a bit of work, plus there are a couple of glaring memory leaks that need patching up. But just bear in mind here that
(a) I have never used the JNI to code stuff natively and link it up to Java.
(b) I have never used CoreMIDI, or in fact coded pretty much anything vaguely related to MIDI applications before.
(c) I only really have a cursory knowledge of Cocoa and multi-threaded programming. In fact my Java isn't really that great.
(d) There is virtually no documentation or sample code on any of this (very irritating!)
(e) I only worked on this two days.
and I have something that works. Surely it wouldn't be beyond the realms of possibility that Apple could have given someone with far more experience and capability in this than me a week to do this properly?
Basically I have some fairly minimal Java code which implements the MidiDeviceProvider SPI in Java. Coupled with this is a native library which queries CoreMIDI for device information, and also sets up receivers and transmitters to input/output ports. When data becomes available, the native routines call the associated Java calls and that's about it.
Anyway, I don't plan on releasing source just yet unless people are desperate because of all the aforementioned reasons, but if people would like to test it on various architectures that would be good. In theory, given the source I can get this working with minimal effort on PPC, i386, x86_64 etc for Java 1.5 or 1.6 either 32- or 64-bit. I actually have nothing but Snow Leopard to test it on anymore here. I would also appreciate any help and comments people have!