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.
This commit is contained in:
Kevin Larke 2015-02-25 15:17:10 -08:00
parent a7cecdd678
commit cf8c6af27f
2 changed files with 10 additions and 5 deletions

View File

@ -1275,7 +1275,7 @@ cmRC_t cmScMatcherReset( cmScMatcher* p, unsigned scLocIdx )
return cmOkRC;
}
bool cmScMatcherInputMidi( cmScMatcher* p, unsigned smpIdx, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1 )
bool cmScMatcherInputMidi( cmScMatcher* p, unsigned smpIdx, unsigned muid, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1 )
{
if( (status&0xf0) != kNoteOnMdId)
return false;
@ -1293,6 +1293,7 @@ bool cmScMatcherInputMidi( cmScMatcher* p, unsigned smpIdx, unsigned status, cm
p->midiBuf[mi].scEvtIdx = cmInvalidIdx;
p->midiBuf[mi].mni = p->mni++;
p->midiBuf[mi].smpIdx = smpIdx;
p->midiBuf[mi].muid = muid;
p->midiBuf[mi].pitch = d0;
p->midiBuf[mi].vel = d1;
if( p->mbi > 0 )
@ -1503,7 +1504,7 @@ cmRC_t cmScMatcherStep( cmScMatcher* p )
return cmOkRC;
}
cmRC_t cmScMatcherExec( cmScMatcher* p, unsigned smpIdx, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* scLocIdxPtr )
cmRC_t cmScMatcherExec( cmScMatcher* p, unsigned smpIdx, unsigned muid, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* scLocIdxPtr )
{
bool fl = p->mbi > 0;
cmRC_t rc = cmOkRC;
@ -1513,7 +1514,7 @@ cmRC_t cmScMatcherExec( cmScMatcher* p, unsigned smpIdx, unsigned status, c
*scLocIdxPtr = cmInvalidIdx;
// update the MIDI buffer with the incoming note
if( cmScMatcherInputMidi(p,smpIdx,status,d0,d1) == false )
if( cmScMatcherInputMidi(p,smpIdx,muid,status,d0,d1) == false )
return rc;
// if the MIDI buffer transitioned to full then perform an initial scan sync.
@ -2485,7 +2486,7 @@ cmRC_t cmScAlignScanToTimeLineEvent( cmScMatcher* p, cmTlH_t tlH, cmTlObj_t* top
// if the time line MIDI msg a note-on
if( (mep->msg->status&0xf0) == kNoteOnMdId )
{
rc = cmScMatcherExec(p, mep->obj.seqSmpIdx, mep->msg->status, mep->msg->u.chMsgPtr->d0, mep->msg->u.chMsgPtr->d1, NULL );
rc = cmScMatcherExec(p, mep->obj.seqSmpIdx, mep->msg->uid, mep->msg->status, mep->msg->u.chMsgPtr->d0, mep->msg->u.chMsgPtr->d1, NULL );
switch( rc )
{

View File

@ -145,6 +145,7 @@ extern "C" {
typedef struct
{
unsigned mni; // unique identifier for this MIDI note - used to recognize when the cmScMatcher backtracks.
unsigned muid; // MIDI file event msg unique id (See cmMidiTrackMsg_t.uid)
unsigned smpIdx; // time stamp of this event
unsigned pitch; // MIDI note pitch
unsigned vel; // " " velocity
@ -208,6 +209,7 @@ extern "C" {
unsigned scEvtIdx; // score event index
unsigned mni; // index of the performed MIDI event associated with this score location
unsigned smpIdx; // sample time index of performed MIDI event
unsigned muid; // MIDI file event msg unique id (See cmMidiTrackMsg_t.uid)
unsigned pitch; // performed pitch
unsigned vel; // performed velocity
unsigned flags; // smTruePosFl | smFalsePosFl
@ -297,12 +299,14 @@ extern "C" {
// will be set with the matched scLocIdx of the match.
// If this call does not result in a successful match *scLocIdxPtr is set
// to cmInvalidIdx.
// 'muid' is the unique id associated with this MIDI event under the circumstances
// that the event came from a MIDI file. See cmMidiFile.h cmMidiTrackMsg_t.uid.
// Return:
// cmOkRC - Continue processing MIDI events.
// cmEofRC - The end of the score was encountered.
// cmInvalidArgRC - scan failed or the object was in an invalid state to attempt a match.
// cmSubSysFailRC - a scan resync failed in cmScMatcherStep().
cmRC_t cmScMatcherExec( cmScMatcher* p, unsigned smpIdx, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* scLocIdxPtr );
cmRC_t cmScMatcherExec( cmScMatcher* p, unsigned smpIdx, unsigned muid, unsigned status, cmMidiByte_t d0, cmMidiByte_t d1, unsigned* scLocIdxPtr );
void cmScMatcherPrint( cmScMatcher* p );