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
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);