cmXScore.h/c : Added cmXScoreGenEditFile().

This commit is contained in:
kevin 2016-09-21 19:18:01 -04:00
parent 1b2054bf10
commit 5272aaeb52
2 changed files with 62 additions and 20 deletions

View File

@ -71,14 +71,15 @@ enum
struct cmXsMeas_str; struct cmXsMeas_str;
struct cmXsVoice_str; struct cmXsVoice_str;
// Values measured for each sounding note in the preceding time window....
typedef struct cmXsComplexity_str typedef struct cmXsComplexity_str
{ {
unsigned sum_d_vel; unsigned sum_d_vel; // sum of first order difference of cmXsNote_t.dynamics
unsigned sum_d_rym; unsigned sum_d_rym; // sum of first order difference of cmXsNote_t.rvalue
unsigned sum_d_lpch; unsigned sum_d_lpch; // sum of first order difference of cmXsNote_t.pitch of note assigned to the bass cleff
unsigned sum_n_lpch; unsigned sum_n_lpch; // count of notes assigned to the bass cleff
unsigned sum_d_rpch; unsigned sum_d_rpch; // sum of first order difference of cmXsNote_t.pitch of note assigned to the treble cleff
unsigned sum_n_rpch; unsigned sum_n_rpch; // count of notes assigned to the treble cleff
} cmXsComplexity_t; } cmXsComplexity_t;
typedef struct cmXsNote_str typedef struct cmXsNote_str
@ -2032,7 +2033,6 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
{ {
if( rV[i].newFlags != 0 ) if( rV[i].newFlags != 0 )
{ {
if( cmIsFlag(rV[i].newFlags,kDampDnXsFl ) ) if( cmIsFlag(rV[i].newFlags,kDampDnXsFl ) )
_cmXScoreInsertPedalEvent(p,rV + i,kDampDnXsFl); _cmXScoreInsertPedalEvent(p,rV + i,kDampDnXsFl);
@ -2044,7 +2044,6 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
if( cmIsFlag(rV[i].newFlags,kSostUpXsFl ) ) if( cmIsFlag(rV[i].newFlags,kSostUpXsFl ) )
_cmXScoreInsertPedalEvent(p,rV + i,kSostUpXsFl); _cmXScoreInsertPedalEvent(p,rV + i,kSostUpXsFl);
} }
} }
@ -2603,6 +2602,7 @@ cmXsRC_t _cmXScoreWriteCsvHdr( cmXScore_t* p )
return kOkXsRC; return kOkXsRC;
} }
cmXsRC_t _cmXScoreWriteCsvBlankCols( cmXScore_t* p, unsigned cnt, cmCsvCell_t** leftCellPtrPtr ) cmXsRC_t _cmXScoreWriteCsvBlankCols( cmXScore_t* p, unsigned cnt, cmCsvCell_t** leftCellPtrPtr )
{ {
unsigned i; unsigned i;
@ -3081,6 +3081,47 @@ void cmXScoreReport( cmXsH_t h, cmRpt_t* rpt, bool sortFl )
} }
} }
void _cmXScoreGenEditFileWrite( void* arg, const cmChar_t* text )
{
if( text != NULL && arg != NULL )
{
cmFileH_t* hp = (cmFileH_t*)arg;
cmFilePrint(*hp,text);
}
}
cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* outFn )
{
cmXsH_t xsH = cmXsNullHandle;
cmFileH_t fH = cmFileNullHandle;
cmXsRC_t rc = kOkXsRC;
cmErr_t err;
cmRpt_t rpt;
cmErrSetup(&err,&ctx->rpt,"cmXScoreGenEditFile");
cmRptSetup(&rpt,_cmXScoreGenEditFileWrite,_cmXScoreGenEditFileWrite,&fH);
if((rc = cmXScoreInitialize(ctx,&xsH,xmlFn,NULL)) != kOkXsRC )
return rc;
if( cmFileOpen(&fH,outFn,kWriteFileFl,&ctx->rpt) != kOkFileRC )
{
cmErrMsg(&err,kFileFailXsRC,"Unable to open the output file '%s'.",cmStringNullGuard(outFn));
goto errLabel;
}
cmXScoreReport(xsH,&rpt,true);
errLabel:
if( cmFileClose(&fH) != kOkFileRC )
rc = cmErrMsg(&err,kFileFailXsRC,"File close failed on '%s'.",cmStringNullGuard(outFn));
cmXScoreFinalize(&xsH);
return rc;
}
typedef struct typedef struct
{ {
unsigned ival; unsigned ival;
@ -3639,7 +3680,6 @@ cmXsRC_t _cmXScoreGenSvg( cmCtx_t* ctx, cmXsH_t h, const cmChar_t* dir, const cm
} }
} }
return _cmXsWriteMidiSvg( ctx, p, &mf, dir, fn ); return _cmXsWriteMidiSvg( ctx, p, &mf, dir, fn );
} }

View File

@ -58,6 +58,8 @@ extern "C" {
void cmXScoreReport( cmXsH_t h, cmRpt_t* rpt, bool sortFl ); void cmXScoreReport( cmXsH_t h, cmRpt_t* rpt, bool sortFl );
cmXsRC_t cmXScoreGenEditFile( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* outFn );
// Generate the CSV file suitable for use by cmScore. // Generate the CSV file suitable for use by cmScore.
cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn ); cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn );