由于某种原因,当我尝试使用CORE-MIDI通过USB发送3条关于Midi消息时,输出设备仅播放一个音符,这是我的代码Objectivc-C
const UInt8 noteOn[] = { 0x90, 60, 127 };
const UInt8 noteOn2[] = { 0x90, 64, 127 };
const UInt8 noteOn3[] = { 0x90, 68, 127 };
UInt32 size0 = sizeof(noteOn);
NSLog(@"%s(%u bytes to core MIDI)", __func__, unsigned(size0));
assert(size0 < 65536);
Byte packetBuffer[size0*3+100];
MIDIPacketList *packetList = (MIDIPacketList*)packetBuffer;
MIDIPacket *packet = MIDIPacketListInit(packetList);
packet = MIDIPacketListAdd(packetList, sizeof(packetBuffer), packet, 0, size0, noteOn);
packet = MIDIPacketListAdd(packetList, sizeof(packetBuffer), packet, 0, size0, noteOn2);
packet = MIDIPacketListAdd(packetList, sizeof(packetBuffer), packet, 0, size0, noteOn3);
for (ItemCount index = 0; index < MIDIGetNumberOfDestinations(); ++index)
{
MIDIEndpointRef outputEndpoint = MIDIGetDestination(index);
if (outputEndpoint)
{
// Send it
OSStatus s = MIDISend(outputPort, outputEndpoint, packetList);
NSLogError(s, @"Sending MIDI");
}
}
如何同时发送这3条NOTE Midi消息?
关于ObjetiveC或Swift的任何示例都会有所帮助。