With the following code I'm trying to send a MIDI-Event to an NSLog Synth:
MIDIClientRef midiClient = NULL;
MIDIClientCreate(
CFSTR("MidiClient"),
NULL,
NULL,
&midiClient
);
MIDIPortRef midiClientOutPort = NULL;
MIDIOutputPortCreate(
midiClient,
CFSTR("MidiClientPort"),
&midiClientOutPort
);
NSLog(@"%lu", MIDIGetNumberOfDestinations());
MIDIEndpointRef endpoint = NULL;
endpoint = MIDIGetDestination(1);
CFPropertyListRef plist = NULL;
MIDIObjectGetProperties(endpoint, &plist, YES);
NSArray *temp = [NSArray arrayWithObject:(__bridge id)(plist)];
NSLog(@"%@", [temp description]);
MIDIPacketList packet;
packet.numPackets = 1;
packet.packet[0].data[0] = 0x90;
packet.packet[0].data[1] = 0x3c;
packet.packet[0].data[2] = 0x40;
packet.packet[0].timeStamp = 0;
MIDISend(midiClientOutPort, endpoint, &packet);
If I check OSStatus I get no errors. I get a MIDIClient, a MIDIOutputPort and the MIDISend is also fine. Additionally I get the synth destination with no errors. The synth is listening to all midi channels and if I test with a sequencer to synth responds with audio. I execute the code with a button press but nothing happens.
What doing I'm wrong?
The solution:
I have to set the length property!