From 15ee5423c95af573146f8ce9838ad178d0b5c814 Mon Sep 17 00:00:00 2001 From: Kevin Larke Date: Sat, 23 Apr 2016 15:41:19 -0400 Subject: [PATCH] cmScore.h/c : Added cmScorePrintSets(). --- app/cmScore.c | 116 +++++++++++++++++++++++++++++++++++--------------- app/cmScore.h | 1 + 2 files changed, 82 insertions(+), 35 deletions(-) diff --git a/app/cmScore.c b/app/cmScore.c index e559e34..c1566c7 100644 --- a/app/cmScore.c +++ b/app/cmScore.c @@ -761,8 +761,8 @@ cmScRC_t _cmScParseNoteOn( cmSc_t* p, unsigned rowIdx, cmScoreEvt_t* s, unsigned if((attr = cmCsvCellText(p->cH,rowIdx,kGraceColScIdx)) != NULL && *attr == 'g' ) { flags += kGraceScFl; - if( cmIsNotFlag(flags,kEvenScFl) ) - return cmErrMsg(&p->err,kSyntaxErrScRC,"All 'grace' notes should also be 'even' notes."); + //if( cmIsNotFlag(flags,kEvenScFl) ) + // return cmErrMsg(&p->err,kSyntaxErrScRC,"All 'grace' notes should also be 'even' notes."); } // tempo attribute @@ -1047,10 +1047,10 @@ cmScRC_t _cmScProcSets( cmSc_t* p ) char cc = _cmScVarIdToChar(p->sets[i].varId); int nn = snprintf(NULL,0,"%c-%s",cc,ep->label); - char b[nn+2]; - snprintf(b,nn,"%c-%s",cc,ep->label); + char b[nn+3]; + snprintf(b,nn+1,"%c-%s",cc,ep->label); p->sets[i].symArray[j] = cmSymTblRegisterSymbol(p->stH,b); - snprintf(b,nn+1,"c%c-%s",cc,ep->label); + snprintf(b,nn+2,"c%c-%s",cc,ep->label); p->sets[i].costSymArray[j] = cmSymTblRegisterSymbol(p->stH,b); @@ -2386,50 +2386,96 @@ cmScRC_t cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* m) return kOkScRC; } +void _cmScorePrintHdr( cmRpt_t* rpt ) +{ + cmRptPrintf(rpt,"evnt CSV bar\n"); + cmRptPrintf(rpt,"index line loctn bar idx type pitch ETD Dynamic\n"); + cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n"); +} + +void _cmScorePrintEvent( const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt ) +{ + switch(r->type) + { + case kBarEvtScId: + cmRptPrintf(rpt,"%5i %5i %3i bar\n", + i, + r->line, + r->barNumb ); + break; + + case kNonEvtScId: + cmRptPrintf(rpt,"%5i %5i %5i %3i %3i %s %5s %c%c%c %s\n", + i, + r->line, + r->locIdx, + r->barNumb, + r->barNoteIdx, + cmScEvtTypeIdToLabel(r->type), + cmMidiToSciPitch(r->pitch,NULL,0), + cmIsFlag(r->flags,kEvenScFl) ? 'e' : ' ', + cmIsFlag(r->flags,kTempoScFl) ? 't' : ' ', + cmIsFlag(r->flags,kDynScFl) ? 'd' : ' ', + cmIsFlag(r->flags,kDynScFl) ? cmScDynIdToLabel(r->dynVal) : ""); + break; + + default: + break; + } + +} + void cmScorePrint( cmScH_t h, cmRpt_t* rpt ) { cmSc_t* p = _cmScHandleToPtr(h); unsigned i; - - cmRptPrintf(rpt,"evnt CSV bar\n"); - cmRptPrintf(rpt,"index line loctn bar idx type pitch ETD Dynamic\n"); - cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n"); - + + _cmScorePrintHdr(rpt); + for(i=0; icnt; ++i) + _cmScorePrintEvent(p->array+i,i,rpt); +} + + +void cmScorePrintSets( cmScH_t h, cmRpt_t* rpt ) +{ + cmSc_t* p = _cmScHandleToPtr(h); + unsigned i,j,k; + + + for(i=0,k=0; ilocCnt; ++i) { - cmScoreEvt_t* r = p->array + i; - switch(r->type) + const cmScoreSet_t* s = p->loc[i].setList; + for(; s!=NULL; s=s->llink) { - case kBarEvtScId: - cmRptPrintf(rpt,"%5i %5i %3i bar\n", - i, - r->line, - r->barNumb ); - break; + char cc = _cmScVarIdToChar(s->varId); - case kNonEvtScId: - cmRptPrintf(rpt,"%5i %5i %5i %3i %3i %s %5s %c%c%c %s\n", - i, - r->line, - r->locIdx, - r->barNumb, - r->barNoteIdx, - cmScEvtTypeIdToLabel(r->type), - cmMidiToSciPitch(r->pitch,NULL,0), - cmIsFlag(r->flags,kEvenScFl) ? 'e' : ' ', - cmIsFlag(r->flags,kTempoScFl) ? 't' : ' ', - cmIsFlag(r->flags,kDynScFl) ? 'd' : ' ', - cmIsFlag(r->flags,kDynScFl) ? cmScDynIdToLabel(r->dynVal) : ""); - break; + cmRptPrintf(rpt,"\n%i Set:%c\n",k,cc); + ++k; + + _cmScorePrintHdr(rpt); + for(j=0; jeleCnt; ++j) + _cmScorePrintEvent(*s->eleArray+j,j,rpt); - default: - break; + cmRptPrintf(rpt,"Targets Section: "); + for(j=0; jsectCnt; ++j) + cmRptPrintf(rpt,"%s ",s->sectArray[j]->label); + cmRptPrintf(rpt,"\n"); + + + cmRptPrintf(rpt,"Variables: "); + for(j=0; jsectCnt; ++j) + cmRptPrintf(rpt,"%s ",cmSymTblLabel(p->stH,s->symArray[j])); + + for(j=0; jsectCnt; ++j) + cmRptPrintf(rpt,cmSymTblLabel(p->stH,s->costSymArray[j])); + cmRptPrintf(rpt,"\n"); + } } } - cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn ) { cmScRC_t rc = kOkScRC; diff --git a/app/cmScore.h b/app/cmScore.h index 87aa98d..d8cda18 100644 --- a/app/cmScore.h +++ b/app/cmScore.h @@ -271,6 +271,7 @@ extern "C" { cmScRC_t cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* ); void cmScorePrint( cmScH_t h, cmRpt_t* rpt ); + void cmScorePrintSets( cmScH_t h, cmRpt_t* rpt ); // Generate a new score file from a MIDI file. cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn );