Search code examples
usbmidi

What does the Cable Number field represents in an USB-MIDI Event packet?


My OS is Windows 7, i use MIDI-OX as a MIDI utility and wireshark as a sniffer.

Currently developping some MIDI app on STM32, i have a hard time understanding the meaning of cable number in an USB-MIDI Event packet. USB MIDI Event packet

The USB MIDI specification states (p.16, 4) that :

The Cable Number (CN) is a value ranging from 0x0 to 0xF indicating the number assignment of the Embedded MIDI Jack associated with the endpoint that is transferring the data.

In my project, i have an embedded Jack OUT which ID is 3. When trying to send USB-Midi event with a cable Number set at 3, my MIDI messages were not recognized by my MIDI-OX, although they were seen by Wireshark. Changing the cable number to 0 made the MIDI events recognized by MIDI OX. But i want to understand why it made it work.

I think i have confused number assignement and Jack ID, so what is this number assignment ?


Solution

  • Section 3.1 of the USB MIDI specification says:

    Each Entity within the USB-MIDI function is assigned a unique identification number, the EntityID, contained in the bJackID or bElementID field of the descriptor. The value 0x00 is reserved for undefined ID, effectively restricting the total number of addressable Entities in the USB-MIDI function (both Jacks and Elements) to 255.

    So this cannot be used for a four-bit cable number.

    That "number assignment" refers to the following algorithm (which everybody pretends is obvious): the cable numbers of an endpoint are from zero to one less than bNumEmbMIDIJack.