osx - CoreMIDI: midiReadProc only receives the first packet of 3 packets with the same timestamp -


i working on small program monitor midi output ni maschine 2. (idea add program change messages parts in ni machine , use them trigger vj-efects , other stuff)

the following test case gives problem. test part in ni machine has 1 note , 2 program change messages on first beat , second note 16th later.

when hit start , capture output midi monitor tool see: results midi monitor

this correct. maschine sending. - notice 2 control changes , next note on packets have same timestamp.

when same simple virtual client (see code below) this: results virtual client

  • as can see second control change , note on packets missing!

notice second third line (song position , continue) have same timestamp , in both cases received.

if took trouble read until point understand problem. know big difference between simpel virtual client , midi monitor program use of coremidi service plugin 'spying' midi output. limitation of coremidi or missing something?

below code virtual client: stripped down basic needs receive ni mashine. init sets virtual client, destination , sets uniqueid. readproc producing nslog messages missing packets shown above.

any suggestions appreciated

// //  virtualclient.m //  testmidireadproc // //  created rob keeris on 02/06/15. //  copyright (c) 2015 connector. rights reserved. //  #import "virtualclient.h"  @implementation virtualclient   sint32          virtualinuniqueid = 1234567893; midiclientref   client; midiendpointref virtualin;  nsstring * miditypename(byte miditype){     switch (miditype) {         case 0x80: return @"note off";         case 0x90: return @"note on";         case 0xb0: return @"controlchange";         case 0xc0: return @"programchange";         case 0xf2: return @"songposition";         case 0xf8: return @"clock";         case 0xfa: return @"start";         case 0xfb: return @"continue";         case 0xfc: return @"stop";         case 0x00: return @"invalidtype";         default: return [nsstring stringwithformat:@"unlisted miditype 0x%02x",miditype];     } }  void midireadproc (const midipacketlist *list, void *procref, void *srcref) {      const midipacket *packet = &list->packet[0];  // ?defined const avoid compiler warnings?     (int = 0; < list->numpackets; i++) {          if (packet->data[0] != 0xf8){ // filter out clock messages              nslog(@"%llu packet(%i of %i) %@(0x%02x) 0x%02x 0x%02x",                   packet->timestamp,i+1,list->numpackets,miditypename(packet->data[0]),packet->data[0],packet->data[1],packet->data[2]);         }          packet = midipacketnext (packet);     } }  - (id)init{     osstatus result;      self = [super init];     if (self) {         // create client         result = midiclientcreate(cfstr("myvirtualclient"), null, null, &client);         if (result !=0) nslog(@"midiclientcreate error %i",result);         // create destination         result = mididestinationcreate(client, cfstr("myvirtualdestination"), midireadproc,(__bridge void *)(self),&virtualin);         if (result !=0) nslog(@"midiclientcreate error %i",result);         // set uniqueid dont have toggele output in ni maschine         result = midiobjectsetintegerproperty(virtualin, kmidipropertyuniqueid, virtualinuniqueid);         if (result !=0) nslog(@"midiclientcreate error %i",result);      }     return self; }  @end 

extra info put in test in response hints of gene see happens when removing 0xf8 filter , using printf instead of nslog();

output midi monitor: enter image description here

output form code:

enter image description here

no solution clock received same timestamp.

tempo in test set 50 bpm (so 1 clock every 50 ms) checked see if there missing clock pulses isn't case. clocks received approx expected timestamp.

minor comment here. since you're doing this:

const midipacket *packet = &list->packet[0];  // ?defined const avoid compiler warnings? 

this

for (int = 0; < list->numpackets; i++) { 

should be

for (int = 0; < list->numpackets; ++i) { 

but doesn't fix problem. happens when remove filtering "if" (besides getting lots of f8s)? shot in dark: try printf see if nslog no good.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -