Skip to content

Getting ProMIDI to work in Processing on OS X Leopard

2009 April 22
by Tedb0t

There is a commonly used MIDI library for Processing called ProMIDI.  They don’t seem to document this on their site (their documentation is terrible in general), but it will not work out-of-the-box on Leopard, due to Apple not supporting a certain Java MIDI class after 10.4.8.  Luckily some folks stepped in and made MMJ, a Java MIDI subsystem.  Read on for all the details.

From their site:

As of Mac OS X version 10.4.8 Apple do no longer support the com.apple.audio.midi java package, which on previous OS X versions allowed java applications to easily access the CoreMIDI system. mmj steps into that hole by providing a universal binary JNI wrapper to CoreMIDI, that is deployable accross system versions and processor architectures. If you need to work with Midi from java on both PowerPC and Intel Macs with all Java runtimes >= 1.4, this is what you need.

Here’s what you do:

  1. Download the library here.
  2. Look for /Library/Java/Extensions on your harddisk.  If the path doesn’t exist, go ahead and make it.
  3. Copy libmmj.jnilib and mmj.jar from the zip file to that extensions path.
  4. If you want to send or receive MIDI from within your computer, you’ll need a software bus.  On OS X Leopard (not sure if this is on previous versions?), this is REALLY easy, and instructions follow.  On Windows I think you have to use MidiOx/Yoke or something similar.
    1. Open the Audio/MIDI Setup program in /Applications/Utilities.
    2. Double click on the red IAC Driver button.
    3. Check “Device is online.”
    4. Click “Apply” if possible, on mine it is grayed out but it doesn’t seem to matter.
  5. Now when you run your midiIO.printDevices(); command you will see:

input 0 : IAC Driver - Bus 1
output 0 : IAC Driver - Bus 1

…or whatever you named the bus (that is the default), and usually the “Java Sound Synthesizer” as well.  Bingo!  Now you just set your other program (like Ableton Live, etc.) to use that same bus and you can start to send MIDI back and forth.  Enjoy!

Related Posts:


7 Responses
  1. chrispix permalink
    July 23, 2009

    I’m not sure this method works anymore. According to the June 17, 2009 post from corporeal on http://processing.org/discourse/yabb2/YaBB.pl?num=1188575049/15 the mmj files don’t work with the current java versions on OS X.

    When I tried the above, I get the following error, which seems to support that:

    Uncaught exception in main method: java.lang.UnsatisfiedLinkError: /Library/Java/Extensions/libmmj.jnilib: no suitable image found. Did find: /Library/Java/Extensions/libmmj.jnilib: no matching architecture in universal wrapper

  2. July 23, 2009

    Hm, what current Java versions do you mean? I just recompiled my test using J2SE 5.0 with the 2006 ProMIDI lib on OS X 10.5.7 with the old MMJ files as of this original posting and it worked normally. I haven’t tried with any newer MMJ files.

  3. GiantRobot permalink
    August 15, 2009

    Looks like the ProMIDI lib site is down, could you post your copy of the lib?

    I’m dumbfounded about osx’s core midi not natively working with Java. I’ve written tons of midi i/o code in java on windows over the last 2 years. I just got my first macbook pro and tonight started porting my code over. Guess I’ll go to bed early.

    I’m getting the same error message as chrispix. I assume its the lack of ProMIDI.

  4. GiantRobot permalink
    August 15, 2009

    Nevermind, a little more looking revealed the new site.

    http://creativecomputing.cc/p5libs/promidi/

  5. xiaosquared permalink
    October 30, 2009

    Thanks for the post. It worked perfectly, and I got ProMIDI to print out the devices that I need.

    However, I tried running some code to print out the IO lines directly in Java using JavaSound’s MIDI capabilities, and it gave me the same error that chrispix got:

    Exception in thread “main” java.lang.UnsatisfiedLinkError: /Users/xx/Library/Java/Extensions/libmmj.jnilib: no suitable image found. Did find: /Users/xx/Library/Java/Extensions/libmmj.jnilib: no matching architecture in universal wrapper
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1878)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1771)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1045)
    at de.humatic.mmj.MidiSystem.loadLibrary(MidiSystem.java:79)
    at de.humatic.mmj.MidiSystem.getDevices(MidiSystem.java:287)
    at de.humatic.mmj.spi.CoreMidiProvider.getDeviceInfo(CoreMidiProvider.java:37)
    at javax.sound.midi.MidiSystem.getMidiDeviceInfo(MidiSystem.java:173)
    at test.MidiTest.main(MidiTest.java:17)

    Since Processing is based on Java, I assumed that your fix would work in Java as well. Do you have any idea why this is? Any thoughts on how to fix it? Thanks in advance.

    Here’s the Java code snippet:
    MidiDevice device = null;
    MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
    for (int i = 0; i < infos.length; i++) {
    try {
    device = MidiSystem.getMidiDevice(infos[i]);
    } catch (MidiUnavailableException e) {
    System.out.println("Midi Unavailable");
    }
    finally {
    System.out.println(infos[i]);
    }
    }

  6. tiia permalink
    March 10, 2010

    Hello,
    I’ve been trying to get ProMidi to run on my OS 10.5 MacBook for a while now. Nothing seems to work! i followed yr above instructions, and found that those mmj files were already in the specified folder. i proceeded anyways, then checked my audio midi setup, and confirmed the device was online. Yet when i restart Processing, and try to run *any* ProMIDI scripts, i find that i get the same error as always:(
    Example:

    Exception in thread “Animation Thread” java.lang.NoClassDefFoundError: processing/core/PApplet
    at promidi.MidiIO.(MidiIO.java:100)

    Please could someone help me out? its seriously getting to me, so it would be seriously appreciated!

    thanks a million :)

  7. April 20, 2010

    I would just like to comment for anybody considering the use of proMIDI other than for very simple prototyping is a big no no. proMIDI uses its own implementation of the Java realtime sequencer which tends to crash if left running for any longer than 10 minutes. I wasted 4 – 5 months trying to fix several parts of their sequencer to successfully make my step sequencer work. It still suffered from unstable timing and would crash after 10 minutes.

    Conclusively, I ended up having to re-implement my entire project in the native midi library for java.

    After doing so, I found a good release which natively incorporates Java’s MIDI library, see link below as this is in my opinion a much better alternative to proMIDI:

    Use RWMIDI for processing instead:

    http://ruinwesen.com/support

    Jocepos

Comments are closed.