objective c - MIDI Machine Control packet has unexpected bytes - Stack Overflow

admin2025-05-02  0

I'm trying to debug incoming MMC "locate" messages that are being sent from Pro Tools to my macOS app. I can't parse the bytes I'm receiving - they seem to be encoded or wrapped or something.

My development environment is: macOS Sequoia, Xcode 16.1, targeted minimum deployment macOS 13.5, Objective-C.

I've defined my input port using Core MIDI, like this:

MIDIInputPortCreateWithProtocol(client, CFSTR("Input port"), kMIDIProtocol_1_0, &inPort, gReceiveBlock);

I get the MIDI message in my gReceiveBlock callback routine, so I know everything is setup properly (endpoints, ports, MMC ID, etc). But the bytes in the incoming packet don't line up with what is in the MIDI spec. I'm using the MIDI Monitor app to sniff messages, and it shows the packet sent from Pro Tools:

16:48:30.173    From IAC Driver Bus 1   SysEx Universal Real Time 13 bytes  F0 7F 01 06 44 06 01 01 01 0F 23 00 F7  

But in my app, when I examine the packet, I see:


    timeStamp   MIDITimeStamp   0x0000000000000000
    wordCount   UInt32  0x00000004
    words   UInt32[64]  
    [0] UInt32  0x30167f01
    [1] UInt32  0x06440601
    [2] UInt32  0x30350101
    [3] UInt32  0x0f210000

I've bolded the bytes that don't match between MIDI Monitor's "words" buffer and mine. Specifically, in my buffer the first byte is not a SysEx byte (0xF0), there are extra bytes inserted between the control bytes and the timecode bytes, the frames value of the timecode bytes is incorrect, and there's no ending byte (0xF7).

Here's the code that receives the bytes:

MIDIReceiveBlock const gReceiveBlock = ^(const MIDIEventList *eventList, void *srcConnRefCon) {
    // Process each packet in the event list
    const MIDIEventPacket *packet = &eventList->packet[0];
    for (int i = 0; i < eventList->numPackets; ++i) {
        // Get the MIDI words (32-bit data chunks)
        for (int w = 0; w < packet->wordCount; ++w) {
            uint32_t word = packet->words[w];
            // Process the packet
        }
        packet = MIDIEventPacketNext(packet);
    }
};

What am I not getting? BTW I tried changing kMIDIProtocol_1_0 to kMIDIProtocol_2_0 when creating the input port, but same result.

转载请注明原文地址:http://anycun.com/QandA/1746136603a92078.html