The MidiBus is not finding available virtual MIDI devices

edited October 2014 in Library Questions

I've a sketch that listens for MIDI messages and displays animated GIFs based on notes and velocity. The MIDI is driven by a program called Renoise. Since this is app-to-app communication (i.e. there is no actual MIDI keyboard here) I needed to use some internal MIDI routing. On WIndows I use LoopBe and it works fine.

On Ubuntu I'm using virmidi to create virtual MIDI ports. When I run my sketch, which used The MidiBus library, it does not detect any of these virtual devices. (Renoise, OTOH, sees these virtual devices just fine.)

I thought this might just be a Java thing but I have other Java code running on the same machine that does find and interact with these virtual devices (and can receive the MIDI messages sent by Renoise over a virtual MIDI device).

In digging though some code I learned that an available virtual MIDI input device can be detected by checking getMaxTransmitters. For real devices this should return a positive value. Available virtual devices return -1.

When the MidiBus code runs all the virtual input devices have getMaxTransmitters == 0. In the other Java code (a JRuby program that uses the same underlying Java system libs as MidiBus) these devices have getMaxTransmitters == -1.

Has anyone else run into this? It may well be some quirk of my setup, so I'm curious to hear from anyone else who has virtual MIDI devices on Ubuntu with the MidiBus library.

Tagged:

Answers

  • Here's a simple Java program that lists the available input devices.

    import javax.sound.midi.MidiSystem;
    import javax.sound.midi.MidiDevice;
    
    class JavaMidiTest {
    
      public static void main(String args[]){
    
        System.out.println("Listing all devices with getMaxTransmitters != 0 ");
    
        MidiDevice device;
        MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
        for (int i = 0; i < infos.length; i++) {
          try {
            device = MidiSystem.getMidiDevice(infos[i]);
            if (device.getMaxTransmitters() != 0 ) 
              System.out.println(infos[i] + "\tdevice.getMaxTransmitters() = " + device.getMaxTransmitters() );
          } catch (Exception e) {
            System.err.println(e);
          }
        }
      }
    
    }
    /*
     Listing all devices with getMaxTransmitters != 0 
    VirMIDI [hw:1,0,0]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,1]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,2]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,3]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,4]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,5]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,6]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,7]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,8]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,9]  device.getMaxTransmitters() = -1
    VirMIDI [hw:1,0,10] device.getMaxTransmitters() = -1
        ...
    VirMIDI [hw:1,3,15] device.getMaxTransmitters() = -1
    Real Time Sequencer device.getMaxTransmitters() = -1
    
    */
    

    The code in the MidiBus seems to do essentially the same thing. One method does this:

     MidiBus.available_devices = MidiSystem.getMidiDeviceInfo();
    

    Then later

    for(int i = 0;i < MidiBus.available_devices.length;i++) {
      try {
        device = MidiSystem.getMidiDevice(MidiBus.available_devices[i]);
    
                    if (device.getMaxTransmitters() != 0) {
              devices_list.add(MidiBus.available_devices[i]);
            }
        // ...
      }
    }
    

    Yet the results are quite different.

  • Answer ✓

    To answer my own question: This seems to be a matter of 32 v. 64 bit. The Java ( and JRuby code) was being run using 64-bit Java.

    I've apparently been using a 32-bit install of Processing. I now installed the current 32 and 64-bit versions of Processing, and the 32 bit version does not show the virtual devices while the 64-bit version works fine.

Sign In or Register to comment.