Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MIDIEndpointRef localVirtualEndpoint;
- result = MIDIDestinationCreate(virtualMidi,
- (CFSTR("Virtual Destination")),
- MyMIDIReadProc,
- _samplerUnit1,
- &localVirtualEndpoint);
- static void MyMIDIReadProc(const MIDIPacketList *pktlist,
- void *refCon,
- void *connRefCon) {
- AUGraph *player = (AUGraph*) refCon;
- MIDIPacket *packet = (MIDIPacket *)pktlist->packet;
- for (int i=0; i < pktlist->numPackets; i++) {
- Byte midiStatus = packet->data[0];
- Byte midiCommand = midiStatus >> 4;
- if (midiCommand == 0x09) {
- Byte note = packet->data[1] & 0x7F;
- Byte velocity = packet->data[2] & 0x7F;
- int noteNumber = ((int) note) % 12;
- NSString *noteType;
- switch (noteNumber) {
- case 0:
- noteType = @"C";
- break;
- case 1:
- noteType = @"C#";
- break;
- case 2:
- noteType = @"D";
- break;
- case 3:
- noteType = @"D#";
- break;
- case 4:
- noteType = @"E";
- break;
- case 5:
- noteType = @"F";
- break;
- case 6:
- noteType = @"F#";
- break;
- case 7:
- noteType = @"G";
- break;
- case 8:
- noteType = @"G#";
- break;
- case 9:
- noteType = @"A";
- break;
- case 10:
- noteType = @"Bb";
- break;
- case 11:
- noteType = @"B";
- break;
- default:
- break;
- }
- NSLog(@" noteType= %@ note number %d",noteType,noteNumber);
- OSStatus result = noErr;
- //MARK: Render
- result = MusicDeviceMIDIEvent (player,
- midiStatus,
- note+7,
- velocity,
- 0);
- }
- packet = MIDIPacketNext(packet);
- }
- MIDIEndpointRef localVirtualEndpoint;
- result = MIDIDestinationCreate(virtualMidi,
- (CFSTR("Virtual Destination")),
- MyMIDIReadProc,
- _processingGraph,
- &localVirtualEndpoint);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement