Why doesn't this simple CoreMIDI program produce MIDI output?

后端 未结 4 540
独厮守ぢ
独厮守ぢ 2020-12-23 23:56

Here is an extremely simple CoreMIDI OS X application that sends MIDI data. The problem is that it doesn\'t work. It compiles fine, and runs. It reports no errors, and does

4条回答
  •  失恋的感觉
    2020-12-24 00:35

    A little detail that others are skipping: the time parameter of MIDIPacketListAdd is important for some musical apps.

    Here is an example of how you can retrieve it:

    #import 
    MIDITimeStamp midiTime = mach_absolute_time();
    

    Source: Apple Documentation

    And then, applied to the other examples here:

    pktBuffer[1024];
    MIDIPacketList *pktList = (MIDIPacketList*)pktBuffer;
    MIDIPacket *pktPtr = MIDIPacketListInit(pktList);
    MIDITimeStamp midiTime = mach_absolute_time();
    Byte midiDataToSend[] = {0x91, 0x3c, 0x40};
    pktPtr = MIDIPacketListAdd(pktList, sizeof(pktList), pktPtr, midiTime, sizeof(midiDataToSend), midiDataToSend);
    

提交回复
热议问题