cmProc4.h/c : Added comments to the score follower.

This commit is contained in:
Kevin Larke 2015-02-09 10:13:47 -08:00
parent 88d5d9a499
commit 0b46711fd8
2 changed files with 25 additions and 13 deletions

View File

@ -2363,7 +2363,8 @@ void cmScMatcherPrint( cmScMatcher* p )
unsigned esli = 0; unsigned esli = 0;
unsigned i,j,k; unsigned i,j,k;
// get first/last scLocIdx from res[] // get first/last scLocIdx from res[] - this is the range of
// score events that the score matcher has identified
for(i=0; i<p->ri; ++i) for(i=0; i<p->ri; ++i)
if( p->res[i].locIdx != cmInvalidIdx ) if( p->res[i].locIdx != cmInvalidIdx )
{ {
@ -2382,15 +2383,16 @@ void cmScMatcherPrint( cmScMatcher* p )
aan += lp->evtCnt; aan += lp->evtCnt;
} }
// allocate an array off 'aan' print records // allocate an array of 'aan' print records
cmScMatcherPrint_t* a = cmMemAllocZ(cmScMatcherPrint_t,aan); cmScMatcherPrint_t* a = cmMemAllocZ(cmScMatcherPrint_t,aan);
// fill a[] note and bar events from cmScoreLoc() // fill the cmScMatcherPrint_t array with note and bar events from the score
for(i=bsli; i<=esli; ++i) for(i=bsli; i<=esli; ++i)
{ {
unsigned scLocIdx = i; unsigned scLocIdx = i;
cmScoreLoc_t* lp = cmScoreLoc(p->mp->scH, scLocIdx ); cmScoreLoc_t* lp = cmScoreLoc(p->mp->scH, scLocIdx );
// for each score event which occurs at this location
for(j=0; j<lp->evtCnt; ++j) for(j=0; j<lp->evtCnt; ++j)
{ {
assert( an < aan ); assert( an < aan );
@ -2400,6 +2402,7 @@ void cmScMatcherPrint( cmScMatcher* p )
an += 1; an += 1;
switch( ep->type ) switch( ep->type )
{ {
case kBarEvtScId: case kBarEvtScId:
@ -2420,6 +2423,12 @@ void cmScMatcherPrint( cmScMatcher* p )
} }
//
// a[an] now contains a record for each note and bar event in the
// time range associated with the score matcher's result array.
//
// for each result record // for each result record
for(i=0; i<p->ri; ++i) for(i=0; i<p->ri; ++i)
{ {
@ -2428,7 +2437,7 @@ void cmScMatcherPrint( cmScMatcher* p )
// if this result recd matched a score event // if this result recd matched a score event
if( cmIsFlag(rp->flags,kSmTruePosFl) ) if( cmIsFlag(rp->flags,kSmTruePosFl) )
{ {
// locate the matching score event // locate the matching score event in a[an]
for(k=0; k<an; ++k) for(k=0; k<an; ++k)
if( a[k].scLocIdx==p->mp->loc[rp->locIdx].scLocIdx && a[k].pitch==rp->pitch ) if( a[k].scLocIdx==p->mp->loc[rp->locIdx].scLocIdx && a[k].pitch==rp->pitch )
{ {
@ -2512,6 +2521,9 @@ void cmScMatcherPrint( cmScMatcher* p )
} }
} }
printf("sloc bar mni ptch flag\n");
printf("---- ---- ---- ---- ----\n");
for(i=0; i<an; ++i) for(i=0; i<an; ++i)
{ {
printf("%4i %4i %4i %4s %c%c%c\n",a[i].scLocIdx,a[i].barNumb,a[i].mni, printf("%4i %4i %4i %4s %c%c%c\n",a[i].scLocIdx,a[i].barNumb,a[i].mni,

View File

@ -244,7 +244,7 @@ extern "C" {
// Score location record. // Score location record.
typedef struct typedef struct
{ {
unsigned evtCnt; // unsigned evtCnt; // count of score events at this location (i.e. a chord will have more than one event at a given location)
cmScMatchEvt_t* evtV; // evtV[evtCnt] cmScMatchEvt_t* evtV; // evtV[evtCnt]
unsigned scLocIdx; // scH score location index unsigned scLocIdx; // scH score location index
int barNumb; // bar number of this location int barNumb; // bar number of this location
@ -312,13 +312,13 @@ extern "C" {
typedef struct typedef struct
{ {
unsigned locIdx; unsigned locIdx; // index into cmScMatch_t.loc[]
unsigned scEvtIdx; unsigned scEvtIdx; // score event index
unsigned mni; unsigned mni; // index of the performed MIDI event associated with this score location
unsigned smpIdx; unsigned smpIdx; // sample time index of performed MIDI event
unsigned pitch; unsigned pitch; // performed pitch
unsigned vel; unsigned vel; // performed velocity
unsigned flags; unsigned flags; // smTruePosFl | smFalsePosFl
} cmScMatcherResult_t; } cmScMatcherResult_t;
struct cmScMatcher_str; struct cmScMatcher_str;
@ -380,7 +380,7 @@ extern "C" {
cmRC_t cmScMatcherReset( cmScMatcher* p, unsigned scLocIdx ); cmRC_t cmScMatcherReset( cmScMatcher* p, unsigned scLocIdx );
// Slide a score window 'hopCnt' times, beginning at 'bli' (an // Slide a score window 'hopCnt' times, beginning at 'bli' (an
// index int p->mp->loc[]) looking for the best match to p->midiBuf[]. // index into p->mp->loc[]) looking for the best match to p->midiBuf[].
// The score window contain scWndN (p->mp->mcn-1) score locations. // The score window contain scWndN (p->mp->mcn-1) score locations.
// Returns the index into p->mp->loc[] of the start of the best // Returns the index into p->mp->loc[] of the start of the best
// match score window. The score associated // match score window. The score associated