Sunday, 15 March 2015

ios - how get data from c language -



ios - how get data from c language -

below c method getting notetype , notenumber want show on label. playing midi file below method homecoming midi file info in clang method want show on label.

static void mymidireadproc(const midipacketlist *pktlist, void *refcon, void *connrefcon) { audiounit *player = (audiounit*) refcon; midipacket *packet = (midipacket *)pktlist->packet; (int i=0; < 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* sound = (__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); } }

are nslog messages working? looks if should be.

it not practice (and may have problems) setting view midi read proc, realtime callback , don't want spend time writing ui in place.

better if force events somewhere (like array) , send notification view controller (with array object) @ end function. want homecoming function.

ios clang midi

No comments:

Post a Comment