app/cmTimeLine.h/c,cmScoreProc.c:The time-line now takes a prefix path rather
then included explicit paths as part of the time-line data file.
This commit is contained in:
parent
cad6618f3d
commit
e918c4308b
@ -85,6 +85,7 @@ cmSpRC_t _cmScoreProcInit( cmCtx_t* ctx, cmSp_t* p, const cmChar_t* rsrcFn )
|
||||
cmSpRC_t rc = kOkSpRC;
|
||||
const cmChar_t* scFn = NULL;
|
||||
const cmChar_t* tlFn = NULL;
|
||||
const cmChar_t* tlPrefixPath = NULL;
|
||||
|
||||
p->srate = 96000;
|
||||
|
||||
@ -111,6 +112,14 @@ cmSpRC_t _cmScoreProcInit( cmCtx_t* ctx, cmSp_t* p, const cmChar_t* rsrcFn )
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// get the time line data file prefix path
|
||||
if( cmJsonPathToString( p->jsH, NULL, NULL, "tlPrefixPath", &tlPrefixPath ) != kOkJsRC )
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kJsonFailSpRC,"Unable to locate the time line data file prefix path in the main resource file:%s",cmStringNullGuard(rsrcFn));
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
|
||||
// read the dynamics reference array
|
||||
if((rc = _cmJsonReadDynArray( p->jsH, &p->dynArray, &p->dynCnt )) != kOkSpRC )
|
||||
{
|
||||
@ -127,7 +136,7 @@ cmSpRC_t _cmScoreProcInit( cmCtx_t* ctx, cmSp_t* p, const cmChar_t* rsrcFn )
|
||||
}
|
||||
|
||||
// load the time-line file
|
||||
if( cmTimeLineInitializeFromFile(ctx, &p->tlH, NULL, NULL, tlFn ) != kOkTlRC )
|
||||
if( cmTimeLineInitializeFromFile(ctx, &p->tlH, NULL, NULL, tlFn, tlPrefixPath ) != kOkTlRC )
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kTimeLineFailSpRC,"Time line load failed for time line file:%s.",cmStringNullGuard(tlFn));
|
||||
goto errLabel;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "cmAudioFile.h"
|
||||
#include "cmMidi.h"
|
||||
#include "cmMidiFile.h"
|
||||
#include "cmFileSys.h"
|
||||
#include "cmTimeLine.h"
|
||||
|
||||
// id's used to track the type of a serialized object
|
||||
@ -55,6 +56,7 @@ typedef struct
|
||||
unsigned nextSeqId;
|
||||
cmTlCb_t cbFunc;
|
||||
void* cbArg;
|
||||
cmChar_t* prefixPath;
|
||||
unsigned nextUId;
|
||||
char* tmpBuf;
|
||||
unsigned seqCnt;
|
||||
@ -592,10 +594,17 @@ cmTlRC_t _cmTlAllocAudioFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmC
|
||||
cmRC_t afRC = cmOkRC;
|
||||
cmTlRC_t rc;
|
||||
_cmTlObj_t* op = NULL;
|
||||
|
||||
// prepend the time-line path prefix to the filename
|
||||
fn = cmFsMakeFn( p->prefixPath, fn, NULL, NULL );
|
||||
|
||||
unsigned recdByteCnt = sizeof(cmTlAudioFile_t) + strlen(fn) + 1;
|
||||
|
||||
if( cmAudioFileIsValid( afH = cmAudioFileNewOpen(fn, &info, &afRC, p->err.rpt )) == false )
|
||||
return cmErrMsg(&p->err,kAudioFileFailTlRC,"The time line audio file '%s' could not be opened.",cmStringNullGuard(fn));
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kAudioFileFailTlRC,"The time line audio file '%s' could not be opened.",cmStringNullGuard(fn));
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
if((rc = _cmTlAllocRecd(p,nameStr,refIdStr,begSmpIdx,info.frameCnt,kAudioFileTlId,seqId,recdByteCnt,&op)) != kOkTlRC )
|
||||
goto errLabel;
|
||||
@ -621,6 +630,8 @@ cmTlRC_t _cmTlAllocAudioFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmC
|
||||
//_cmTlNotifyListener(p, kInsertMsgTlId, op );
|
||||
|
||||
errLabel:
|
||||
cmFsFreeFn(fn);
|
||||
|
||||
if( rc != kOkTlRC )
|
||||
cmAudioFileDelete(&afH);
|
||||
|
||||
@ -718,6 +729,9 @@ cmTlRC_t _cmTlAllocMidiFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmCh
|
||||
cmTlRC_t rc = kOkTlRC;
|
||||
_cmTlObj_t* op = NULL;
|
||||
|
||||
// prepend the time-line path prefix to the filename
|
||||
fn = cmFsMakeFn( p->prefixPath, fn, NULL, NULL );
|
||||
|
||||
// open the midi file
|
||||
if( cmMidiFileOpen(fn, &mfH, &p->ctx ) != kOkMfRC )
|
||||
return cmErrMsg(&p->err,kMidiFileFailTlRC,"The time line midi file '%s' could not be opened.",cmStringNullGuard(fn));
|
||||
@ -763,6 +777,8 @@ cmTlRC_t _cmTlAllocMidiFileRecd( _cmTl_t* p, const cmChar_t* nameStr, const cmCh
|
||||
|
||||
|
||||
errLabel:
|
||||
cmFsFreeFn(fn);
|
||||
|
||||
if( rc != kOkTlRC )
|
||||
{
|
||||
cmMidiFileClose(&mfH);
|
||||
@ -890,6 +906,8 @@ cmTlRC_t _cmTimeLineFinalize( _cmTl_t* p )
|
||||
|
||||
cmMemPtrFree(&p->tmpBuf);
|
||||
|
||||
cmMemPtrFree(&p->prefixPath);
|
||||
|
||||
cmMemPtrFree(&p);
|
||||
|
||||
|
||||
@ -899,7 +917,7 @@ cmTlRC_t _cmTimeLineFinalize( _cmTl_t* p )
|
||||
return cmErrMsg(&p->err,kFinalizeFailTlRC,"Finalize failed.");
|
||||
}
|
||||
|
||||
cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg )
|
||||
cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg, const cmChar_t* prefixPath )
|
||||
{
|
||||
cmTlRC_t rc;
|
||||
|
||||
@ -909,9 +927,10 @@ cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void*
|
||||
_cmTl_t* p = cmMemAllocZ( _cmTl_t, 1 );
|
||||
|
||||
cmErrSetup(&p->err,&ctx->rpt,"Time Line");
|
||||
p->ctx = *ctx;
|
||||
p->cbFunc = cbFunc;
|
||||
p->cbArg = cbArg;
|
||||
p->ctx = *ctx;
|
||||
p->cbFunc = cbFunc;
|
||||
p->cbArg = cbArg;
|
||||
p->prefixPath = cmMemAllocStr(prefixPath);
|
||||
|
||||
if(cmLHeapIsValid( p->lH = cmLHeapCreate( 8192, ctx )) == false )
|
||||
{
|
||||
@ -928,10 +947,10 @@ cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void*
|
||||
return rc;
|
||||
}
|
||||
|
||||
cmTlRC_t cmTimeLineInitializeFromFile( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg, const cmChar_t* fn )
|
||||
cmTlRC_t cmTimeLineInitializeFromFile( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg, const cmChar_t* fn, const cmChar_t* prefixPath )
|
||||
{
|
||||
cmTlRC_t rc;
|
||||
if((rc = cmTimeLineInitialize(ctx,hp,cbFunc,cbArg)) != kOkTlRC )
|
||||
if((rc = cmTimeLineInitialize(ctx,hp,cbFunc,cbArg,prefixPath)) != kOkTlRC )
|
||||
return rc;
|
||||
|
||||
return cmTimeLineReadJson(hp,fn);
|
||||
@ -1595,12 +1614,12 @@ cmTlRC_t cmTimeLinePrint( cmTlH_t h, cmRpt_t* rpt )
|
||||
return kOkTlRC;
|
||||
}
|
||||
|
||||
cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, cmRpt_t* rpt )
|
||||
cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, const cmChar_t* prefixPath, cmRpt_t* rpt )
|
||||
{
|
||||
cmTlRC_t rc;
|
||||
cmTlH_t h = cmTimeLineNullHandle;
|
||||
|
||||
if((rc = cmTimeLineInitializeFromFile(ctx,&h,NULL,NULL,fn)) != kOkTlRC )
|
||||
if((rc = cmTimeLineInitializeFromFile(ctx,&h,NULL,NULL,fn,prefixPath)) != kOkTlRC )
|
||||
return rc;
|
||||
|
||||
cmTimeLinePrint(h,rpt);
|
||||
@ -1609,12 +1628,12 @@ cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, cmRpt_t* rpt )
|
||||
}
|
||||
|
||||
|
||||
cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* jsFn )
|
||||
cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* jsFn, const cmChar_t* prefixPath )
|
||||
{
|
||||
cmTlRC_t rc = kOkTlRC;
|
||||
cmTlH_t tlH = cmTimeLineNullHandle;
|
||||
|
||||
if((rc = cmTimeLineInitialize(ctx,&tlH,NULL,NULL)) != kOkTlRC )
|
||||
if((rc = cmTimeLineInitialize(ctx,&tlH,NULL,NULL,prefixPath)) != kOkTlRC )
|
||||
return rc;
|
||||
|
||||
if((rc = cmTimeLineReadJson(&tlH,jsFn)) != kOkTlRC )
|
||||
|
@ -103,8 +103,8 @@ extern "C" {
|
||||
extern cmTlH_t cmTimeLineNullHandle;
|
||||
|
||||
//
|
||||
cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg );
|
||||
cmTlRC_t cmTimeLineInitializeFromFile( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg, const cmChar_t* fn );
|
||||
cmTlRC_t cmTimeLineInitialize( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg, const cmChar_t* prefixPath );
|
||||
cmTlRC_t cmTimeLineInitializeFromFile( cmCtx_t* ctx, cmTlH_t* hp, cmTlCb_t cbFunc, void* cbArg, const cmChar_t* fn, const cmChar_t* prefixPath );
|
||||
|
||||
const cmChar_t* cmTimeLineFileName( cmTlH_t h );
|
||||
|
||||
@ -194,9 +194,9 @@ extern "C" {
|
||||
cmTlRC_t cmTimeLineWrite( cmTlH_t h, const cmChar_t* fn );
|
||||
|
||||
cmTlRC_t cmTimeLinePrint( cmTlH_t h, cmRpt_t* rpt );
|
||||
cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* fn, cmRpt_t* rpt );
|
||||
cmTlRC_t cmTimeLinePrintFn( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* prefixPath, cmRpt_t* rpt );
|
||||
|
||||
cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* jsFn );
|
||||
cmTlRC_t cmTimeLineTest( cmCtx_t* ctx, const cmChar_t* tlFn, const cmChar_t* prefixPath );
|
||||
|
||||
// The time-line notifies listeners of initialization and finalization
|
||||
// events via calling a cmTlCbFunc_t function. The argument to this
|
||||
|
Loading…
Reference in New Issue
Block a user