ianhomer / odin

Sequencer to enhance live musical performances, jamming and compositions
Other
5 stars 0 forks source link

MIDI Device connections do not update in running process on OSX #1

Open ianhomer opened 7 years ago

ianhomer commented 7 years ago

Call to

MidiSystem.getMidiDeviceInfo

never changes after application is initialised even when MIDI devices are connected or disconnected. Application needs to be reconnected to discover new connections.

The class com.purplepip.odin.midi.MidiDeviceWrapper was created to allow rediscovery, but it does not work on Mac OS. It has not been tested on any other OS.

Background

This issue has been reported elsewhere

    Method method = MidiOutDeviceProvider.class.getDeclaredMethod("nGetNumDevices");
    method.setAccessible(true);
    LOG.info("Number of devices {} ", method.invoke(null));

The observation that Juce has resolved the issue could suggest that it is not a core Apple bug and perhaps the JDK is not calling MIDIClientCreate correctly. Note that MIDINotifyProc API docs do state that the "MIDINotifyProc callback function is invoked on the same thread on which you called the MIDIClientCreate function." and is called "when the MIDI state changes.". Perhaps in the JDK this callback is not fired correctly.

The osxmidi4j provides a native MIDI integration which might be different to the Core Java implementation. I wonder whether that library encounters the same issue.

Environment

macOS 10.11.6 and 10.12.4 Java 1.8.0_66-b17