fader_master/docs/midi-identity.md

1.8 KiB

Linux MIDI identity spike

midir 0.11.1 exposes Linux ports as ALSA sequencer client:port addresses and human-readable names. Neither value is a durable USB identity: client numbers can change with connection and discovery order, while identical controllers can publish identical names.

For a kernel sequencer client, ALSA reports its sound-card number. The MIDI identity probe opens that card's udev sound/cardN device and copies:

  • ID_VENDOR_ID and ID_MODEL_ID as the controller model key;
  • ID_SERIAL_SHORT when the USB device supplies a serial;
  • ID_PATH as the physical connection fallback.

User and virtual ALSA clients return no card number and therefore no USB metadata. They may be selected by a unique port name, but duplicate names remain ambiguous.

Matching policy

  1. Match the configured port name and, for USB devices, VID/PID.
  2. Prefer an exact serial when one was observed.
  3. Without a serial, prefer the retained physical path.
  4. A unique remaining model/name is safe to select.
  5. Multiple remaining candidates stay unassigned. An explicit backend-port choice may resolve the current topology, but the ephemeral ALSA address is not treated as durable evidence after reconnect or reboot.

This means two identical serial-less devices can remain attached to stable USB sockets and be distinguished by path. If they move between sockets, software cannot prove which physical unit is which; silently binding by enumeration order would risk controlling the wrong applications.

Recorded host observation

On 2026-10-14, the Arch Linux host exposed only PortIdentity { backend_id: "14:0", name: "Midi Through:Midi Through Port-0 14:0", usb: None }. This validates the virtual-client fallback but is not physical-controller acceptance. The controller observations requested in checklist.md must be recorded before M5.2 is marked complete.