Post

Replies

Boosts

Views

Activity

Reply to MIDISend vs MIDISendEventList
Same with me, I create event list like below. The Old API can work , but the new API not work. No midi signal sent out (int)sendShortMsg:(unsigned char)deviceIndex :(unsigned char *)pMsg :(unsigned long)size {     int result = 0;     OSStatus err = 0;     ByteCount bufSize = 1024;     Byte packetListBuf[1024];     MIDIEventList *eventList = NULL;     MIDIEventPacket *event = NULL;     MIDIPacketList* pPacketList = NULL;     MIDIPacket* pPacket = NULL;     if ((pMsg == NULL) || (size == 0)) {         ErrLog(@"The msg is empty");     }     if (outPortRef == 0) {         ErrLog(@"the outportRef equal zero, it's invalid.");         goto EXIT;     }     if (@available(iOS 14.0, *)) {         eventList = (MIDIEventList *)packetListBuf;         event = MIDIEventListInit(eventList, kMIDIProtocol_1_0);         if (event == NULL) {             ErrLog(@"pPacket is null");             goto EXIT;         }     } else {         pPacketList = (MIDIPacketList*)packetListBuf;         pPacket = MIDIPacketListInit(pPacketList);         if (pPacket == NULL) {             ErrLog(@"pPacket is null");             goto EXIT;         }     }     if (@available(iOS 14.0, *)) {         UInt32 *newMsg = [self convertMidi1ToMidi2WithData:pMsg size:size]; // convert byte array to UInt32 array         event = MIDIEventListAdd(eventList, bufSize, event, 0, size, newMsg);         if (event == NULL) {             ErrLog(@"pPacket is null 2");             goto EXIT;         }     } else {         pPacket = MIDIPacketListAdd(                                     pPacketList,                                        bufSize,                                            pPacket,                                          0,                                                size,                                               (Byte*)pMsg                                     );         if (pPacket == NULL) {             ErrLog(@"pPacket is null 2");             goto EXIT;         }     }     if (@available(iOS 14.0, *)) {         err = MIDISendEventList(outPortRef, devInfo.m_EndpointRef, eventList);         if (err != noErr) {             ErrLog(@"MIDI OUT device output error.");             goto EXIT;         }     } else {         err = MIDISend(outPortRef, devInfo.m_EndpointRef,pPacketList);         if (err != noErr) {             ErrLog(@"MIDI OUT device output error.");             goto EXIT;         }     } EXIT:;     return result; }
Topic: Media Technologies SubTopic: General Tags:
Dec ’20