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.
Share This
Last night I spent about 9 hours writing a build script for the AudioTool allowing us to compile each plugin into its own SWF container. I think it is the first time a Flash project is taking more than 5 minutes for me to compile completly.
I figured out that it is definitly not easy to handle the mxmlc or compc in a way we needed it to be. The point is that we have for each plugin three modules A, B, C and a library D. A depends on D. B depends on A and D. C depends on A, B and D. Now to make it even more complex we have A, B, C and D in one project so that developing in this environment stays still simple. The solution to compile all modules in a way we need them to be was first generating unique entry points for the SWF files because we do not want to work with SWC libraries (or the SWF inside the SWC package). After having the unique entry points we compile D (and its dependencies as well) without including the source of A, B or C. Afterwards we can compile A. But B is dependent on A so we have to compile a SWF for A and then a SWC for A so B can link to A as an external library. C is also analog to this but needs B as a library as well. In the end it was 5am and I was happy to have the complete build working which generates a lot of SWF files and SWC libraries.
Since it is very hard to configure Ant for this (I was using XSL in the beginning for automated code generation) I started developing my own Ant tasks. I have to say that it is really simple and saved us hours of work. We have now one single XML file containing the dependencies and the Ant task will do the rest (code generation, compile tasks, etc.).
Share This
This evening Kai-Philipp and me were playing around with the Hobnox Audiotool to test some of the upcomming Midi features.
In the middle of the performance we lost the connection to the little cubes and had to restart the Midi bridge between Flash and the devices. It is still in an early stage but a whole load of fun.
The little cubes were provided by our colleague Oliver who is currently reviewing them. They are comming from percussa.com and are able to send CC values based on their orientation.
Share This
FlashHunter is a neat Eclipse plug-in I wrote that allows you to kill all running Flash player instances with a single click. Two days ago I was implementing the fast Fourier transformation in Flash and I had a stupid error that caused an endless loop. Since I am testing with the standalone player the only way to get rid of it was Ctrl+Alt+Del and killing it. This is not really a nice workflow so I wrote the plug-in.
I am not a Java developer and definitly not an Eclpise platform developer so the plugin itself is very basic. I experimented a little bit with JNI and wrote most of the plugin in C++ because it still is my language of choice.
The plugin is Windows only. I think you could also do something like that as an external tool for OS X (”killall Flash\ Player”).
Share This