From 1b2054bf10abe6e40cf94bc27a862a04a8467d96 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 21 Sep 2016 19:16:54 -0400 Subject: [PATCH 1/2] cmScoreMatchGraphic.c : Changed score0.css to cmScoreMatchGraphic.css. --- app/cmScoreMatchGraphic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/cmScoreMatchGraphic.c b/app/cmScoreMatchGraphic.c index 79799fb..b013c97 100644 --- a/app/cmScoreMatchGraphic.c +++ b/app/cmScoreMatchGraphic.c @@ -538,7 +538,7 @@ cmSmgRC_t cmScoreMatchGraphicWrite( cmSmgH_t h, const cmChar_t* fn ) svgHeight += 10; // add a right and lower border svgWidth += 10; - cmFilePrintf(fH,"\n\n\n\n",svgWidth,svgHeight); + cmFilePrintf(fH,"\n\n\n\n",svgWidth,svgHeight); for(i=0; ilocN; ++i) { From 5272aaeb52a1b13235160ea6c018350df2318da4 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 21 Sep 2016 19:18:01 -0400 Subject: [PATCH 2/2] cmXScore.h/c : Added cmXScoreGenEditFile(). --- app/cmXScore.c | 80 +++++++++++++++++++++++++++++++++++++------------- app/cmXScore.h | 2 ++ 2 files changed, 62 insertions(+), 20 deletions(-) diff --git a/app/cmXScore.c b/app/cmXScore.c index d0e9c68..c94ddab 100644 --- a/app/cmXScore.c +++ b/app/cmXScore.c @@ -71,14 +71,15 @@ enum struct cmXsMeas_str; struct cmXsVoice_str; +// Values measured for each sounding note in the preceding time window.... typedef struct cmXsComplexity_str { - unsigned sum_d_vel; - unsigned sum_d_rym; - unsigned sum_d_lpch; - unsigned sum_n_lpch; - unsigned sum_d_rpch; - unsigned sum_n_rpch; + unsigned sum_d_vel; // sum of first order difference of cmXsNote_t.dynamics + unsigned sum_d_rym; // sum of first order difference of cmXsNote_t.rvalue + unsigned sum_d_lpch; // sum of first order difference of cmXsNote_t.pitch of note assigned to the bass cleff + unsigned sum_n_lpch; // count of notes assigned to the bass cleff + unsigned sum_d_rpch; // sum of first order difference of cmXsNote_t.pitch of note assigned to the treble cleff + unsigned sum_n_rpch; // count of notes assigned to the treble cleff } cmXsComplexity_t; typedef struct cmXsNote_str @@ -2011,8 +2012,8 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t* if( cmIsFlag(rV[i].newFlags,kTieEndXsFl) ) { rV[i].note->flags |= kTieEndXsFl; - rV[i].note->flags = cmClrFlag(rV[i].note->flags, kOnsetXsFl); - rV[i].newFlags = cmClrFlag(rV[i].newFlags,kTieEndXsFl ); + rV[i].note->flags = cmClrFlag( rV[i].note->flags, kOnsetXsFl ); + rV[i].newFlags = cmClrFlag( rV[i].newFlags, kTieEndXsFl); } // if a new note value was specified @@ -2032,7 +2033,6 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t* { if( rV[i].newFlags != 0 ) { - if( cmIsFlag(rV[i].newFlags,kDampDnXsFl ) ) _cmXScoreInsertPedalEvent(p,rV + i,kDampDnXsFl); @@ -2043,8 +2043,7 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t* _cmXScoreInsertPedalEvent(p,rV + i,kDampUpXsFl); 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; } + cmXsRC_t _cmXScoreWriteCsvBlankCols( cmXScore_t* p, unsigned cnt, cmCsvCell_t** leftCellPtrPtr ) { 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 { unsigned ival; @@ -3376,13 +3417,13 @@ cmXsRC_t _cmXsWriteMidiFile( cmCtx_t* ctx, cmXsH_t h, const cmChar_t* dir, const typedef struct cmXsSvgEvt_str { - unsigned flags; // k???XsFl - unsigned tick; // start tick - unsigned durTicks; // dur-ticks - unsigned voice; // score voice number - unsigned d0; // MIDI d0 (barNumb) - unsigned d1; // MIDI d1 - cmXsComplexity_t cplx; + unsigned flags; // k???XsFl + unsigned tick; // start tick + unsigned durTicks; // dur-ticks + unsigned voice; // score voice number + unsigned d0; // MIDI d0 (barNumb) + unsigned d1; // MIDI d1 + cmXsComplexity_t cplx; struct cmXsSvgEvt_str* link; } cmXsSvgEvt_t; @@ -3638,8 +3679,7 @@ cmXsRC_t _cmXScoreGenSvg( cmCtx_t* ctx, cmXsH_t h, const cmChar_t* dir, const cm } } } - - + return _cmXsWriteMidiSvg( ctx, p, &mf, dir, fn ); } diff --git a/app/cmXScore.h b/app/cmXScore.h index 3b28c25..a47cfa1 100644 --- a/app/cmXScore.h +++ b/app/cmXScore.h @@ -58,6 +58,8 @@ extern "C" { 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. cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn );