下面是我要在标签上显示的注释类型和注释编号的 c 方法。实际上我正在播放一个midi文件,方法是返回midi文件数据,但是在clang方法中,但我想在标签上显示它。
static void MyMIDIReadProc(const MIDIPacketList *pktlist,
void *refCon,
void *connRefCon) {
AudioUnit *player = (AudioUnit*) 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 : noteNumber %@",[noteType stringByAppendingFormat:[NSString stringWithFormat:@": %i", noteNumber]]);
ViewController* audio = (__bridge ViewController*)refCon;
[audio.self.noteDisplayLabel setText:@"sdasd"];
audio.test_messages = @"sdsadsa";
[audio labelText:@"asdasdas"];
NSLog(@"%@", audio.test_messages);
OSStatus result = noErr;
// result = MusicDeviceMIDIEvent (player, midiStatus, note, velocity, 0);
}
packet = MIDIPacketNext(packet);
}
}