[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] Re: sc_coremidi bug




On Mar 2, 2006, at 10:29 AM, Chris Brown wrote:

Sorry I can't help with alleviating  this process, but thought I'd point out that this bugger's still not working properly.   Events with exact  same input time are now received, but not differentiated properly.  For example, two notes received at exactly the same time now have the same note numbers and velocities.

this was the problem i had before james committed the fix. 
when was your last update? was it a clean one?


now i have this and it works fine (i think it's the same as what james had committed)

tom


static void midiProcessPacket(MIDIPacket *pkt, int uid)
{
 //jt
    if(pkt) {
     pthread_mutex_lock (&gLangMutex); //dont know if this is really needed/seems to be more stable..
// it is needed  -jamesmcc
if (compiledOK) {
VMGlobals *g = gMainVMGlobals;


  uint8 i = 0;
  while (i < pkt->length) {
  uint8 status = pkt->data[i] & 0xF0;
  uint8 chan = pkt->data[i] & 0x0F;
  g->canCallOS = false; // cannot call the OS

 

  ++g->sp; SetObject(g->sp, s_midiin->u.classobj); // Set the class MIDIIn
  //set arguments: 
  ++g->sp;SetInt(g->sp,  uid); //src
  // ++g->sp;  SetInt(g->sp, status); //status
  ++g->sp;  SetInt(g->sp, chan); //chan
  switch (status) {
  case 0x80 : //noteOff
  ++g->sp; SetInt(g->sp,  pkt->data[i + 1]); //val1
  ++g->sp; SetInt(g->sp,  pkt->data[i + 2]); //val2
  runInterpreter(g, s_midiNoteOffAction, 5);
  i += 3;
  break;
  case 0x90 : //noteOn 
  ++g->sp; SetInt(g->sp,  pkt->data[i + 1]); //val1
  ++g->sp; SetInt(g->sp,  pkt->data[i + 2]); //val2
  runInterpreter(g, pkt->data[i + 2] ? s_midiNoteOnAction : s_midiNoteOffAction, 5);
  i += 3;
  break;
  case 0xA0 : //polytouch
  ++g->sp; SetInt(g->sp,  pkt->data[i + 1]); //val1
  ++g->sp; SetInt(g->sp,  pkt->data[i + 2]); //val2
  runInterpreter(g, s_midiPolyTouchAction, 5);
  i += 3;
  break;
  case 0xB0 : //control
  ++g->sp; SetInt(g->sp,  pkt->data[i + 1]); //val1
  ++g->sp; SetInt(g->sp,  pkt->data[i + 2]); //val2
  runInterpreter(g, s_midiControlAction, 5);
  i += 3;
  break;
  case 0xC0 : //program
  ++g->sp; SetInt(g->sp,  pkt->data[i + 1]); //val1
  runInterpreter(g, s_midiProgramAction, 4);
  i += 2;
  break;
  case 0xD0 : //touch
  ++g->sp; SetInt(g->sp,  pkt->data[i + 1]); //val1
  runInterpreter(g, s_midiTouchAction, 4);
  i += 2;
  break;
  case 0xE0 : //bend
  ++g->sp; SetInt(g->sp,  (pkt->data[i + 2] << 7) | pkt->data[i + 1]); //val1
  runInterpreter(g, s_midiBendAction, 4);
  i += 3;
  break;
  case 0xF0 :
  midiProcessSystemPacket(pkt, chan);
  i += 1;
  break;
  default : // data byte => continuing sysex message
  chan = 0;
  midiProcessSystemPacket(pkt, chan);
  i += 1;
  break;
  }
}
g->canCallOS = false;
}
    pthread_mutex_unlock (&gLangMutex); 
    }
}