DSP time line processor integration

This commit is contained in:
kevin 2012-11-16 12:13:36 -08:00
parent 00e2219a42
commit f93924a449
4 changed files with 62 additions and 18 deletions

View File

@ -392,7 +392,7 @@ extern "C" {
cmDspRC_t cmDspUiMeterCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned minVarId, unsigned maxVarId, unsigned valVarId, unsigned lblVarId );
cmDspRC_t cmDspUiButtonCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned typeDuiId, unsigned outVarId, unsigned lblVarId );
cmDspRC_t cmDspUiLabelCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned lblVarId, unsigned alignVarId );
cmDspRC_t cmDspUiTimeLineCreate(cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned valVarId, unsigned lblVarId, unsigned tlFileId, unsigned audPathId );
cmDspRC_t cmDspUiTimeLineCreate(cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId );
cmDspRC_t cmDspUiNewColumn( cmDspCtx_t* ctx, unsigned colW );
cmDspRC_t cmDspUiInsertHorzBorder( cmDspCtx_t* ctx );

View File

@ -24,6 +24,7 @@
#include "cmOp.h"
#include "cmMath.h"
#include "cmAudioFile.h"
#include "cmFileSys.h"
#include "cmProcObj.h"
@ -33,6 +34,10 @@
#include "cmProc2.h"
#include "cmVectOpsTemplateMain.h"
#include "cmAudioFile.h"
#include "cmMidiFile.h"
#include "cmTimeLine.h"
enum
{
kWndSmpCntKrId,
@ -229,10 +234,12 @@ struct cmDspClass_str* cmKrClassCons( cmDspCtx_t* ctx )
//==========================================================================================================================================
enum
{
kValTlId,
kLblTlId,
kTlFileTlId,
kAudPathTlId
kAudPathTlId,
kSelTlId,
kAudFnTlId,
kBegSmpIdxTlId,
kEndSmpIdxTlId
};
cmDspClass_t _cmTimeLineDC;
@ -240,29 +247,62 @@ cmDspClass_t _cmTimeLineDC;
typedef struct
{
cmDspInst_t inst;
cmTlH_t tlH;
} cmDspTimeLine_t;
cmDspInst_t* _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
{
cmDspVarArg_t args[] =
{
{ "val", kValTlId, 0, 0, kInDsvFl | kOutDsvFl | kStrzDsvFl | kReqArgDsvFl | kSendDfltDsvFl, "Current string"},
{ "lbl", kLblTlId, 0, 0, kStrzDsvFl | kOptArgDsvFl, "Label"},
{ "tlfile", kTlFileTlId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Time line file." },
{ "path", kAudPathTlId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Audio path" },
{ "sel", kSelTlId, 0, 0, kInDsvFl | kInDsvFl | kOutDsvFl | kUIntDsvFl, "Selected marker id."},
{ "afn", kAudFnTlId, 0, 0, kOutDsvFl | kStrzDsvFl, "Selected Audio file." },
{ "bsi", kBegSmpIdxTlId, 0, 0, kOutDsvFl | kUIntDsvFl, "Begin audio sample index."},
{ "esi", kEndSmpIdxTlId, 0, 0, kOutDsvFl | kUIntDsvFl, "End audio sample index."},
{ NULL, 0, 0, 0, 0 }
};
cmDspTimeLine_t* p = cmDspInstAlloc(cmDspTimeLine_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
cmDspSetDefaultUInt( ctx, &p->inst, kSelTlId, 0, cmInvalidId);
cmDspSetDefaultStrcz( ctx, &p->inst, kAudFnTlId, NULL, "");
cmDspSetDefaultUInt( ctx, &p->inst, kBegSmpIdxTlId, 0, cmInvalidIdx);
cmDspSetDefaultUInt( ctx, &p->inst, kEndSmpIdxTlId, 0, cmInvalidIdx);
// create the UI control
cmDspUiTimeLineCreate(ctx,&p->inst,kValTlId,kLblTlId,kTlFileTlId,kAudPathTlId);
cmDspUiTimeLineCreate(ctx,&p->inst,kTlFileTlId,kAudPathTlId,kSelTlId);
p->tlH = cmTimeLineNullHandle;
return &p->inst;
}
cmDspRC_t _cmDspTimeLineFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
cmDspRC_t rc = kOkDspRC;
cmDspTimeLine_t* p = (cmDspTimeLine_t*)inst;
if( cmTimeLineFinalize(&p->tlH) != kOkTlRC )
return cmErrMsg(&inst->classPtr->err, kInstFinalFailDspRC, "Time-line finalize failed.");
return rc;
}
cmDspRC_t _cmDspTimeLineReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
cmDspRC_t rc = kOkDspRC;
cmDspTimeLine_t* p = (cmDspTimeLine_t*)inst;
cmDspApplyAllDefaults(ctx,inst);
return kOkDspRC;
const cmChar_t* tlFn;
if((tlFn = cmDspStrcz(inst, kTlFileTlId )) != NULL )
if( cmTimeLineInitializeFromFile(ctx->cmCtx, &p->tlH, NULL, NULL, tlFn ) != kOkTlRC )
rc = cmErrMsg(&inst->classPtr->err, kInstResetFailDspRC, "Time-line file open failed.");
return rc;
}
cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
@ -270,8 +310,9 @@ cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
switch( evt->dstVarId )
{
case kValTlId:
case kSelTlId:
cmDspSetEvent(ctx,inst,evt);
break;
default:
@ -286,7 +327,7 @@ struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx )
cmDspClassSetup(&_cmTimeLineDC,ctx,"TimeLine",
NULL,
_cmDspTimeLineAlloc,
NULL,
_cmDspTimeLineFree,
_cmDspTimeLineReset,
NULL,
_cmDspTimeLineRecv,

View File

@ -36,16 +36,19 @@
cmDspRC_t _cmDspSysPgm_TimeLine(cmDspSysH_t h, void** userPtrPtr )
{
cmDspRC_t rc = kOkDspRC;
cmDspRC_t rc = kOkDspRC;
const cmChar_t* tlFn = "/home/kevin/src/cmgv/src/gv/data/tl7.js";
const cmChar_t* audPath = "/home/kevin/media/audio/20110723-Kriesberg/Audio Files";
cmDspInst_t* tlp = cmDspSysAllocInst(h,"TimeLine", "text", 1, "Hello" );
cmDspInst_t* tlp = cmDspSysAllocInst(h,"TimeLine", "tl", 2, tlFn, audPath );
cmDspInst_t* prp = cmDspSysAllocInst(h,"Printer", NULL, 1, ">" );
if((rc = cmDspSysLastRC(h)) != kOkDspRC )
return rc;
cmDspSysInstallCb(h, tlp, "val", prp, "in", NULL );
cmDspSysInstallCb(h, tlp, "afn", prp, "in", NULL );
cmDspSysInstallCb(h, tlp, "sel", prp, "in", NULL );
return rc;
}

View File

@ -361,10 +361,10 @@ cmDspRC_t cmDspUiLabelCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned lbl
return rc;
}
cmDspRC_t cmDspUiTimeLineCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned valVarId, unsigned lblVarId, unsigned tlFileVarId, unsigned audPathVarId )
cmDspRC_t cmDspUiTimeLineCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId )
{
cmDspRC_t rc;
unsigned arr[] = { valVarId, lblVarId, tlFileVarId, audPathVarId };
unsigned arr[] = { tlFileVarId, audPathVarId, selVarId };
cmDspValue_t v;
unsigned vn = sizeof(arr)/sizeof(arr[0]);
cmDsvSetUIntMtx(&v,arr,vn,1);
@ -374,14 +374,14 @@ cmDspRC_t cmDspUiTimeLineCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned
return cmDspInstErr(ctx,inst,kUiEleCreateFailDspRC,"Time Line UI element create failed.");
// use instance symbol as default label
if((rc = _cmDspUiUseInstSymbolAsLabel(ctx, inst, lblVarId, "TimeLine")) != kOkDspRC )
return rc;
//if((rc = _cmDspUiUseInstSymbolAsLabel(ctx, inst, lblVarId, "TimeLine")) != kOkDspRC )
// return rc;
// Set the kUiDsvFl on the variables used for the min/max/def/val for this scalar
// Setting this flag will cause their values to be sent to the UI whenever they change.
cmDspInstVarSetFlags( ctx, inst, valVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, tlFileVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, audPathVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, selVarId, kUiDsvFl );
return rc;
}