Is the Web MIDI API Port ID unique to each device or the device in general?

100 views Asked by At

Referring to https://webaudio.github.io/web-midi-api/#dom-midiport-id.

As an example, let's say we're talking about Synth X. The name and manufacturer parameters of the MIDIPort would be the same across any instance of Synth X that connects.

My question is, would each individual Synth X product have a unique id parameter? For example, my friend and I both have Synth X, would the IDs be unique?

Or is this more like a device ID? Like manufacture + name = ID? All Synth X products would return the same ID?

1

There are 1 answers

0
Brad On

No, it isn't unique.

At least on Windows, these port numbers/IDs are just the enumeration order of devices. While the idea of the spec is that you can save one and re-open the same device later, this doesn't really work in between page loads in practice. (Which, is really unfortunate!)

Taking this another step further, the OS doesn't really know how to uniquely identify the device either. Even in the case of USB, the device descriptor doesn't always have a unique ID. It's common for cheaper devices to all be programmed with the same serial, or no serial at all.