Is MidiDeviceInfo::identifier unique per unit?

Hopefully a quick question - is the MidiDeviceInfo::identifier unique per individual unit? Or only unique per device model (or perhaps firmware version of the device)?

For example, if I have 2 Korg nanoKeys plugged in, will they each have the same identifier, or different ones?

If others are interested in figuring this out empirically, I would be happy to post some identifier strings here, and we can compare. I just don’t have 2 of the same model unit here to check this myself.

PS: There is some overlap with the questions posed in this thread, but I don’t see the issue squarely answered there either:

Yes, the identifier will be unique per unit so you can distinguish between two of the same connected devices. You can’t rely on them being persistent though and on Windows at least the indentifier may change based on the port that the device is connected to.

1 Like

Thanks Ed for the clarification. And good to know about the Windows caveat.

I have now done some further testing on this question, with 2 of the same device model (in this case, 2 Behringer X-Touch Mini controllers), on macOS.

As @ed95 says, the MidiDeviceInfo::identifier is “unique per unit”, but that is only true for a given moment in time. The identifier is not a property that is inherent to the unit itself. Instead, it is partly based on the USB port that the device is plugged into, so the identifier can change when the device is plugged into different ports… but also it doesn’t necessarily change just from changing ports.

So basically, I’m agreeing with what Ed said, and adding that it’s also true on macOS as well as Windows, that the identifier can change based on which port a MIDI device is plugged into.

To show an actual example, here are the results from iterating the output of MidiInput::getAvailableDevices(), and writing .name , .identifier of each entry to the debug output.

I start by plugging in only one unit at a time, to different ports:

When X-Touch unit A is in USB port 1:
X-TOUCH MINI, 1878780887

When X-Touch unit A is in USB port 2:
X-TOUCH MINI, 1878780887

When X-Touch unit B is in USB port 1:
X-TOUCH MINI, 1878780887

So, all the same so far, even though I’m swapping around units and ports, but now I try both at once…

When X-Touch unit A is in USB port 1, and X-Touch unit B is in USB port 2:
X-TOUCH MINI, -1779811009
X-TOUCH MINI, 1878780887

And, once it has assigned these different identifiers, if I return to plugging in only one unit at a time, then:

When X-Touch unit A is in USB port 1:
X-TOUCH MINI, 1878780887

When X-Touch unit A is in USB port 2:
X-TOUCH MINI, -1779811009

Now it gives different identifiers to the different ports!

Will the input and output of the same controller have identical identifiers?

Ah, good idea to check, but unfortunately not.

Remember, MIDI hardware can have any number (including zero) of input ports and output ports (well, I suppose it needs at least 1 port of some kind, or it doesn’t qualify as “MIDI hardware”). If a particular device had one MIDI input and two MIDI outputs, which one of the outputs would share an identifier with the input?

Well in my particular case, I would love them all to have the same identifier, thinking of it as a usb port number of some sort. I know it is not the case, and if -let say- the device has dedicated 5din Midi in and out this will present more complications.

But as the nature of the modern devices that the Juce app will run on generally happens to connect to the device via usb that would make some sense.

Java on android for example treats the device as a device class, with input and output properties, very straight forward. I wish Juce had some kind of a class that can help with this out-of-the-box

As a complete side issue - @t0m can you tell me why my original post in this thread shows as having been edited twice? First time by you, second time by @jrlanglois?

It looks like the content was not actually modified either time. As an admin, I suppose you have forum permissions to edit users’ posts, but why would another user be allowed to do this?

I’m adding categories and tags to posts that are missing them to help users sift through the wads of them.

To add, it looks like doing this is intrusive in that it notifies the OP, as well as pushing the post upwards in the category as a new reply was added… I might avoid doing this unless it’s really necessary. Sorry for any noise and confusion!

Ah, I see. Innocuous enough! I had looked for an explanation in the forum FAQ but couldn’t find anything.