Here's the basic MIDI send stuff (mostly straight from PGMidi)
-(void)noteOn:(NSUInteger)voice note:(NSUInteger)note{
if(voice == 1){
UInt8 status = 144 + (UInt8)chordMIDIChannel;
const UInt8 noteOn[] = { status, (UInt8)note, chordMIDIVelocity };
if(chordMIDIDest)[chordMIDIDest sendBytes:noteOn size:sizeof(noteOn)];
else [midi virtualPortSend:noteOn size:sizeof(noteOn)];
}else{
UInt8 status = 144 + (UInt8)leadMIDIChannel;
const UInt8 noteOn[] = { status, (UInt8)note, leadMIDIVelocity };
if(leadMIDIDest)[leadMIDIDest sendBytes:noteOn size:sizeof(noteOn)];
else[midi virtualPortSend:noteOn size:sizeof(noteOn)];
}
}
and the PGMidiDestination send bytes:
- (void) sendBytes:(const UInt8*)bytes size:(UInt32)size
{
assert(size < 65536);
Byte packetBuffer[size+100];
MIDIPacketList *packetList = (MIDIPacketList*)packetBuffer;
MIDIPacket *packet = MIDIPacketListInit(packetList);
packet = MIDIPacketListAdd(packetList, sizeof(packetBuffer), packet, 0, size, bytes);
[self sendPacketList:packetList];
}
- (void) sendPacketList:(const MIDIPacketList *)packetList
{
// Send it
OSStatus s = MIDISend(midi.outputPort, endpoint, packetList);
NSLogError(s, @"Sending MIDI");
}