Many changes to support cmtools.
This commit is contained in:
parent
6240b8f9a8
commit
9d5697d9cd
@ -19,6 +19,7 @@
|
||||
#include "cmFile.h"
|
||||
#include "cmScore.h"
|
||||
#include "cmVectOpsTemplateMain.h"
|
||||
#include "cmRptFile.h"
|
||||
|
||||
cmScH_t cmScNullHandle = cmSTATIC_NULL_HANDLE;
|
||||
|
||||
@ -2441,7 +2442,7 @@ void _cmScorePrintHdr( cmRpt_t* rpt )
|
||||
|
||||
void _cmScorePrintEvent( cmSc_t* p, const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
|
||||
{
|
||||
bool eolFl = true;
|
||||
//bool eolFl = true;
|
||||
switch(r->type)
|
||||
{
|
||||
case kBarEvtScId:
|
||||
@ -2469,7 +2470,7 @@ void _cmScorePrintEvent( cmSc_t* p, const cmScoreEvt_t* r, unsigned i, cmRpt_t*
|
||||
break;
|
||||
|
||||
default:
|
||||
eolFl = false;
|
||||
//eolFl = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2741,15 +2742,27 @@ cmScRC_t cmScoreFileFromMidi( cmCtx_t* ctx, const cmChar_t* midiFn, const c
|
||||
}
|
||||
|
||||
|
||||
void cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn )
|
||||
void cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* outFn )
|
||||
{
|
||||
cmScH_t h = cmScNullHandle;
|
||||
cmScH_t h = cmScNullHandle;
|
||||
cmRptFileH_t fH = cmRptFileNullHandle;
|
||||
cmRpt_t* rpt = &ctx->rpt;
|
||||
|
||||
if( outFn != NULL )
|
||||
if( cmRptFileCreate( ctx, &fH, outFn, NULL ) == kOkRfRC )
|
||||
rpt = cmRptFileRpt( fH );
|
||||
|
||||
|
||||
if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL, cmSymTblNullHandle ) != kOkScRC )
|
||||
return;
|
||||
|
||||
cmScorePrint(h,&ctx->rpt);
|
||||
cmScorePrint(h,rpt);
|
||||
|
||||
cmScoreFinalize(&h);
|
||||
|
||||
if( cmRptFileIsValid( fH ) )
|
||||
cmRptFileClose( &fH );
|
||||
|
||||
}
|
||||
|
||||
void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
|
||||
|
@ -282,7 +282,7 @@ extern "C" {
|
||||
|
||||
// Print open the score file 'fn' and report the contents. This function
|
||||
// simply wraps calls to cmScoreInitialize() and cmScorePrint().
|
||||
void cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn );
|
||||
void cmScoreReport( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* outFn );
|
||||
|
||||
void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn );
|
||||
|
||||
|
@ -339,8 +339,10 @@ typedef struct
|
||||
unsigned _cmSpMeasSectCount( _cmSpMeasProc_t* m )
|
||||
{
|
||||
const _cmSpMeas_t* mp = m->list_beg;
|
||||
unsigned n = 0;
|
||||
for(; mp != NULL; mp=mp->link)
|
||||
unsigned n = 0;
|
||||
unsigned M = 0;
|
||||
|
||||
for(; mp != NULL; mp=mp->link,++M)
|
||||
n += mp->setPtr->sectCnt;
|
||||
|
||||
return n;
|
||||
@ -359,9 +361,10 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, _cmSpMeasProc_t* m, const
|
||||
cmFileH_t fH = cmFileNullHandle;
|
||||
cmSpRC_t rc = kOkSpRC;
|
||||
unsigned i,j,k;
|
||||
unsigned scnt = _cmSpMeasSectCount(m);
|
||||
|
||||
_cmSpMeas_t* mp = m->list_beg;
|
||||
|
||||
unsigned scnt = _cmSpMeasSectCount(m);
|
||||
_cmSpMeasSect_t sarray[ scnt ];
|
||||
for(i=0,k=0; k<scnt && mp!=NULL; ++i,mp=mp->link)
|
||||
{
|
||||
@ -375,24 +378,26 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, _cmSpMeasProc_t* m, const
|
||||
{ assert(0); }
|
||||
}
|
||||
|
||||
|
||||
for(j=0; j<mp->setPtr->sectCnt; ++j,++k)
|
||||
{
|
||||
assert(k<scnt);
|
||||
|
||||
_cmSpMeasSect_t* r = sarray + k;
|
||||
|
||||
r->srcSeqId = mp->markPtr->obj.seqId,
|
||||
r->srcMarkNameStr = cmStringNullGuard(mp->markPtr->obj.name),
|
||||
r->srcTypeId = mp->setPtr->varId,
|
||||
r->srcTypeLabelStr = typeLabel,
|
||||
r->dstScLocIdx = mp->setPtr->sectArray[j]->locPtr->index,
|
||||
r->dstEvtIdx = mp->setPtr->sectArray[j]->begEvtIndex,
|
||||
r->dstSectLabelStr = cmStringNullGuard(mp->setPtr->sectArray[j]->label),
|
||||
r->value = mp->value,
|
||||
r->cost = mp->cost;
|
||||
|
||||
r->srcSeqId = mp->markPtr->obj.seqId;
|
||||
r->srcMarkNameStr = cmStringNullGuard(mp->markPtr->obj.name);
|
||||
r->srcTypeId = mp->setPtr->varId;
|
||||
r->srcTypeLabelStr = typeLabel;
|
||||
r->dstScLocIdx = mp->setPtr->sectArray[j]->locPtr->index;
|
||||
r->dstEvtIdx = mp->setPtr->sectArray[j]->begEvtIndex;
|
||||
r->dstSectLabelStr = cmStringNullGuard(mp->setPtr->sectArray[j]->label);
|
||||
r->value = mp->value;
|
||||
r->cost = mp->cost;
|
||||
}
|
||||
}
|
||||
|
||||
assert(mp==NULL && k==scnt);
|
||||
// assert(mp==NULL && k==scnt); if the ending mp->setPtr->sectCnt==0 then this assert will not work correctly even though there would be no data inconsistency
|
||||
|
||||
qsort(sarray,scnt,sizeof(sarray[0]),_cmSpMeasSectCompare);
|
||||
|
||||
@ -408,39 +413,39 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, _cmSpMeasProc_t* m, const
|
||||
{
|
||||
_cmSpMeasSect_t* r = sarray + i;
|
||||
|
||||
cmFilePrintf(fH,"[ \"%s\" \"%s\" %f %f %i %i %i \"%s\" %i ]\n",
|
||||
r->dstSectLabelStr,
|
||||
r->srcTypeLabelStr,
|
||||
r->value,
|
||||
r->cost,
|
||||
r->dstScLocIdx,
|
||||
r->dstEvtIdx,
|
||||
r->srcSeqId,
|
||||
r->srcMarkNameStr,
|
||||
r->srcTypeId
|
||||
);
|
||||
cmFilePrintf(fH,"[ \"%s\" \"%s\" %f %f %i %i %i \"%s\" %i ]\n",
|
||||
r->dstSectLabelStr,
|
||||
r->srcTypeLabelStr,
|
||||
r->value,
|
||||
r->cost,
|
||||
r->dstScLocIdx,
|
||||
r->dstEvtIdx,
|
||||
r->srcSeqId,
|
||||
r->srcMarkNameStr,
|
||||
r->srcTypeId
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
mp = sp->list_beg;
|
||||
for(; mp!=NULL; mp=mp->link)
|
||||
{
|
||||
mp = sp->list_beg;
|
||||
for(; mp!=NULL; mp=mp->link)
|
||||
{
|
||||
|
||||
for(i=0; i<mp->setPtr->sectCnt; ++i)
|
||||
{
|
||||
cmFilePrintf(fH,"[ %i \"%s\" %i \"%s\" %i %i \"%s\" %f %f ]\n",
|
||||
mp->markPtr->obj.seqId,
|
||||
cmStringNullGuard(mp->markPtr->obj.name),
|
||||
mp->setPtr->varId,
|
||||
typeLabel,
|
||||
mp->setPtr->sectArray[i]->locPtr->index,
|
||||
mp->setPtr->sectArray[i]->begEvtIndex,
|
||||
cmStringNullGuard(mp->setPtr->sectArray[i]->label),
|
||||
mp->value,
|
||||
mp->cost );
|
||||
cmFilePrintf(fH,"[ %i \"%s\" %i \"%s\" %i %i \"%s\" %f %f ]\n",
|
||||
mp->markPtr->obj.seqId,
|
||||
cmStringNullGuard(mp->markPtr->obj.name),
|
||||
mp->setPtr->varId,
|
||||
typeLabel,
|
||||
mp->setPtr->sectArray[i]->locPtr->index,
|
||||
mp->setPtr->sectArray[i]->begEvtIndex,
|
||||
cmStringNullGuard(mp->setPtr->sectArray[i]->label),
|
||||
mp->value,
|
||||
mp->cost );
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
cmFilePrintf(fH,"\n]\n}\n");
|
||||
@ -516,10 +521,10 @@ cmSpRC_t _cmSpProcMeasCb( void* arg, cmSp_t* sp, cmScoreProcSelId_t id, cmTlObj
|
||||
}
|
||||
|
||||
|
||||
cmSpRC_t _cmScoreProcGenAllMeasurementsMain(cmCtx_t* ctx)
|
||||
cmSpRC_t _cmScoreProcGenAllMeasurementsMain(cmCtx_t* ctx, const cmChar_t* pgmRsrcFn, const cmChar_t* outFn)
|
||||
{
|
||||
const cmChar_t* rsrcFn = "/home/kevin/.kc/time_line.js";
|
||||
const cmChar_t* outFn = "/home/kevin/src/cmkc/src/kc/data/meas0.js";
|
||||
//const cmChar_t* rsrcFn = "/home/kevin/.kc/time_line.js";
|
||||
//const cmChar_t* outFn = "/home/kevin/src/cmkc/src/kc/data/meas0.js";
|
||||
|
||||
cmSpRC_t rc = kOkSpRC;
|
||||
_cmSpMeasProc_t* m = cmMemAllocZ(_cmSpMeasProc_t,1);
|
||||
@ -531,7 +536,7 @@ cmSpRC_t _cmScoreProcGenAllMeasurementsMain(cmCtx_t* ctx)
|
||||
cmRptPrintf(&ctx->rpt,"Score Performance Evaluation Start\n");
|
||||
|
||||
// initialize the score processor
|
||||
if((rc = _cmScoreProcInit(ctx,sp,rsrcFn,_cmSpProcMeasCb,_cmSpMatchMeasCb,m)) != kOkSpRC )
|
||||
if((rc = _cmScoreProcInit(ctx,sp,pgmRsrcFn,_cmSpProcMeasCb,_cmSpMatchMeasCb,m)) != kOkSpRC )
|
||||
goto errLabel;
|
||||
|
||||
// allocate the performance evaluation measurement object
|
||||
@ -719,10 +724,10 @@ cmSpRC_t _cmSpProcAssocCb( void* arg, cmSp_t* sp, cmScoreProcSelId_t id, cmTlOb
|
||||
return rc;
|
||||
}
|
||||
|
||||
cmSpRC_t _cmScoreProcGenAssocMain(cmCtx_t* ctx)
|
||||
cmSpRC_t _cmScoreProcGenAssocMain(cmCtx_t* ctx, const cmChar_t* pgmRsrcFn, const cmChar_t* outFn )
|
||||
{
|
||||
const cmChar_t* rsrcFn = "/home/kevin/.kc/time_line.js";
|
||||
const cmChar_t* outFn = "/home/kevin/src/cmkc/src/kc/data/takeSeqBldr0.js";
|
||||
//const cmChar_t* pgmRsrcFn = "/home/kevin/.kc/time_line.js";
|
||||
//const cmChar_t* outFn = "/home/kevin/src/cmkc/src/kc/data/takeSeqBldr0.js";
|
||||
cmSpRC_t rc = kOkSpRC;
|
||||
cmSpAssocProc_t* m = cmMemAllocZ(cmSpAssocProc_t,1);
|
||||
cmSp_t s;
|
||||
@ -749,7 +754,7 @@ cmSpRC_t _cmScoreProcGenAssocMain(cmCtx_t* ctx)
|
||||
}
|
||||
|
||||
// initialize the score processor
|
||||
if((rc = _cmScoreProcInit(ctx,sp,rsrcFn,_cmSpProcAssocCb,_cmSpMatchAssocCb, m)) != kOkSpRC )
|
||||
if((rc = _cmScoreProcInit(ctx,sp,pgmRsrcFn,_cmSpProcAssocCb,_cmSpMatchAssocCb, m)) != kOkSpRC )
|
||||
goto errLabel;
|
||||
|
||||
m->sp = sp;
|
||||
@ -804,12 +809,17 @@ cmSpRC_t _cmScoreProcGenAssocMain(cmCtx_t* ctx)
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
cmSpRC_t cmScoreProc(cmCtx_t* ctx)
|
||||
cmSpRC_t cmScoreProc(cmCtx_t* ctx, const cmChar_t* sel, const cmChar_t* pgmRsrcFn, const cmChar_t* outFn)
|
||||
{
|
||||
cmSpRC_t rc = kOkSpRC;
|
||||
|
||||
//_cmScoreProcGenAllMeasurementsMain(ctx);
|
||||
_cmScoreProcGenAssocMain(ctx);
|
||||
if( strcmp(sel,"meas") == 0 )
|
||||
_cmScoreProcGenAllMeasurementsMain(ctx,pgmRsrcFn,outFn);
|
||||
else
|
||||
if( strcmp(sel,"assoc") == 0 )
|
||||
_cmScoreProcGenAssocMain(ctx,pgmRsrcFn,outFn);
|
||||
else
|
||||
cmErrMsg(&ctx->err,kSelectorFailSpRC,"Unknown selector %s.", cmStringNullGuard(sel));
|
||||
|
||||
return rc;
|
||||
|
||||
|
@ -17,11 +17,12 @@ extern "C" {
|
||||
kTimeLineFailSpRC,
|
||||
kScoreMatchFailSpRC,
|
||||
kFileFailSpRC,
|
||||
kProcFailSpRC
|
||||
kProcFailSpRC,
|
||||
kSelectorFailSpRC
|
||||
};
|
||||
|
||||
|
||||
cmSpRC_t cmScoreProc(cmCtx_t* ctx );
|
||||
cmSpRC_t cmScoreProc(cmCtx_t* ctx, const cmChar_t* sel, const cmChar_t* pgmRsrcFn, const cmChar_t* outFn);
|
||||
|
||||
//)
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "cmFileSys.h"
|
||||
#include "cmTimeLine.h"
|
||||
#include "cmOnset.h"
|
||||
#include "cmRptFile.h"
|
||||
|
||||
// id's used to track the type of a serialized object
|
||||
enum
|
||||
@ -1802,6 +1803,25 @@ cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* pr
|
||||
return cmTimeLineFinalize(&h);
|
||||
}
|
||||
|
||||
cmTlRC_t cmTimeLineReport( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* tlPrefixPath, const cmChar_t* rptFn )
|
||||
{
|
||||
cmTlRC_t rc;
|
||||
cmRptFileH_t rptH = cmRptFileNullHandle;
|
||||
|
||||
if(( rc = cmRptFileCreate(ctx, &rptH, rptFn, NULL )) != kOkRfRC )
|
||||
{
|
||||
rc = cmErrMsg(&ctx->err,kRptFileFailTlRC,"Unable to open the report file: %s\n",cmStringNullGuard(rptFn));
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
rc = cmTimeLinePrintFn(ctx, tlFn, tlPrefixPath, cmRptFileRpt(rptH) );
|
||||
|
||||
errLabel:
|
||||
cmRptFileClose(&rptH);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* jsFn, const cmChar_t* prefixPath )
|
||||
{
|
||||
|
@ -27,7 +27,8 @@ extern "C" {
|
||||
kFinalizeFailTlRC,
|
||||
kInvalidSeqIdTlRC,
|
||||
kOnsetFailTlRC,
|
||||
kAssertFailTlRC
|
||||
kAssertFailTlRC,
|
||||
kRptFileFailTlRC
|
||||
};
|
||||
|
||||
typedef enum
|
||||
@ -217,6 +218,7 @@ extern "C" {
|
||||
|
||||
cmTlRC_t cmTimeLinePrint( cmTlH_t h, cmRpt_t* rpt );
|
||||
cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* prefixPath, cmRpt_t* rpt );
|
||||
cmTlRC_t cmTimeLineReport( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* prefixPath, const cmChar_t* rptFn );
|
||||
|
||||
cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* prefixPath );
|
||||
|
||||
|
@ -3856,19 +3856,19 @@ void _cmXsWriteMidiSvgLinePoint( cmSvgH_t svgH, double x0, double y0, double x1,
|
||||
|
||||
}
|
||||
|
||||
cmXsRC_t _cmXsWriteMidiSvg( cmCtx_t* ctx, cmXScore_t* p, cmXsMidiFile_t* mf, const cmChar_t* dir, const cmChar_t* fn )
|
||||
cmXsRC_t _cmXsWriteMidiSvg( cmCtx_t* ctx, cmXScore_t* p, cmXsMidiFile_t* mf, const cmChar_t* svgFn, bool standAloneFl, bool panZoomFl )
|
||||
{
|
||||
cmXsRC_t rc = kOkXsRC;
|
||||
cmSvgH_t svgH = cmSvgNullHandle;
|
||||
cmXsSvgEvt_t* e = mf->elist;
|
||||
unsigned noteHeight = 10;
|
||||
cmChar_t* fn0 = cmMemAllocStr( fn );
|
||||
const cmChar_t* svgFn = cmFsMakeFn(dir,fn0 = cmTextAppendSS(fn0,"_midi_svg"),"html",NULL);
|
||||
//cmChar_t* fn0 = cmMemAllocStr( fn );
|
||||
//const cmChar_t* svgFn = cmFsMakeFn(dir,fn0 = cmTextAppendSS(fn0,"_midi_svg"),"html",NULL);
|
||||
const cmChar_t* cssFn = cmFsMakeFn(NULL,"score_midi_svg","css",NULL);
|
||||
cmChar_t* t0 = NULL; // temporary dynamic string
|
||||
unsigned i = 0;
|
||||
const cmXsSvgEvt_t* e0 = NULL;
|
||||
cmMemFree(fn0);
|
||||
//cmMemFree(fn0);
|
||||
|
||||
// create the SVG writer
|
||||
if( cmSvgWriterAlloc(ctx,&svgH) != kOkSvgRC )
|
||||
@ -3960,12 +3960,12 @@ cmXsRC_t _cmXsWriteMidiSvg( cmCtx_t* ctx, cmXScore_t* p, cmXsMidiFile_t* mf, con
|
||||
cmErrMsg(&p->err,kSvgFailXsRC,"SVG element insert failed.");
|
||||
|
||||
if( rc == kOkXsRC )
|
||||
if( cmSvgWriterWrite(svgH,cssFn,svgFn) != kOkSvgRC )
|
||||
if( cmSvgWriterWrite(svgH,cssFn,svgFn,standAloneFl, panZoomFl) != kOkSvgRC )
|
||||
rc = cmErrMsg(&p->err,kSvgFailXsRC,"SVG file write to '%s' failed.",cmStringNullGuard(svgFn));
|
||||
|
||||
errLabel:
|
||||
cmSvgWriterFree(&svgH);
|
||||
cmFsFreeFn(svgFn);
|
||||
//cmFsFreeFn(svgFn);
|
||||
cmFsFreeFn(cssFn);
|
||||
cmMemFree(t0);
|
||||
|
||||
@ -4001,7 +4001,7 @@ void _cmXsPushSvgEvent( cmXScore_t* p, cmXsMidiFile_t* mf, unsigned flags, unsig
|
||||
mf->eol = e;
|
||||
}
|
||||
|
||||
cmXsRC_t _cmXScoreGenSvg( cmCtx_t* ctx, cmXsH_t h, int beginMeasNumb, const cmChar_t* dir, const cmChar_t* fn )
|
||||
cmXsRC_t _cmXScoreGenSvg( cmCtx_t* ctx, cmXsH_t h, int beginMeasNumb, const cmChar_t* svgFn, bool standAloneFl, bool panZoomFl )
|
||||
{
|
||||
cmXScore_t* p = _cmXScoreHandleToPtr(h);
|
||||
cmXsPart_t* pp = p->partL;
|
||||
@ -4058,12 +4058,11 @@ cmXsRC_t _cmXScoreGenSvg( cmCtx_t* ctx, cmXsH_t h, int beginMeasNumb, const cmCh
|
||||
_cmXsPushSvgEvent(p,&mf,note->flags,note->tick,note->duration,0,d0,127,NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _cmXsWriteMidiSvg( ctx, p, &mf, dir, fn );
|
||||
return _cmXsWriteMidiSvg( ctx, p, &mf, svgFn, standAloneFl, panZoomFl );
|
||||
}
|
||||
|
||||
|
||||
@ -4073,9 +4072,12 @@ cmXsRC_t cmXScoreTest(
|
||||
const cmChar_t* editFn,
|
||||
const cmChar_t* csvOutFn,
|
||||
const cmChar_t* midiOutFn,
|
||||
const cmChar_t* svgOutFn,
|
||||
bool reportFl,
|
||||
int beginMeasNumb,
|
||||
int beginBPM )
|
||||
int beginBPM,
|
||||
bool standAloneFl,
|
||||
bool panZoomFl )
|
||||
{
|
||||
cmXsRC_t rc;
|
||||
cmXsH_t h = cmXsNullHandle;
|
||||
@ -4113,12 +4115,13 @@ cmXsRC_t cmXScoreTest(
|
||||
|
||||
_cmXsIsMidiFileValid(ctx, h, pp->dirStr, pp->fnStr );
|
||||
|
||||
_cmXScoreGenSvg( ctx, h, beginMeasNumb, pp->dirStr, pp->fnStr );
|
||||
|
||||
cmFsFreePathParts(pp);
|
||||
|
||||
}
|
||||
|
||||
if( svgOutFn != NULL )
|
||||
_cmXScoreGenSvg( ctx, h, beginMeasNumb, svgOutFn, standAloneFl, panZoomFl );
|
||||
|
||||
if(reportFl)
|
||||
cmXScoreReport(h,&ctx->rpt,true);
|
||||
|
||||
|
@ -72,7 +72,7 @@ extern "C" {
|
||||
// Set reportFl to true to print a report of the score following processing.
|
||||
// Set begMeasNumb to the first measure the to be written to the output csv, MIDI and SVG files.
|
||||
// Set begBPM to 0 to use the tempo from the score otherwise set it to the tempo at begMeasNumb.
|
||||
cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn, bool reportFl, int begMeasNumb, int begBPM );
|
||||
cmXsRC_t cmXScoreTest( cmCtx_t* ctx, const cmChar_t* xmlFn, const cmChar_t* reorderFn, const cmChar_t* csvOutFn, const cmChar_t* midiOutFn, const cmChar_t* svgOutFn, bool reportFl, int begMeasNumb, int begBPM, bool svgStandAloneFl, bool svgPanZoomFl );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ cmAbRC_t cmApBufUpdate(
|
||||
n0 = pp->audioFramesCnt;
|
||||
|
||||
cmApSample_t* bpp = ((cmApSample_t*)pp->audioBytesPtr) + j;
|
||||
cmApSample_t* dp = bpp;
|
||||
//cmApSample_t* dp = bpp;
|
||||
bool enaFl = cmIsFlag(cp->fl,kChApFl) && cmIsFlag(cp->fl,kMuteApFl)==false;
|
||||
|
||||
unsigned decrSmpN = 0;
|
||||
@ -625,7 +625,7 @@ cmAbRC_t cmApBufUpdate(
|
||||
else // otherwise copy samples from the output buffer to the packet
|
||||
{
|
||||
const cmApSample_t* sp = enaFl ? cp->b + cp->oi : _cmApBuf.zeroBuf;
|
||||
const cmApSample_t* ep = sp + n0;
|
||||
//const cmApSample_t* ep = sp + n0;
|
||||
|
||||
unsigned pi = cp->oi;
|
||||
cp->oi = _cmApCopyOutSamples( enaFl ? cp->b : _cmApBuf.zeroBuf, op->n, cp->oi, (cmApSample_t*)pp->audioBytesPtr, pp->audioFramesCnt, pp->chCnt, j, op->srateMult, cp->gain, &cp->s0 );
|
||||
@ -1061,8 +1061,8 @@ void cmApBufReport( cmRpt_t* rpt )
|
||||
}
|
||||
|
||||
cmRptPrintf(rpt,"%s - i:%7i o:%7i f:%7i n:%7i err %s:%7i mtr:%5.4f ",
|
||||
j==0?"IN":"OUT",
|
||||
ii,oi,fn,ip->n, (j==0?"over":"under"), ip->faultCnt, mtr);
|
||||
j==0?"IN ":"OUT",
|
||||
ii,oi,fn,ip->n, (j==0?"over ":"under"), ip->faultCnt, mtr);
|
||||
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "cmAudioFile.h"
|
||||
#include "cmMath.h"
|
||||
#include "cmFileSys.h"
|
||||
#include "cmRptFile.h"
|
||||
|
||||
|
||||
// #define _24to32_aif( p ) ((int)( ((p[0]>127?255:0) << 24) + (((int)p[0]) << 16) + (((int)p[1]) <<8) + p[2])) // no-swap equivalent
|
||||
@ -1804,6 +1805,37 @@ cmRC_t cmAudioFileReportFn( const cmChar_t* fn, unsigned frmIdx, unsigned fr
|
||||
return cmAudioFileDelete(&h);
|
||||
}
|
||||
|
||||
cmRC_t cmAudioFileReportInfo( cmCtx_t* ctx, const cmChar_t* audioFn, const cmChar_t* rptFn )
|
||||
{
|
||||
cmRC_t rc = kOkAfRC;
|
||||
cmRptFileH_t rptH = cmRptFileNullHandle;
|
||||
cmAudioFileInfo_t afInfo;
|
||||
memset(&afInfo,0,sizeof(afInfo));
|
||||
cmAudioFileH_t afH = cmAudioFileNewOpen( audioFn, &afInfo, &rc, &ctx->rpt );
|
||||
|
||||
|
||||
if( rc != kOkAfRC )
|
||||
{
|
||||
rc = cmErrMsg(&ctx->err,rc,"Audio file '%s' open failed.",cmStringNullGuard(audioFn));
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
if(( rc = cmRptFileCreate(ctx, &rptH, rptFn, NULL )) != kOkRfRC )
|
||||
{
|
||||
rc = cmErrMsg(&ctx->err,kRptFileFailAfRC,"Unable to open the report file: %s\n",cmStringNullGuard(rptFn));
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
cmAudioFilePrintInfo(&afInfo,cmRptFileRpt(rptH));
|
||||
|
||||
errLabel:
|
||||
cmRptFileClose(&rptH);
|
||||
cmAudioFileDelete(&afH);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
cmRC_t cmAudioFileSetSrate( const cmChar_t* fn, unsigned srate )
|
||||
{
|
||||
cmRC_t rc = kOkAfRC;
|
||||
|
@ -36,6 +36,7 @@ extern "C" {
|
||||
kInvalidFileModeAfRC,
|
||||
kInvalidHandleAfRC,
|
||||
kInvalidChCountAfRC,
|
||||
kRptFileFailAfRC,
|
||||
kUnknownErrAfRC
|
||||
};
|
||||
|
||||
@ -271,6 +272,8 @@ extern "C" {
|
||||
// Print the cmAudioFileInfo_t to a file.
|
||||
void cmAudioFilePrintInfo( const cmAudioFileInfo_t* infoPtr, cmRpt_t* );
|
||||
|
||||
cmRC_t cmAudioFileReportInfo( cmCtx_t* ctx, const cmChar_t* audioFn, const cmChar_t* rptFn );
|
||||
|
||||
// Print the file header information and frmCnt sample values beginning at frame index frmIdx.
|
||||
cmRC_t cmAudioFileReport( cmAudioFileH_t h, cmRpt_t* rpt, unsigned frmIdx, unsigned frmCnt );
|
||||
|
||||
|
23
cmMidiFile.c
23
cmMidiFile.c
@ -1848,7 +1848,22 @@ void _cmMidiFilePrintMsg( cmRpt_t* rpt, const cmMidiTrackMsg_t* tmp )
|
||||
|
||||
if( tmp->status == kMetaStId )
|
||||
{
|
||||
cmRptPrintf(rpt,"%s ", cmMidiMetaStatusToLabel(tmp->metaId));
|
||||
|
||||
switch( tmp->metaId )
|
||||
{
|
||||
case kTempoMdId:
|
||||
cmRptPrintf(rpt,"%s bpm %i", cmMidiMetaStatusToLabel(tmp->metaId),60000000 / tmp->u.iVal);
|
||||
break;
|
||||
|
||||
case kTimeSigMdId:
|
||||
cmRptPrintf(rpt,"%s %i %i", cmMidiMetaStatusToLabel(tmp->metaId), tmp->u.timeSigPtr->num,tmp->u.timeSigPtr->den);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
cmRptPrintf(rpt,"%s ", cmMidiMetaStatusToLabel(tmp->metaId));
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1924,6 +1939,8 @@ cmMidiFileDensity_t* cmMidiFileNoteDensity( cmMidiFileH_t h, unsigned* cntRef )
|
||||
dV[k].uid = msgs[i]->uid;
|
||||
dV[k].amicro = msgs[i]->amicro;
|
||||
|
||||
// count the number of notes occuring in the time window
|
||||
// between this note and one second prior to this note.
|
||||
for(j=i; j>=0; --j)
|
||||
{
|
||||
if( msgs[i]->amicro - msgs[j]->amicro > 1000000 )
|
||||
@ -1979,7 +1996,7 @@ cmMfRC_t cmMidiFileGenPlotFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmCh
|
||||
return rc;
|
||||
}
|
||||
|
||||
cmMfRC_t cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outSvgFn, const cmChar_t* cssFn )
|
||||
cmMfRC_t cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outSvgFn, const cmChar_t* cssFn, bool standAloneFl, bool panZoomFl )
|
||||
{
|
||||
cmMfRC_t rc = kOkMfRC;
|
||||
cmSvgH_t svgH = cmSvgNullHandle;
|
||||
@ -2061,7 +2078,7 @@ cmMfRC_t cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmCha
|
||||
cmMemFree(tx);
|
||||
|
||||
if( rc == kOkMfRC )
|
||||
if( cmSvgWriterWrite(svgH,cssFn,outSvgFn) != kOkSvgRC )
|
||||
if( cmSvgWriterWrite(svgH,cssFn,outSvgFn, standAloneFl, panZoomFl) != kOkSvgRC )
|
||||
rc = cmErrMsg(&ctx->err,kSvgFailMfRC,"SVG file write to '%s' failed.",cmStringNullGuard(outSvgFn));
|
||||
|
||||
|
||||
|
@ -229,7 +229,7 @@ extern "C" {
|
||||
// Generate a piano-roll plot description file which can be displayed with cmXScore.m
|
||||
cmMfRC_t cmMidiFileGenPlotFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outFn );
|
||||
|
||||
cmMfRC_t cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outSvgFn, const cmChar_t* cssFn );
|
||||
cmMfRC_t cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outSvgFn, const cmChar_t* cssFn, bool standAloneFl, bool panZoomFl );
|
||||
|
||||
// Generate a text file reportusing cmMIdiFilePrintMsgs()
|
||||
cmMfRC_t cmMidiFileReport( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outTextFn );
|
||||
|
@ -244,11 +244,12 @@ _cmPoOpt_t* _cmPgmOptWordIdToOptRecd( _cmPo_t* p, const cmChar_t* wordId )
|
||||
cmPoRC_t _cmPgmOptInstall( _cmPo_t* p, unsigned numId, const cmChar_t charId, const cmChar_t* wordId, unsigned cflags, unsigned sflags, unsigned enumId, unsigned cnt, const cmChar_t* helpStr, _cmPoOpt_t** rpp )
|
||||
{
|
||||
// validate the num. id
|
||||
if( cmIsNotFlag(sflags,kEnumPoFl) && _cmPgmOptNumIdToOptRecd(p,numId) != NULL )
|
||||
if( cmIsNotFlag(sflags,kEnumPoFl) && _cmPgmOptNumIdToOptRecd(p,numId) != NULL )
|
||||
return cmErrMsg(&p->err,kDuplicateIdPoRC,"The numeric id '%i' was already used by another parameter.",numId);
|
||||
|
||||
|
||||
// validate the char. id
|
||||
if( _cmPgmOptCharIdToOptRecd(p,charId) != NULL )
|
||||
if(_cmPgmOptCharIdToOptRecd(p,charId) != NULL )
|
||||
return cmErrMsg(&p->err,kDuplicateIdPoRC,"The character id -'%c' was already used by another parameter.",charId);
|
||||
|
||||
// validate the word. id
|
||||
|
@ -3909,7 +3909,7 @@ cmRC_t cmRecdPlayInsertRecord(cmRecdPlay* p, unsigned labelSymId, const
|
||||
return rc;
|
||||
}
|
||||
|
||||
return cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The fragment label symbol id '%i' not found for 'begin record'.",labelSymId);
|
||||
return cmCtxRtCondition( &p->obj, cmInvalidArgRC, "The fragment label symbol id '%i' not found for 'begin record'.",labelSymId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,16 +185,7 @@ void _cmSvgWriterFlipY( cmSvg_t* p, unsigned height )
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
"<script type=\"text/javascript\" src=\"svg-pan-zoom.min.js\"></script>\n"
|
||||
"<script>\n"
|
||||
" var panZoom = null;\n"
|
||||
" function doOnLoad() { panZoom = svgPanZoom(document.querySelector('#mysvg'), { controlIconsEnabled:true } ) }\n"
|
||||
"</script>\n"
|
||||
|
||||
*/
|
||||
|
||||
cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* outFn )
|
||||
cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* outFn, bool standAloneFl, bool panZoomFl )
|
||||
{
|
||||
cmSvgRC_t rc = kOkSvgRC;
|
||||
cmSvg_t* p = _cmSvgHandleToPtr(h);
|
||||
@ -205,28 +196,35 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t*
|
||||
cmChar_t* s0 = NULL;
|
||||
cmChar_t* s1 = NULL;
|
||||
|
||||
cmChar_t hdr[] =
|
||||
cmChar_t panZoomHdr[] =
|
||||
"<script type=\"text/javascript\" src=\"svg-pan-zoom/dist/svg-pan-zoom.js\"></script>\n"
|
||||
"<script>\n"
|
||||
" var panZoom = null;\n"
|
||||
" function doOnLoad() { panZoom = svgPanZoom(document.querySelector('#mysvg'), { controlIconsEnabled:true } ) }\n"
|
||||
"</script>\n";
|
||||
|
||||
|
||||
cmChar_t standAloneFmt[] =
|
||||
"<!DOCTYPE html>\n"
|
||||
"<html>\n"
|
||||
"<head>\n"
|
||||
"<meta charset=\"utf-8\">\n"
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">\n"
|
||||
"%s\n"
|
||||
"</head>\n"
|
||||
"<body onload=\"doOnLoad()\">\n"
|
||||
"<svg id=\"mysvg\" width=\"%f\" height=\"%f\">\n";
|
||||
|
||||
"<body onload=\"doOnLoad()\">\n";
|
||||
|
||||
cmChar_t svgFmt[] = "<svg id=\"mysvg\" width=\"%f\" height=\"%f\">\n";
|
||||
|
||||
_cmSvgSize(p, &svgWidth, &svgHeight );
|
||||
|
||||
_cmSvgWriterFlipY( p, svgHeight );
|
||||
|
||||
// print the file header
|
||||
if( (s0 = cmTsPrintfP(s0,hdr,cssFn,svgWidth,svgHeight)) == NULL )
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kPrintFailSvgRC,"File prefix write failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
s0 = cmTsPrintfP(s0, standAloneFmt, cssFn, panZoomFl ? panZoomHdr : "");
|
||||
|
||||
s1 = cmTsPrintfP(s1,"%s%s", standAloneFl ? s0 : "", svgFmt);
|
||||
|
||||
s0 = cmTsPrintfP(s0,s1,svgWidth,svgHeight);
|
||||
|
||||
for(; e!=NULL; e=e->link)
|
||||
{
|
||||
@ -262,12 +260,15 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t*
|
||||
|
||||
}
|
||||
|
||||
if( (s1 = cmTsPrintfP(s1,"</svg>\n</body>\n</html>\n")) == NULL )
|
||||
if( (s1 = cmTsPrintfP(s1,"</svg>\n")) == NULL )
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kPrintFailSvgRC,"File suffix write failed.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
if( standAloneFl )
|
||||
s1 = cmTextAppendSS(s1,"</body>\n</html>\n");
|
||||
|
||||
if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC )
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kFileFailSvgRC,"SVG file create failed for '%s'.",cmStringNullGuard(outFn));
|
||||
@ -280,6 +281,7 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t*
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
|
||||
errLabel:
|
||||
cmFileClose(&fH);
|
||||
|
||||
|
@ -30,7 +30,7 @@ enum
|
||||
// and the Javascript file svg-pan-zoom.min.js from https://github.com/ariutta/svg-pan-zoom.
|
||||
// Both the CSS file and svg-pan-zoom.min.js should therefore be in the same directory
|
||||
// as the output HTML file.
|
||||
cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* outFn );
|
||||
cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* outFn, bool standaloneFl, bool panZoomFl );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user