Get Midi Input information (is External Device)


#1

Hi there,
I would like to implement auto connect with MIDI devices that are externals.

I already implemented “static void globalSystemChangeCallback (const MIDINotification*, void*)” to do the auto connect. In this proc I perform a call to GetDevice and for each device and connect it automatically if it is external.

Would you consider adding a method somewhere that returns if a midi input device is external (or a struct with some device information) ?

(Optional) Implementing the notification for globalSystemChangeCallback would avoid duplicating some code and would be very handy. (in juce_mac_CoreMidi.cpp)

Thank you


#2

Happy to consider it of course! But remember that we need to make everything cross-platform, so a hack that just works on Windows isn’t much use to use.


#3

You are right this is the tricky part, I guess there is no harm duplicating some code.

I would have a question then, can I trust this method that I plan to duplicate and modify to define if a device is external:

static String getConnectedEndpointName (MIDIEndpointRef endpoint)

And have some code like this:

        if (connObjectType == kMIDIObjectType_ExternalSource
            || connObjectType == kMIDIObjectType_ExternalDestination)
            {
          isDeviceExternal = true;
           }

Instead of

          if (connObjectType == kMIDIObjectType_ExternalSource
            || connObjectType == kMIDIObjectType_ExternalDestination)
             {
               // Connected to an external device's endpoint (10.3 and later).
                  s = getEndpointName (static_cast<MIDIEndpointRef> (connObject), true);
             }

Thank you for you time


#4

Sorry… I don’t understand the question?


#5

I was just wondering if this IF statement really means that the MIDI device is external.
I suppose yes but I wanted to make sure before I get myself inspired by this code to define if a device is external or not.

(in juce_mac_CoreMidi.cpp)

static String getConnectedEndpointName (MIDIEndpointRef endpoint)
{
[…]
if (connObjectType == kMIDIObjectType_ExternalSource
|| connObjectType == kMIDIObjectType_ExternalDestination)
{
// Does this means we are using an external device?
s = getEndpointName (static_cast (connObject), true);
}
[…]


#6

I guess so. It’s worth checking whether there are any other items in that enum that may also need be be checked for.