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,19 +2386,15 @@ cmScRC_t cmScoreDecode( const void* msg, unsigned msgByteCnt, cmScMsg_t* m)
return kOkScRC; return kOkScRC;
} }
void _cmScorePrintHdr( cmRpt_t* rpt )
void cmScorePrint( cmScH_t h, cmRpt_t* rpt )
{ {
cmSc_t* p = _cmScHandleToPtr(h);
unsigned i;
cmRptPrintf(rpt,"evnt CSV bar\n"); cmRptPrintf(rpt,"evnt CSV bar\n");
cmRptPrintf(rpt,"index line loctn bar idx type pitch ETD Dynamic\n"); cmRptPrintf(rpt,"index line loctn bar idx type pitch ETD Dynamic\n");
cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n"); cmRptPrintf(rpt,"----- ----- ----- --- --- ----- ----- --- -------\n");
}
for(i=0; i<p->cnt; ++i) void _cmScorePrintEvent( const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
{ {
cmScoreEvt_t* r = p->array + i;
switch(r->type) switch(r->type)
{ {
case kBarEvtScId: case kBarEvtScId:
@ -2426,10 +2422,60 @@ void cmScorePrint( cmScH_t h, cmRpt_t* rpt )
default: default:
break; break;
} }
}
} }
void cmScorePrint( cmScH_t h, cmRpt_t* rpt )
{
cmSc_t* p = _cmScHandleToPtr(h);
unsigned i;
_cmScorePrintHdr(rpt);
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)
{
const cmScoreSet_t* s = p->loc[i].setList;
for(; s!=NULL; s=s->llink)
{
char cc = _cmScVarIdToChar(s->varId);
cmRptPrintf(rpt,"\n%i Set:%c\n",k,cc);
++k;
_cmScorePrintHdr(rpt);
for(j=0; j<s->eleCnt; ++j)
_cmScorePrintEvent(*s->eleArray+j,j,rpt);
cmRptPrintf(rpt,"Targets Section: ");
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 );