Many changes to support cmtools.
This commit is contained in:
parent
6240b8f9a8
commit
9d5697d9cd
@ -19,6 +19,7 @@
|
|||||||
#include "cmFile.h"
|
#include "cmFile.h"
|
||||||
#include "cmScore.h"
|
#include "cmScore.h"
|
||||||
#include "cmVectOpsTemplateMain.h"
|
#include "cmVectOpsTemplateMain.h"
|
||||||
|
#include "cmRptFile.h"
|
||||||
|
|
||||||
cmScH_t cmScNullHandle = cmSTATIC_NULL_HANDLE;
|
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 )
|
void _cmScorePrintEvent( cmSc_t* p, const cmScoreEvt_t* r, unsigned i, cmRpt_t* rpt )
|
||||||
{
|
{
|
||||||
bool eolFl = true;
|
//bool eolFl = true;
|
||||||
switch(r->type)
|
switch(r->type)
|
||||||
{
|
{
|
||||||
case kBarEvtScId:
|
case kBarEvtScId:
|
||||||
@ -2469,7 +2470,7 @@ void _cmScorePrintEvent( cmSc_t* p, const cmScoreEvt_t* r, unsigned i, cmRpt_t*
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
eolFl = false;
|
//eolFl = false;
|
||||||
break;
|
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 )
|
if( cmScoreInitialize(ctx,&h,fn,0,NULL,0,NULL,NULL, cmSymTblNullHandle ) != kOkScRC )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cmScorePrint(h,&ctx->rpt);
|
cmScorePrint(h,rpt);
|
||||||
|
|
||||||
cmScoreFinalize(&h);
|
cmScoreFinalize(&h);
|
||||||
|
|
||||||
|
if( cmRptFileIsValid( fH ) )
|
||||||
|
cmRptFileClose( &fH );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn )
|
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
|
// Print open the score file 'fn' and report the contents. This function
|
||||||
// simply wraps calls to cmScoreInitialize() and cmScorePrint().
|
// 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 );
|
void cmScoreTest( cmCtx_t* ctx, const cmChar_t* fn );
|
||||||
|
|
||||||
|
@ -339,10 +339,12 @@ typedef struct
|
|||||||
unsigned _cmSpMeasSectCount( _cmSpMeasProc_t* m )
|
unsigned _cmSpMeasSectCount( _cmSpMeasProc_t* m )
|
||||||
{
|
{
|
||||||
const _cmSpMeas_t* mp = m->list_beg;
|
const _cmSpMeas_t* mp = m->list_beg;
|
||||||
unsigned n = 0;
|
unsigned n = 0;
|
||||||
for(; mp != NULL; mp=mp->link)
|
unsigned M = 0;
|
||||||
|
|
||||||
|
for(; mp != NULL; mp=mp->link,++M)
|
||||||
n += mp->setPtr->sectCnt;
|
n += mp->setPtr->sectCnt;
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,9 +361,10 @@ cmSpRC_t _cmScWriteMeasFile( cmCtx_t* ctx, cmSp_t* sp, _cmSpMeasProc_t* m, const
|
|||||||
cmFileH_t fH = cmFileNullHandle;
|
cmFileH_t fH = cmFileNullHandle;
|
||||||
cmSpRC_t rc = kOkSpRC;
|
cmSpRC_t rc = kOkSpRC;
|
||||||
unsigned i,j,k;
|
unsigned i,j,k;
|
||||||
|
unsigned scnt = _cmSpMeasSectCount(m);
|
||||||
|
|
||||||
_cmSpMeas_t* mp = m->list_beg;
|
_cmSpMeas_t* mp = m->list_beg;
|
||||||
|
|
||||||
unsigned scnt = _cmSpMeasSectCount(m);
|
|
||||||
_cmSpMeasSect_t sarray[ scnt ];
|
_cmSpMeasSect_t sarray[ scnt ];
|
||||||
for(i=0,k=0; k<scnt && mp!=NULL; ++i,mp=mp->link)
|
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); }
|
{ assert(0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for(j=0; j<mp->setPtr->sectCnt; ++j,++k)
|
for(j=0; j<mp->setPtr->sectCnt; ++j,++k)
|
||||||
{
|
{
|
||||||
|
assert(k<scnt);
|
||||||
|
|
||||||
_cmSpMeasSect_t* r = sarray + k;
|
_cmSpMeasSect_t* r = sarray + k;
|
||||||
|
|
||||||
r->srcSeqId = mp->markPtr->obj.seqId,
|
r->srcSeqId = mp->markPtr->obj.seqId;
|
||||||
r->srcMarkNameStr = cmStringNullGuard(mp->markPtr->obj.name),
|
r->srcMarkNameStr = cmStringNullGuard(mp->markPtr->obj.name);
|
||||||
r->srcTypeId = mp->setPtr->varId,
|
r->srcTypeId = mp->setPtr->varId;
|
||||||
r->srcTypeLabelStr = typeLabel,
|
r->srcTypeLabelStr = typeLabel;
|
||||||
r->dstScLocIdx = mp->setPtr->sectArray[j]->locPtr->index,
|
r->dstScLocIdx = mp->setPtr->sectArray[j]->locPtr->index;
|
||||||
r->dstEvtIdx = mp->setPtr->sectArray[j]->begEvtIndex,
|
r->dstEvtIdx = mp->setPtr->sectArray[j]->begEvtIndex;
|
||||||
r->dstSectLabelStr = cmStringNullGuard(mp->setPtr->sectArray[j]->label),
|
r->dstSectLabelStr = cmStringNullGuard(mp->setPtr->sectArray[j]->label);
|
||||||
r->value = mp->value,
|
r->value = mp->value;
|
||||||
r->cost = mp->cost;
|
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);
|
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;
|
_cmSpMeasSect_t* r = sarray + i;
|
||||||
|
|
||||||
cmFilePrintf(fH,"[ \"%s\" \"%s\" %f %f %i %i %i \"%s\" %i ]\n",
|
cmFilePrintf(fH,"[ \"%s\" \"%s\" %f %f %i %i %i \"%s\" %i ]\n",
|
||||||
r->dstSectLabelStr,
|
r->dstSectLabelStr,
|
||||||
r->srcTypeLabelStr,
|
r->srcTypeLabelStr,
|
||||||
r->value,
|
r->value,
|
||||||
r->cost,
|
r->cost,
|
||||||
r->dstScLocIdx,
|
r->dstScLocIdx,
|
||||||
r->dstEvtIdx,
|
r->dstEvtIdx,
|
||||||
r->srcSeqId,
|
r->srcSeqId,
|
||||||
r->srcMarkNameStr,
|
r->srcMarkNameStr,
|
||||||
r->srcTypeId
|
r->srcTypeId
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
mp = sp->list_beg;
|
mp = sp->list_beg;
|
||||||
for(; mp!=NULL; mp=mp->link)
|
for(; mp!=NULL; mp=mp->link)
|
||||||
{
|
{
|
||||||
|
|
||||||
for(i=0; i<mp->setPtr->sectCnt; ++i)
|
for(i=0; i<mp->setPtr->sectCnt; ++i)
|
||||||
{
|
{
|
||||||
cmFilePrintf(fH,"[ %i \"%s\" %i \"%s\" %i %i \"%s\" %f %f ]\n",
|
cmFilePrintf(fH,"[ %i \"%s\" %i \"%s\" %i %i \"%s\" %f %f ]\n",
|
||||||
mp->markPtr->obj.seqId,
|
mp->markPtr->obj.seqId,
|
||||||
cmStringNullGuard(mp->markPtr->obj.name),
|
cmStringNullGuard(mp->markPtr->obj.name),
|
||||||
mp->setPtr->varId,
|
mp->setPtr->varId,
|
||||||
typeLabel,
|
typeLabel,
|
||||||
mp->setPtr->sectArray[i]->locPtr->index,
|
mp->setPtr->sectArray[i]->locPtr->index,
|
||||||
mp->setPtr->sectArray[i]->begEvtIndex,
|
mp->setPtr->sectArray[i]->begEvtIndex,
|
||||||
cmStringNullGuard(mp->setPtr->sectArray[i]->label),
|
cmStringNullGuard(mp->setPtr->sectArray[i]->label),
|
||||||
mp->value,
|
mp->value,
|
||||||
mp->cost );
|
mp->cost );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cmFilePrintf(fH,"\n]\n}\n");
|
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* rsrcFn = "/home/kevin/.kc/time_line.js";
|
||||||
const cmChar_t* outFn = "/home/kevin/src/cmkc/src/kc/data/meas0.js";
|
//const cmChar_t* outFn = "/home/kevin/src/cmkc/src/kc/data/meas0.js";
|
||||||
|
|
||||||
cmSpRC_t rc = kOkSpRC;
|
cmSpRC_t rc = kOkSpRC;
|
||||||
_cmSpMeasProc_t* m = cmMemAllocZ(_cmSpMeasProc_t,1);
|
_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");
|
cmRptPrintf(&ctx->rpt,"Score Performance Evaluation Start\n");
|
||||||
|
|
||||||
// initialize the score processor
|
// 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;
|
goto errLabel;
|
||||||
|
|
||||||
// allocate the performance evaluation measurement object
|
// allocate the performance evaluation measurement object
|
||||||
@ -719,10 +724,10 @@ cmSpRC_t _cmSpProcAssocCb( void* arg, cmSp_t* sp, cmScoreProcSelId_t id, cmTlOb
|
|||||||
return rc;
|
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* pgmRsrcFn = "/home/kevin/.kc/time_line.js";
|
||||||
const cmChar_t* outFn = "/home/kevin/src/cmkc/src/kc/data/takeSeqBldr0.js";
|
//const cmChar_t* outFn = "/home/kevin/src/cmkc/src/kc/data/takeSeqBldr0.js";
|
||||||
cmSpRC_t rc = kOkSpRC;
|
cmSpRC_t rc = kOkSpRC;
|
||||||
cmSpAssocProc_t* m = cmMemAllocZ(cmSpAssocProc_t,1);
|
cmSpAssocProc_t* m = cmMemAllocZ(cmSpAssocProc_t,1);
|
||||||
cmSp_t s;
|
cmSp_t s;
|
||||||
@ -749,7 +754,7 @@ cmSpRC_t _cmScoreProcGenAssocMain(cmCtx_t* ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initialize the score processor
|
// 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;
|
goto errLabel;
|
||||||
|
|
||||||
m->sp = sp;
|
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;
|
cmSpRC_t rc = kOkSpRC;
|
||||||
|
|
||||||
//_cmScoreProcGenAllMeasurementsMain(ctx);
|
if( strcmp(sel,"meas") == 0 )
|
||||||
_cmScoreProcGenAssocMain(ctx);
|
_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;
|
return rc;
|
||||||
|
|
||||||
|
@ -17,12 +17,13 @@ extern "C" {
|
|||||||
kTimeLineFailSpRC,
|
kTimeLineFailSpRC,
|
||||||
kScoreMatchFailSpRC,
|
kScoreMatchFailSpRC,
|
||||||
kFileFailSpRC,
|
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);
|
||||||
|
|
||||||
//)
|
//)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "cmFileSys.h"
|
#include "cmFileSys.h"
|
||||||
#include "cmTimeLine.h"
|
#include "cmTimeLine.h"
|
||||||
#include "cmOnset.h"
|
#include "cmOnset.h"
|
||||||
|
#include "cmRptFile.h"
|
||||||
|
|
||||||
// id's used to track the type of a serialized object
|
// id's used to track the type of a serialized object
|
||||||
enum
|
enum
|
||||||
@ -1802,6 +1803,25 @@ cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* pr
|
|||||||
return cmTimeLineFinalize(&h);
|
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 )
|
cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* jsFn, const cmChar_t* prefixPath )
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,8 @@ extern "C" {
|
|||||||
kFinalizeFailTlRC,
|
kFinalizeFailTlRC,
|
||||||
kInvalidSeqIdTlRC,
|
kInvalidSeqIdTlRC,
|
||||||
kOnsetFailTlRC,
|
kOnsetFailTlRC,
|
||||||
kAssertFailTlRC
|
kAssertFailTlRC,
|
||||||
|
kRptFileFailTlRC
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -217,6 +218,7 @@ extern "C" {
|
|||||||
|
|
||||||
cmTlRC_t cmTimeLinePrint( cmTlH_t h, cmRpt_t* rpt );
|
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 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 );
|
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;
|
cmXsRC_t rc = kOkXsRC;
|
||||||
cmSvgH_t svgH = cmSvgNullHandle;
|
cmSvgH_t svgH = cmSvgNullHandle;
|
||||||
cmXsSvgEvt_t* e = mf->elist;
|
cmXsSvgEvt_t* e = mf->elist;
|
||||||
unsigned noteHeight = 10;
|
unsigned noteHeight = 10;
|
||||||
cmChar_t* fn0 = cmMemAllocStr( fn );
|
//cmChar_t* fn0 = cmMemAllocStr( fn );
|
||||||
const cmChar_t* svgFn = cmFsMakeFn(dir,fn0 = cmTextAppendSS(fn0,"_midi_svg"),"html",NULL);
|
//const cmChar_t* svgFn = cmFsMakeFn(dir,fn0 = cmTextAppendSS(fn0,"_midi_svg"),"html",NULL);
|
||||||
const cmChar_t* cssFn = cmFsMakeFn(NULL,"score_midi_svg","css",NULL);
|
const cmChar_t* cssFn = cmFsMakeFn(NULL,"score_midi_svg","css",NULL);
|
||||||
cmChar_t* t0 = NULL; // temporary dynamic string
|
cmChar_t* t0 = NULL; // temporary dynamic string
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
const cmXsSvgEvt_t* e0 = NULL;
|
const cmXsSvgEvt_t* e0 = NULL;
|
||||||
cmMemFree(fn0);
|
//cmMemFree(fn0);
|
||||||
|
|
||||||
// create the SVG writer
|
// create the SVG writer
|
||||||
if( cmSvgWriterAlloc(ctx,&svgH) != kOkSvgRC )
|
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.");
|
cmErrMsg(&p->err,kSvgFailXsRC,"SVG element insert failed.");
|
||||||
|
|
||||||
if( rc == kOkXsRC )
|
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));
|
rc = cmErrMsg(&p->err,kSvgFailXsRC,"SVG file write to '%s' failed.",cmStringNullGuard(svgFn));
|
||||||
|
|
||||||
errLabel:
|
errLabel:
|
||||||
cmSvgWriterFree(&svgH);
|
cmSvgWriterFree(&svgH);
|
||||||
cmFsFreeFn(svgFn);
|
//cmFsFreeFn(svgFn);
|
||||||
cmFsFreeFn(cssFn);
|
cmFsFreeFn(cssFn);
|
||||||
cmMemFree(t0);
|
cmMemFree(t0);
|
||||||
|
|
||||||
@ -4001,7 +4001,7 @@ void _cmXsPushSvgEvent( cmXScore_t* p, cmXsMidiFile_t* mf, unsigned flags, unsig
|
|||||||
mf->eol = e;
|
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);
|
cmXScore_t* p = _cmXScoreHandleToPtr(h);
|
||||||
cmXsPart_t* pp = p->partL;
|
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);
|
_cmXsPushSvgEvent(p,&mf,note->flags,note->tick,note->duration,0,d0,127,NULL);
|
||||||
continue;
|
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* editFn,
|
||||||
const cmChar_t* csvOutFn,
|
const cmChar_t* csvOutFn,
|
||||||
const cmChar_t* midiOutFn,
|
const cmChar_t* midiOutFn,
|
||||||
|
const cmChar_t* svgOutFn,
|
||||||
bool reportFl,
|
bool reportFl,
|
||||||
int beginMeasNumb,
|
int beginMeasNumb,
|
||||||
int beginBPM )
|
int beginBPM,
|
||||||
|
bool standAloneFl,
|
||||||
|
bool panZoomFl )
|
||||||
{
|
{
|
||||||
cmXsRC_t rc;
|
cmXsRC_t rc;
|
||||||
cmXsH_t h = cmXsNullHandle;
|
cmXsH_t h = cmXsNullHandle;
|
||||||
@ -4113,12 +4115,13 @@ cmXsRC_t cmXScoreTest(
|
|||||||
|
|
||||||
_cmXsIsMidiFileValid(ctx, h, pp->dirStr, pp->fnStr );
|
_cmXsIsMidiFileValid(ctx, h, pp->dirStr, pp->fnStr );
|
||||||
|
|
||||||
_cmXScoreGenSvg( ctx, h, beginMeasNumb, pp->dirStr, pp->fnStr );
|
|
||||||
|
|
||||||
cmFsFreePathParts(pp);
|
cmFsFreePathParts(pp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( svgOutFn != NULL )
|
||||||
|
_cmXScoreGenSvg( ctx, h, beginMeasNumb, svgOutFn, standAloneFl, panZoomFl );
|
||||||
|
|
||||||
if(reportFl)
|
if(reportFl)
|
||||||
cmXScoreReport(h,&ctx->rpt,true);
|
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 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 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.
|
// 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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -610,7 +610,7 @@ cmAbRC_t cmApBufUpdate(
|
|||||||
n0 = pp->audioFramesCnt;
|
n0 = pp->audioFramesCnt;
|
||||||
|
|
||||||
cmApSample_t* bpp = ((cmApSample_t*)pp->audioBytesPtr) + j;
|
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;
|
bool enaFl = cmIsFlag(cp->fl,kChApFl) && cmIsFlag(cp->fl,kMuteApFl)==false;
|
||||||
|
|
||||||
unsigned decrSmpN = 0;
|
unsigned decrSmpN = 0;
|
||||||
@ -625,7 +625,7 @@ cmAbRC_t cmApBufUpdate(
|
|||||||
else // otherwise copy samples from the output buffer to the packet
|
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* sp = enaFl ? cp->b + cp->oi : _cmApBuf.zeroBuf;
|
||||||
const cmApSample_t* ep = sp + n0;
|
//const cmApSample_t* ep = sp + n0;
|
||||||
|
|
||||||
unsigned pi = cp->oi;
|
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 );
|
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 ",
|
cmRptPrintf(rpt,"%s - i:%7i o:%7i f:%7i n:%7i err %s:%7i mtr:%5.4f ",
|
||||||
j==0?"IN":"OUT",
|
j==0?"IN ":"OUT",
|
||||||
ii,oi,fn,ip->n, (j==0?"over":"under"), ip->faultCnt, mtr);
|
ii,oi,fn,ip->n, (j==0?"over ":"under"), ip->faultCnt, mtr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "cmAudioFile.h"
|
#include "cmAudioFile.h"
|
||||||
#include "cmMath.h"
|
#include "cmMath.h"
|
||||||
#include "cmFileSys.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
|
// #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);
|
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 cmAudioFileSetSrate( const cmChar_t* fn, unsigned srate )
|
||||||
{
|
{
|
||||||
cmRC_t rc = kOkAfRC;
|
cmRC_t rc = kOkAfRC;
|
||||||
|
@ -36,6 +36,7 @@ extern "C" {
|
|||||||
kInvalidFileModeAfRC,
|
kInvalidFileModeAfRC,
|
||||||
kInvalidHandleAfRC,
|
kInvalidHandleAfRC,
|
||||||
kInvalidChCountAfRC,
|
kInvalidChCountAfRC,
|
||||||
|
kRptFileFailAfRC,
|
||||||
kUnknownErrAfRC
|
kUnknownErrAfRC
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -271,6 +272,8 @@ extern "C" {
|
|||||||
// Print the cmAudioFileInfo_t to a file.
|
// Print the cmAudioFileInfo_t to a file.
|
||||||
void cmAudioFilePrintInfo( const cmAudioFileInfo_t* infoPtr, cmRpt_t* );
|
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.
|
// 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 );
|
cmRC_t cmAudioFileReport( cmAudioFileH_t h, cmRpt_t* rpt, unsigned frmIdx, unsigned frmCnt );
|
||||||
|
|
||||||
|
27
cmMidiFile.c
27
cmMidiFile.c
@ -1848,7 +1848,22 @@ void _cmMidiFilePrintMsg( cmRpt_t* rpt, const cmMidiTrackMsg_t* tmp )
|
|||||||
|
|
||||||
if( tmp->status == kMetaStId )
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -1923,9 +1938,11 @@ cmMidiFileDensity_t* cmMidiFileNoteDensity( cmMidiFileH_t h, unsigned* cntRef )
|
|||||||
{
|
{
|
||||||
dV[k].uid = msgs[i]->uid;
|
dV[k].uid = msgs[i]->uid;
|
||||||
dV[k].amicro = msgs[i]->amicro;
|
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)
|
for(j=i; j>=0; --j)
|
||||||
{
|
{
|
||||||
if( msgs[i]->amicro - msgs[j]->amicro > 1000000 )
|
if( msgs[i]->amicro - msgs[j]->amicro > 1000000 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1979,7 +1996,7 @@ cmMfRC_t cmMidiFileGenPlotFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmCh
|
|||||||
return rc;
|
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;
|
cmMfRC_t rc = kOkMfRC;
|
||||||
cmSvgH_t svgH = cmSvgNullHandle;
|
cmSvgH_t svgH = cmSvgNullHandle;
|
||||||
@ -2061,7 +2078,7 @@ cmMfRC_t cmMidiFileGenSvgFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmCha
|
|||||||
cmMemFree(tx);
|
cmMemFree(tx);
|
||||||
|
|
||||||
if( rc == kOkMfRC )
|
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));
|
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
|
// 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 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()
|
// Generate a text file reportusing cmMIdiFilePrintMsgs()
|
||||||
cmMfRC_t cmMidiFileReport( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outTextFn );
|
cmMfRC_t cmMidiFileReport( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outTextFn );
|
||||||
|
@ -242,13 +242,14 @@ _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 )
|
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
|
// 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);
|
return cmErrMsg(&p->err,kDuplicateIdPoRC,"The numeric id '%i' was already used by another parameter.",numId);
|
||||||
|
|
||||||
|
|
||||||
// validate the char. id
|
// 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);
|
return cmErrMsg(&p->err,kDuplicateIdPoRC,"The character id -'%c' was already used by another parameter.",charId);
|
||||||
|
|
||||||
// validate the word. id
|
// validate the word. id
|
||||||
|
@ -3909,7 +3909,7 @@ cmRC_t cmRecdPlayInsertRecord(cmRecdPlay* p, unsigned labelSymId, const
|
|||||||
return rc;
|
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 )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* outFn, bool standAloneFl, bool panZoomFl )
|
||||||
"<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 rc = kOkSvgRC;
|
cmSvgRC_t rc = kOkSvgRC;
|
||||||
cmSvg_t* p = _cmSvgHandleToPtr(h);
|
cmSvg_t* p = _cmSvgHandleToPtr(h);
|
||||||
@ -205,29 +196,36 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t*
|
|||||||
cmChar_t* s0 = NULL;
|
cmChar_t* s0 = NULL;
|
||||||
cmChar_t* s1 = 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"
|
"<!DOCTYPE html>\n"
|
||||||
"<html>\n"
|
"<html>\n"
|
||||||
"<head>\n"
|
"<head>\n"
|
||||||
"<meta charset=\"utf-8\">\n"
|
"<meta charset=\"utf-8\">\n"
|
||||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">\n"
|
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">\n"
|
||||||
|
"%s\n"
|
||||||
"</head>\n"
|
"</head>\n"
|
||||||
"<body onload=\"doOnLoad()\">\n"
|
"<body onload=\"doOnLoad()\">\n";
|
||||||
"<svg id=\"mysvg\" width=\"%f\" height=\"%f\">\n";
|
|
||||||
|
cmChar_t svgFmt[] = "<svg id=\"mysvg\" width=\"%f\" height=\"%f\">\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_cmSvgSize(p, &svgWidth, &svgHeight );
|
_cmSvgSize(p, &svgWidth, &svgHeight );
|
||||||
|
|
||||||
_cmSvgWriterFlipY( p, svgHeight );
|
_cmSvgWriterFlipY( p, svgHeight );
|
||||||
|
|
||||||
// print the file header
|
s0 = cmTsPrintfP(s0, standAloneFmt, cssFn, panZoomFl ? panZoomHdr : "");
|
||||||
if( (s0 = cmTsPrintfP(s0,hdr,cssFn,svgWidth,svgHeight)) == NULL )
|
|
||||||
{
|
s1 = cmTsPrintfP(s1,"%s%s", standAloneFl ? s0 : "", svgFmt);
|
||||||
rc = cmErrMsg(&p->err,kPrintFailSvgRC,"File prefix write failed.");
|
|
||||||
goto errLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
s0 = cmTsPrintfP(s0,s1,svgWidth,svgHeight);
|
||||||
|
|
||||||
for(; e!=NULL; e=e->link)
|
for(; e!=NULL; e=e->link)
|
||||||
{
|
{
|
||||||
switch( e->id )
|
switch( e->id )
|
||||||
@ -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.");
|
rc = cmErrMsg(&p->err,kPrintFailSvgRC,"File suffix write failed.");
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( standAloneFl )
|
||||||
|
s1 = cmTextAppendSS(s1,"</body>\n</html>\n");
|
||||||
|
|
||||||
if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC )
|
if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC )
|
||||||
{
|
{
|
||||||
rc = cmErrMsg(&p->err,kFileFailSvgRC,"SVG file create failed for '%s'.",cmStringNullGuard(outFn));
|
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;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
errLabel:
|
errLabel:
|
||||||
cmFileClose(&fH);
|
cmFileClose(&fH);
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ enum
|
|||||||
// and the Javascript file svg-pan-zoom.min.js from https://github.com/ariutta/svg-pan-zoom.
|
// 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
|
// Both the CSS file and svg-pan-zoom.min.js should therefore be in the same directory
|
||||||
// as the output HTML file.
|
// 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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user