下面是c方法我得到notetype和notenumber我想要顯示它在標籤上。 實際上,我正在播放midi文件,下面的方法會返回midi文件數據,但是在clang方法中,但我想在標籤上顯示它。如何從c語言獲取數據
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);
}
}
上述方法產生了什麼?你能打印票據嗎? – Krumelur 2013-02-18 08:51:11
而上面的函數是Objective-C,而不是C :) – Krumelur 2013-02-18 08:51:37
Krumelur,從技術上講,它是一個C函數,Objective C對象在...中,因此需要由ObjC++編譯器編譯。但我們離題了,呃;) – MOK9 2013-03-07 08:02:06