cmScore.h/c : Added cmScoreReport(). Added 'section' number to report output.

This commit is contained in:
kevin 2016-09-14 13:47:19 -04:00
parent 1a042843c8
commit bd63a0eeeb
2 changed files with 35 additions and 7 deletions

View File

@ -2417,6 +2417,16 @@ cmScRC_t cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* m)
return kOkScRC; return kOkScRC;
} }
const cmChar_t* _cmScoreSectionLabel( cmSc_t* p, const cmScoreEvt_t* r )
{
unsigned i;
for(i=0; i<p->sectCnt; ++i)
if( p->sect[i].locPtr != NULL && p->sect[i].locPtr->index == r->locIdx && p->sect[i].begEvtIndex == r->index )
return p->sect[i].label;
return NULL;
}
void _cmScorePrintHdr( cmRpt_t* rpt ) void _cmScorePrintHdr( cmRpt_t* rpt )
{ {
cmRptPrintf(rpt,"evnt CSV bar\n"); cmRptPrintf(rpt,"evnt CSV bar\n");
@ -2424,12 +2434,13 @@ void _cmScorePrintHdr( cmRpt_t* rpt )
cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n"); cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n");
} }
void _cmScorePrintEvent( const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt ) void _cmScorePrintEvent( cmSc_t* p, const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
{ {
bool eolFl = true;
switch(r->type) switch(r->type)
{ {
case kBarEvtScId: case kBarEvtScId:
cmRptPrintf(rpt,"%5i %5i %3i bar\n", cmRptPrintf(rpt,"%5i %5i %3i bar ",
i, i,
r->line, r->line,
r->barNumb ); r->barNumb );
@ -2437,7 +2448,7 @@ void _cmScorePrintEvent( const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
case kPedalEvtScId: case kPedalEvtScId:
case kNonEvtScId: case kNonEvtScId:
cmRptPrintf(rpt,"%5i %5i %5i %3i %3i %s %5s %c%c%c %s\n", cmRptPrintf(rpt,"%5i %5i %5i %3i %3i %s %5s %c%c%c %-7s ",
i, i,
r->line, r->line,
r->locIdx, r->locIdx,
@ -2448,13 +2459,21 @@ void _cmScorePrintEvent( const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
cmIsFlag(r->flags,kEvenScFl) ? 'e' : ' ', cmIsFlag(r->flags,kEvenScFl) ? 'e' : ' ',
cmIsFlag(r->flags,kTempoScFl) ? 't' : ' ', cmIsFlag(r->flags,kTempoScFl) ? 't' : ' ',
cmIsFlag(r->flags,kDynScFl) ? 'd' : ' ', cmIsFlag(r->flags,kDynScFl) ? 'd' : ' ',
//cmIsFlag(r->flags,kDynScFl) ? 7-strlen(cmScDynIdToLabel(r->dynVal)) : 7,
cmIsFlag(r->flags,kDynScFl) ? cmScDynIdToLabel(r->dynVal) : ""); cmIsFlag(r->flags,kDynScFl) ? cmScDynIdToLabel(r->dynVal) : "");
break; break;
default: default:
eolFl = false;
break; break;
} }
const cmChar_t* sectionLabel;
if((sectionLabel = _cmScoreSectionLabel(p,r)) != NULL )
cmRptPrintf(rpt,"section:%s ",sectionLabel);
cmRptPrintf(rpt,"\n");
} }
@ -2466,7 +2485,7 @@ void cmScorePrint( cmScH_t h, cmRpt_t* rpt )
_cmScorePrintHdr(rpt); _cmScorePrintHdr(rpt);
for(i=0; i<p->cnt; ++i) for(i=0; i<p->cnt; ++i)
_cmScorePrintEvent(p->array+i,i,rpt); _cmScorePrintEvent(p,p->array+i,i,rpt);
} }
@ -2491,7 +2510,7 @@ void cmScorePrintSets( cmScH_t h, cmRpt_t* rpt )
_cmScorePrintHdr(rpt); _cmScorePrintHdr(rpt);
for(j=0; j<s->eleCnt; ++j) for(j=0; j<s->eleCnt; ++j)
_cmScorePrintEvent(*s->eleArray+j,j,rpt); _cmScorePrintEvent(p,*s->eleArray+j,j,rpt);
cmRptPrintf(rpt,"Targets Section: "); cmRptPrintf(rpt,"Targets Section: ");
for(j=0; j<s->sectCnt; ++j) for(j=0; j<s->sectCnt; ++j)
@ -2717,7 +2736,7 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
} }
void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn ) void cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn )
{ {
cmScH_t h = cmScNullHandle; cmScH_t h = cmScNullHandle;
if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL, cmSymTblNullHandle ) != kOkScRC ) if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL, cmSymTblNullHandle ) != kOkScRC )
@ -2728,6 +2747,11 @@ void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
cmScoreFinalize(&h); cmScoreFinalize(&h);
} }
void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
{
}
// 1. Fix absolute message time which was incorrect on original score file. // 1. Fix absolute message time which was incorrect on original score file.
// 2. // 2.
void cmScoreFix( cmCtx_t* ctx ) void cmScoreFix( cmCtx_t* ctx )

View File

@ -280,6 +280,10 @@ extern "C" {
// Generate a new score file from a MIDI file. // Generate a new score file from a MIDI file.
cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn ); cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn );
// Print open the score file 'fn' and report the contents. This function
// simply wraps calls to cmScoreInitialize() and cmScorePrint().
void cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn );
void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn ); void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn );
//) //)