MIDI send problems.
MIDI send problems.
- Subject: MIDI send problems.
- From: Jason Bagley <email@hidden>
- Date: Thu, 02 Aug 2001 15:37:18 -0700
Hi,
I've been having trouble sending anything but 3 byte messages through
MIDISend, and I can't seem to get anything to send through MIDISendSysex
at all. Both calls return noErr, and when using MIDISendSysex my
SysexComplete routine is called with bytesToSend == 0 and complete ==
TRUE.
Trying to send messages larger than 3 bytes through MIDISend often freezes
my system! Cursor is active, but I can't do anything else. Unplugging the
interface from the USB chain does not end the freeze.
I've isolated some of the MIDI code in a small test app. There I can send
larger messages via MIDISend, but I have to send a 3 byte message first.
Otherwise, on subsequent invocations of the test app, no large data will
be sent.
I'm using OS X 10.0.4, and MIDISPORT 2x2 with the driver available from
MIDIMAN. I know others have said they have no trouble with this driver.
Thanks in advance for any help.
Here is a snippet of the test app:
const Byte kMIEXGGetKeyboardMode[] = { 0xf0, 0x43, 0x76, 0x65, 0x30,
0x7f, 0x00, 0x00, 0x02, 0xf7 };
Byte noteOn[] = { 0x90, 60, 4 };
Byte noteOff[] = { 0x80, 0, 0 };
...
const Byte *sysExEvent = kMIEXGGetKeyboardMode;
int sysExLength = CalcSysExLength(sysExEvent);
...
#if 0
// Send via MIDISendSysex
sysExRequest = malloc(sizeof(MIDISysexSendRequest) + sysExLength);
memcpy((unsigned char*)sysExRequest + sizeof(MIDISysexSendRequest),
sysExEvent, sysExLength);
sysExRequest->destination = destination;
sysExRequest->data = (unsigned char*)sysExRequest +
sizeof(MIDISysexSendRequest);
sysExRequest->bytesToSend = sysExLength;
sysExRequest->complete = false;
sysExRequest->completionProc = SysExCompletionProc;
sysExRequest->completionRefCon = (void *)sysExRequest;
result = MIDISendSysex(sysExRequest);
fprintf(stderr, "SendSysEx returned %ld.\n", result);
#else
// Send via MIDISend
packet = MIDIPacketListInit(packetList);
assert(NULL != packet);
// Workaround. Send a 3 byte message to "prime" driver?
packet = MIDIPacketListAdd(packetList, 512, packet, timeStamp, 3,
noteOff);
result = MIDISend(outputPort, destination, packetList);
fprintf(stderr, "MIDISend returned %ld.\n", result);
packet = MIDIPacketListInit(packetList);
packet = MIDIPacketListAdd(packetList, 512, packet, timeStamp + 100000,
sysExLength, sysExEvent);
result = MIDISend(outputPort, destination, packetList);
fprintf(stderr, "MIDISend returned %ld.\n", result);
#endif
fprintf(stderr, "Entering run loop.\n");
CFRunLoopRun();
Jason Bagley
Software Engineer
www.artlogic.com