Browse Source

cmProc4.h/c : The cmMidiTrackMsg_t.uid identifier of note-on messages

fed to cmScMatcher are now tracked along with the note.  This allows score events
to be definitevly matched to a particular note-on event when the event
comes from a MIDI file.
master
Kevin Larke 9 years ago
parent
commit
cf8c6af27f
2 changed files with 10 additions and 5 deletions
  1. 5
    4
      cmProc4.c
  2. 5
    1
      cmProc4.h

+ 5
- 4
cmProc4.c View File

1275
   return cmOkRC;
1275
   return cmOkRC;
1276
 }
1276
 }
1277
 
1277
 
1278
-bool cmScMatcherInputMidi(  cmScMatcher* p, unsigned smpIdx, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1 )
1278
+bool cmScMatcherInputMidi(  cmScMatcher* p, unsigned smpIdx, unsigned muid, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1 )
1279
 {
1279
 {
1280
   if( (status&0xf0) != kNoteOnMdId)
1280
   if( (status&0xf0) != kNoteOnMdId)
1281
     return false;
1281
     return false;
1293
   p->midiBuf[mi].scEvtIdx = cmInvalidIdx;
1293
   p->midiBuf[mi].scEvtIdx = cmInvalidIdx;
1294
   p->midiBuf[mi].mni      = p->mni++;
1294
   p->midiBuf[mi].mni      = p->mni++;
1295
   p->midiBuf[mi].smpIdx   = smpIdx;
1295
   p->midiBuf[mi].smpIdx   = smpIdx;
1296
+  p->midiBuf[mi].muid     = muid;
1296
   p->midiBuf[mi].pitch    = d0;
1297
   p->midiBuf[mi].pitch    = d0;
1297
   p->midiBuf[mi].vel      = d1;
1298
   p->midiBuf[mi].vel      = d1;
1298
   if( p->mbi > 0 )
1299
   if( p->mbi > 0 )
1503
   return cmOkRC;
1504
   return cmOkRC;
1504
 }
1505
 }
1505
 
1506
 
1506
-cmRC_t     cmScMatcherExec(  cmScMatcher* p, unsigned smpIdx, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* scLocIdxPtr )
1507
+cmRC_t     cmScMatcherExec(  cmScMatcher* p, unsigned smpIdx, unsigned muid, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* scLocIdxPtr )
1507
 {
1508
 {
1508
   bool     fl  = p->mbi > 0;
1509
   bool     fl  = p->mbi > 0;
1509
   cmRC_t   rc  = cmOkRC;
1510
   cmRC_t   rc  = cmOkRC;
1513
     *scLocIdxPtr = cmInvalidIdx;
1514
     *scLocIdxPtr = cmInvalidIdx;
1514
 
1515
 
1515
   // update the MIDI buffer with the incoming note
1516
   // update the MIDI buffer with the incoming note
1516
-  if( cmScMatcherInputMidi(p,smpIdx,status,d0,d1) == false )
1517
+  if( cmScMatcherInputMidi(p,smpIdx,muid,status,d0,d1) == false )
1517
     return rc;
1518
     return rc;
1518
 
1519
 
1519
   // if the MIDI buffer transitioned to full then perform an initial scan sync.
1520
   // if the MIDI buffer transitioned to full then perform an initial scan sync.
2485
     // if the time line MIDI msg a note-on
2486
     // if the time line MIDI msg a note-on
2486
     if( (mep->msg->status&0xf0) == kNoteOnMdId )
2487
     if( (mep->msg->status&0xf0) == kNoteOnMdId )
2487
     {
2488
     {
2488
-      rc = cmScMatcherExec(p, mep->obj.seqSmpIdx, mep->msg->status, mep->msg->u.chMsgPtr->d0, mep->msg->u.chMsgPtr->d1, NULL );
2489
+      rc = cmScMatcherExec(p, mep->obj.seqSmpIdx, mep->msg->uid, mep->msg->status, mep->msg->u.chMsgPtr->d0, mep->msg->u.chMsgPtr->d1, NULL );
2489
 
2490
 
2490
       switch( rc )
2491
       switch( rc )
2491
       {
2492
       {

+ 5
- 1
cmProc4.h View File

145
   typedef struct
145
   typedef struct
146
   {
146
   {
147
     unsigned mni;    // unique identifier for this MIDI note - used to recognize when the cmScMatcher backtracks.
147
     unsigned mni;    // unique identifier for this MIDI note - used to recognize when the cmScMatcher backtracks.
148
+    unsigned muid;   // MIDI file event msg unique id (See cmMidiTrackMsg_t.uid)
148
     unsigned smpIdx; // time stamp of this event
149
     unsigned smpIdx; // time stamp of this event
149
     unsigned pitch;  // MIDI note pitch
150
     unsigned pitch;  // MIDI note pitch
150
     unsigned vel;    //  "    "   velocity
151
     unsigned vel;    //  "    "   velocity
208
     unsigned scEvtIdx;  // score event index 
209
     unsigned scEvtIdx;  // score event index 
209
     unsigned mni;       // index of the performed MIDI event associated with this score location
210
     unsigned mni;       // index of the performed MIDI event associated with this score location
210
     unsigned smpIdx;    // sample time index of performed MIDI event
211
     unsigned smpIdx;    // sample time index of performed MIDI event
212
+    unsigned muid;      // MIDI file event msg unique id (See cmMidiTrackMsg_t.uid)
211
     unsigned pitch;     // performed pitch 
213
     unsigned pitch;     // performed pitch 
212
     unsigned vel;       // performed velocity
214
     unsigned vel;       // performed velocity
213
     unsigned flags;     // smTruePosFl | smFalsePosFl 
215
     unsigned flags;     // smTruePosFl | smFalsePosFl 
297
   // will be set with the matched scLocIdx of the match.
299
   // will be set with the matched scLocIdx of the match.
298
   // If this call does not result in a successful match *scLocIdxPtr is set
300
   // If this call does not result in a successful match *scLocIdxPtr is set
299
   // to cmInvalidIdx.
301
   // to cmInvalidIdx.
302
+  // 'muid' is the unique id associated with this MIDI event under the circumstances
303
+  // that the event came from a MIDI file.  See cmMidiFile.h cmMidiTrackMsg_t.uid.
300
   // Return:
304
   // Return:
301
   // cmOkRC  - Continue processing MIDI events.
305
   // cmOkRC  - Continue processing MIDI events.
302
   // cmEofRC - The end of the score was encountered.
306
   // cmEofRC - The end of the score was encountered.
303
   // cmInvalidArgRC - scan failed or the object was in an invalid state to attempt a match.
307
   // cmInvalidArgRC - scan failed or the object was in an invalid state to attempt a match.
304
   // cmSubSysFailRC - a scan resync failed in cmScMatcherStep().
308
   // cmSubSysFailRC - a scan resync failed in cmScMatcherStep().
305
-  cmRC_t     cmScMatcherExec(  cmScMatcher* p, unsigned smpIdx, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* scLocIdxPtr );
309
+  cmRC_t     cmScMatcherExec(  cmScMatcher* p, unsigned smpIdx, unsigned muid, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* scLocIdxPtr );
306
 
310
 
307
   void cmScMatcherPrint( cmScMatcher* p );
311
   void cmScMatcherPrint( cmScMatcher* p );
308
 
312
 

Loading…
Cancel
Save