cmScore.h/c : Added cmScorePrintSets().

This commit is contained in:
Kevin Larke 2016-04-23 15:41:19 -04:00
parent 68e34d29d7
commit 15ee5423c9
2 changed files with 82 additions and 35 deletions

View File

@ -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' ) if((attr = cmCsvCellText(p->cH,rowIdx,kGraceColScIdx)) != NULL && *attr == 'g' )
{ {
flags += kGraceScFl; flags += kGraceScFl;
if( cmIsNotFlag(flags,kEvenScFl) ) //if( cmIsNotFlag(flags,kEvenScFl) )
return cmErrMsg(&p->err,kSyntaxErrScRC,"All 'grace' notes should also be 'even' notes."); // return cmErrMsg(&p->err,kSyntaxErrScRC,"All 'grace' notes should also be 'even' notes.");
} }
// tempo attribute // tempo attribute
@ -1047,10 +1047,10 @@ cmScRC_t _cmScProcSets( cmSc_t* p )
char cc = _cmScVarIdToChar(p->sets[i].varId); char cc = _cmScVarIdToChar(p->sets[i].varId);
int nn = snprintf(NULL,0,"%c-%s",cc,ep->label); int nn = snprintf(NULL,0,"%c-%s",cc,ep->label);
char b[nn+2]; char b[nn+3];
snprintf(b,nn,"%c-%s",cc,ep->label); snprintf(b,nn+1,"%c-%s",cc,ep->label);
p->sets[i].symArray[j] = cmSymTblRegisterSymbol(p->stH,b); 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); 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; 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 ) void cmScorePrint( cmScH_t h, cmRpt_t* rpt )
{ {
cmSc_t* p = _cmScHandleToPtr(h); cmSc_t* p = _cmScHandleToPtr(h);
unsigned i; unsigned i;
cmRptPrintf(rpt,"evnt CSV bar\n"); _cmScorePrintHdr(rpt);
cmRptPrintf(rpt,"index line loctn bar idx type pitch ETD Dynamic\n");
cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n");
for(i=0; i<p->cnt; ++i) for(i=0; i<p->cnt; ++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; i<p->locCnt; ++i)
{ {
cmScoreEvt_t* r = p->array + i; const cmScoreSet_t* s = p->loc[i].setList;
switch(r->type) for(; s!=NULL; s=s->llink)
{ {
case kBarEvtScId: char cc = _cmScVarIdToChar(s->varId);
cmRptPrintf(rpt,"%5i %5i %3i bar\n",
i,
r->line,
r->barNumb );
break;
case kNonEvtScId: cmRptPrintf(rpt,"\n%i Set:%c\n",k,cc);
cmRptPrintf(rpt,"%5i %5i %5i %3i %3i %s %5s %c%c%c %s\n", ++k;
i,
r->line, _cmScorePrintHdr(rpt);
r->locIdx, for(j=0; j<s->eleCnt; ++j)
r->barNumb, _cmScorePrintEvent(*s->eleArray+j,j,rpt);
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: cmRptPrintf(rpt,"Targets Section: ");
break; for(j=0; j<s->sectCnt; ++j)
cmRptPrintf(rpt,"%s ",s->sectArray[j]->label);
cmRptPrintf(rpt,"\n");
cmRptPrintf(rpt,"Variables: ");
for(j=0; j<s->sectCnt; ++j)
cmRptPrintf(rpt,"%s ",cmSymTblLabel(p->stH,s->symArray[j]));
for(j=0; j<s->sectCnt; ++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 cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* scoreFn )
{ {
cmScRC_t rc = kOkScRC; cmScRC_t rc = kOkScRC;

View File

@ -271,6 +271,7 @@ extern "C" {
cmScRC_t cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* ); cmScRC_t cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* );
void cmScorePrint( cmScH_t h, cmRpt_t* rpt ); 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. // 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 );