Get Output port id associated with a given Input port id?

Since input port ids and output port ids are different values for the same device, is there a way to get one from the other?

In other words, if I get a MIDI message from a given device, how can I figure out which Output will send MIDI back to that device?

Is the `.name` property the best way to do this?

Comments

  • This is an excellent question, which I had not thought about before. The spec says very little about that. As far as I know, there is no official way to check whether an input and an output belong to the same device.

    While the name property might sometimes work, some manufacturers add suffixes (such as "IN" or "OUT") to the name. There is a discussion regarding this in the JUCE Forum.

    You could post about it on the Web MIDI API GitHub. Perhaps, a field could be added to identify the actual device. However, there are always concerns of fingerprinting and security that come into play.

  • Well it's good to know I wasn't missing anything obvious! 😀

    This would be a good feature for Web MIDI API, so I'll post there..

    In the meantime, we have an Input.manufacturer property. And IIRC, there's a way to get way to a device ID through a sysex interaction. Seems like there'd be some way to build a device "fingerprint" based on those things. An Identity Request?

    Of course, that's not something you'd want to do before each MIDI event, but maybe it could be mapped to the input/output port objects.

    Thanks for the help! I'll keep researching this.

  • edited April 9

    Sending an identity request is definitely something that could be done. You can do it with sendSysex(). A getIdentity() method is already planned for version 3.

Sign In or Register to comment.