WebAudio / web-midi-api

The Web MIDI API, developed by the W3C Audio WG
http://webaudio.github.io/web-midi-api/
Other
323 stars 49 forks source link

Input/Output device mapping #239

Open chrisguttandin opened 1 year ago

chrisguttandin commented 1 year ago

MIDI-CI messages require a bi-directional communication with MIDI devices. As far as I can tell there is currently no way to map an input device with its corresponding output device with WebMIDI. Unfortunately a typical MIDI-CI message flow requires this mapping.

midiOutputDevice.send(/* a MIDI-CI query message */)
midiInputDevice.onmessage = (event) => { /* a MIDI-CI response message */ };

The problem is that there is currently no way to know which midiInputDevice will receive the response when sending something to a particular midiOutputDevice.

Most devices use similar names which makes it is easy for humans to map them. But I guess this is error prone since the names are different from operating system to operating system and a list of mapped devices would be very difficult to maintain.

MIDI-CI messages also contain a MIDI Negotiation Identifier (MIND) which is unique and would allow to map responses with query messages. But in order to do that one would have to listen to all MIDI input devices to capture each and every message just to find the one device that answers.

Maybe it's an options to add something similar to the groupId of a MediaDeviceInfo object which identifies physical devices.

interface MIDIPort {
  readonly attribute DOMString groupId;
};
raveslave commented 1 year ago

the best would be to expose the usb-devices and port structure

mjwilson-google commented 1 year ago

See also #148