I've got an app that communicates with midi devices, this app worked fine for years, however since MacOS 13.3 and iOS 16 users complained about strange behaviors.
After days of debugging I found out that the USB Midi Packets sent are sometimes invalid (wrapped in sysex headers).
Here is the extract used to sent a single midi message
UInt8 mBuffers[100];
MIDIPacketList* packetList = (MIDIPacketList*) mBuffers;
MIDIPacket* packet = MIDIPacketListInit(packetList);
MIDIPacketListAdd(packetList, sizeof(mBuffers), packet, 0, messageLength, (Byte *) messageData);
printf("Sending %i bytes ", messageLength);
for (int i = 0; i < messageLength; i++)
{
if (i > 0) printf(":");
printf("%02X", (Byte)messageData[i]);
}
printf("\n");
fflush(stdout);
status = MIDISend(outputPortReference, endPointReference, packetList);
Here is the output of the program when the issues occurs:
Sending 3 bytes E0:00:00
Sending 3 bytes D0:00:00
Sending 3 bytes E1:00:00
Sending 3 bytes D0:1B:00
Sending 3 bytes E2:00:00
Sending 3 bytes D0:2B:00
Sending 3 bytes E3:00:00
Sending 3 bytes D0:3B:00
Sending 3 bytes D0:4A:00
Sending 3 bytes D0:5A:00
Sending 3 bytes D0:6A:00
Sending 3 bytes D0:79:00
The data rate is relatively high (~100ms per message)
However when looking at the usb stack, the following data gets sent:
0e e0 00 00 -> Match
0d d0 00 00 -> Match
04 00 e1 00 -> WRONG - wrapped in Sysex
04 00 d0 1b -> WRONG - wrapped in Sysex
0f 00 00 00 -> Padding
0e e2 00 00 -> Match
0d d0 2b 00 -> Match
04 00 e3 00 -> WRONG - wrapped in Sysex
04 00 d0 3b -> WRONG - wrapped in Sysex
04 00 d0 4a -> WRONG - wrapped in Sysex
0f 00 00 00 -> Padding
0d d0 5a 00 -> Match
0f 00 00 00 -> Padding
0d d0 6a 00 -> Match
04 00 d0 79 -> WRONG - wrapped in Sysex
0f 00 00 00 -> Padding
I can't explain anymore why this is happening and looking for some advice. Since I can't debug on that level on iOS I can only guess that the root cause is the same.
Does anyone know about such an issue? Any ideas how to further debug?