cmDspKr.h/c Added Score Object added Time-line cursor.

This commit is contained in:
kpl 2012-11-26 23:07:22 -08:00
parent d32c47be4c
commit f0e00c3d37
5 changed files with 155 additions and 16 deletions

View File

@ -31,6 +31,7 @@ extern "C" {
kCheckDuiId, // ui<--eng create a check box control kCheckDuiId, // ui<--eng create a check box control
kLabelDuiId, // ui<--end create a label control kLabelDuiId, // ui<--end create a label control
kTimeLineDuiId,// ui<--end create a time-line control kTimeLineDuiId,// ui<--end create a time-line control
kScoreDuiId, // ui<--end create a score control
kNumberDuiId, // ui<--eng create a number box kNumberDuiId, // ui<--eng create a number box
kTextDuiId, // ui<--eng create a text entry control kTextDuiId, // ui<--eng create a text entry control
kFnameDuiId, // ui<--eng create a file/directory picker control kFnameDuiId, // ui<--eng create a file/directory picker control

View File

@ -392,7 +392,8 @@ extern "C" {
cmDspRC_t cmDspUiMeterCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned minVarId, unsigned maxVarId, unsigned valVarId, unsigned lblVarId ); 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 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 cmDspUiLabelCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned lblVarId, unsigned alignVarId );
cmDspRC_t cmDspUiTimeLineCreate(cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId ); cmDspRC_t cmDspUiTimeLineCreate(cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId, unsigned cursVarId );
cmDspRC_t cmDspUiScoreCreate( cmDspCtx_t* ctx,cmDspInst_t* inst, unsigned scFileVarId, unsigned selVarId );
cmDspRC_t cmDspUiNewColumn( cmDspCtx_t* ctx, unsigned colW ); cmDspRC_t cmDspUiNewColumn( cmDspCtx_t* ctx, unsigned colW );
cmDspRC_t cmDspUiInsertHorzBorder( cmDspCtx_t* ctx ); cmDspRC_t cmDspUiInsertHorzBorder( cmDspCtx_t* ctx );

View File

@ -21,7 +21,6 @@
#include "cmDspCtx.h" #include "cmDspCtx.h"
#include "cmDspClass.h" #include "cmDspClass.h"
#include "cmDspUi.h" #include "cmDspUi.h"
#include "cmOp.h"
#include "cmMath.h" #include "cmMath.h"
@ -163,7 +162,7 @@ cmDspRC_t _cmDspKrExec(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt
cmSpecDistExec(p->sdp,ip,iSmpCnt); cmSpecDistExec(p->sdp,ip,iSmpCnt);
if((sp = cmSpecDistOut(p->sdp)) != NULL ) if((sp = cmSpecDistOut(p->sdp)) != NULL )
vs_Copy(op,sp,oSmpCnt); cmVOS_Copy(op,oSmpCnt,sp);
return rc; return rc;
} }
@ -241,13 +240,14 @@ enum
kTlFileTlId, kTlFileTlId,
kAudPathTlId, kAudPathTlId,
kSelTlId, kSelTlId,
kCursTlId,
kResetTlId,
kAudFnTlId, kAudFnTlId,
kMidiFnTlId, kMidiFnTlId,
kBegAudSmpIdxTlId, kBegAudSmpIdxTlId,
kEndAudSmpIdxTlId, kEndAudSmpIdxTlId,
kBegMidiSmpIdxTlId, kBegMidiSmpIdxTlId,
kEndMidiSmpIdxTlId kEndMidiSmpIdxTlId
}; };
cmDspClass_t _cmTimeLineDC; cmDspClass_t _cmTimeLineDC;
@ -256,27 +256,31 @@ typedef struct
{ {
cmDspInst_t inst; cmDspInst_t inst;
cmTlH_t tlH; cmTlH_t tlH;
unsigned afIdx;
} cmDspTimeLine_t; } cmDspTimeLine_t;
cmDspInst_t* _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl ) cmDspInst_t* _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
{ {
cmDspVarArg_t args[] = cmDspVarArg_t args[] =
{ {
{ "tlfile", kTlFileTlId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Time line file." }, { "tlfile", kTlFileTlId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Time line file." },
{ "path", kAudPathTlId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Audio path" }, { "path", kAudPathTlId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Audio path" },
{ "sel", kSelTlId, 0, 0, kInDsvFl | kInDsvFl | kOutDsvFl | kUIntDsvFl, "Selected marker id."}, { "sel", kSelTlId, 0, 0, kInDsvFl | kOutDsvFl | kUIntDsvFl, "Selected marker id."},
{ "afn", kAudFnTlId, 0, 0, kOutDsvFl | kStrzDsvFl, "Selected Audio file." }, { "curs", kCursTlId, 0, 0, kInDsvFl | kUIntDsvFl, "Current audio file index."},
{ "mfn", kMidiFnTlId, 0, 0, kOutDsvFl | kStrzDsvFl, "Selected MIDI file." }, { "reset", kResetTlId, 0, 0, kInDsvFl | kSymDsvFl, "Resend all outputs." },
{ "absi", kBegAudSmpIdxTlId, 0, 0, kOutDsvFl | kIntDsvFl, "Begin audio sample index."}, { "afn", kAudFnTlId, 0, 0, kOutDsvFl | kStrzDsvFl, "Selected Audio file." },
{ "aesi", kEndAudSmpIdxTlId, 0, 0, kOutDsvFl | kIntDsvFl, "End audio sample index."}, { "mfn", kMidiFnTlId, 0, 0, kOutDsvFl | kStrzDsvFl, "Selected MIDI file." },
{ "mbsi", kBegMidiSmpIdxTlId, 0, 0, kOutDsvFl | kIntDsvFl, "Begin MIDI sample index."}, { "absi", kBegAudSmpIdxTlId, 0, 0, kOutDsvFl | kIntDsvFl, "Begin audio sample index."},
{ "mesi", kEndMidiSmpIdxTlId, 0, 0, kOutDsvFl | kIntDsvFl, "End MIDI sample index."}, { "aesi", kEndAudSmpIdxTlId, 0, 0, kOutDsvFl | kIntDsvFl, "End audio sample index."},
{ "mbsi", kBegMidiSmpIdxTlId, 0, 0, kOutDsvFl | kIntDsvFl, "Begin MIDI sample index."},
{ "mesi", kEndMidiSmpIdxTlId, 0, 0, kOutDsvFl | kIntDsvFl, "End MIDI sample index."},
{ NULL, 0, 0, 0, 0 } { NULL, 0, 0, 0, 0 }
}; };
cmDspTimeLine_t* p = cmDspInstAlloc(cmDspTimeLine_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl); cmDspTimeLine_t* p = cmDspInstAlloc(cmDspTimeLine_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
cmDspSetDefaultUInt( ctx, &p->inst, kSelTlId, 0, cmInvalidId); cmDspSetDefaultUInt( ctx, &p->inst, kSelTlId, 0, cmInvalidId);
cmDspSetDefaultUInt( ctx, &p->inst, kCursTlId, 0, 0);
cmDspSetDefaultStrcz(ctx, &p->inst, kAudFnTlId, NULL, ""); cmDspSetDefaultStrcz(ctx, &p->inst, kAudFnTlId, NULL, "");
cmDspSetDefaultStrcz(ctx, &p->inst, kMidiFnTlId, NULL, ""); cmDspSetDefaultStrcz(ctx, &p->inst, kMidiFnTlId, NULL, "");
cmDspSetDefaultInt( ctx, &p->inst, kBegAudSmpIdxTlId, 0, cmInvalidIdx); cmDspSetDefaultInt( ctx, &p->inst, kBegAudSmpIdxTlId, 0, cmInvalidIdx);
@ -285,7 +289,7 @@ cmDspInst_t* _cmDspTimeLineAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
cmDspSetDefaultInt( ctx, &p->inst, kEndMidiSmpIdxTlId, 0, cmInvalidIdx); cmDspSetDefaultInt( ctx, &p->inst, kEndMidiSmpIdxTlId, 0, cmInvalidIdx);
// create the UI control // create the UI control
cmDspUiTimeLineCreate(ctx,&p->inst,kTlFileTlId,kAudPathTlId,kSelTlId); cmDspUiTimeLineCreate(ctx,&p->inst,kTlFileTlId,kAudPathTlId,kSelTlId,kCursTlId);
p->tlH = cmTimeLineNullHandle; p->tlH = cmTimeLineNullHandle;
@ -325,6 +329,11 @@ cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
switch( evt->dstVarId ) switch( evt->dstVarId )
{ {
case kCursTlId:
cmDspSetEvent(ctx,inst,evt);
break;
case kResetTlId:
case kSelTlId: case kSelTlId:
{ {
unsigned markerId; unsigned markerId;
@ -339,6 +348,8 @@ cmDspRC_t _cmDspTimeLineRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
{ {
assert(op->typeId == kMarkerTlId); assert(op->typeId == kMarkerTlId);
p->afIdx = op->begSmpIdx;
cmDspSetInt(ctx, inst, kBegAudSmpIdxTlId, op->begSmpIdx ); cmDspSetInt(ctx, inst, kBegAudSmpIdxTlId, op->begSmpIdx );
cmDspSetInt(ctx, inst, kEndAudSmpIdxTlId, op->begSmpIdx + op->durSmpCnt ); cmDspSetInt(ctx, inst, kEndAudSmpIdxTlId, op->begSmpIdx + op->durSmpCnt );
@ -386,6 +397,111 @@ struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx )
return &_cmTimeLineDC; return &_cmTimeLineDC;
} }
//==========================================================================================================================================
// Score UI Object
enum
{
kFnScId,
kSelScId,
kSendScId
};
cmDspClass_t _cmScoreDC;
typedef struct
{
cmDspInst_t inst;
cmScH_t scH;
} cmDspScore_t;
cmDspInst_t* _cmDspScoreAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsigned storeSymId, unsigned instSymId, unsigned id, unsigned va_cnt, va_list vl )
{
cmDspVarArg_t args[] =
{
{ "fn", kFnScId, 0, 0, kInDsvFl | kStrzDsvFl | kReqArgDsvFl, "Score file." },
{ "sel", kSelScId, 0, 0, kInDsvFl | kOutDsvFl | kUIntDsvFl, "Selected score element index."},
{ "send", kSendScId, 0, 0, kInDsvFl | kTypeDsvMask, "Resend last selected score element."},
{ NULL, 0, 0, 0, 0 }
};
cmDspScore_t* p = cmDspInstAlloc(cmDspScore_t,ctx,classPtr,args,instSymId,id,storeSymId,va_cnt,vl);
cmDspSetDefaultUInt( ctx, &p->inst, kSelScId, 0, cmInvalidId);
// create the UI control
cmDspUiScoreCreate(ctx,&p->inst,kFnScId,kSelScId);
p->scH = cmScNullHandle;
return &p->inst;
}
cmDspRC_t _cmDspScoreFree(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
cmDspRC_t rc = kOkDspRC;
cmDspScore_t* p = (cmDspScore_t*)inst;
if( cmScoreFinalize(&p->scH) != kOkTlRC )
return cmErrMsg(&inst->classPtr->err, kInstFinalFailDspRC, "Score finalize failed.");
return rc;
}
cmDspRC_t _cmDspScoreReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
cmDspRC_t rc = kOkDspRC;
cmDspScore_t* p = (cmDspScore_t*)inst;
cmDspApplyAllDefaults(ctx,inst);
const cmChar_t* tlFn;
if((tlFn = cmDspStrcz(inst, kFnScId )) != NULL )
if( cmScoreInitialize(ctx->cmCtx, &p->scH, tlFn, NULL, NULL ) != kOkTlRC )
rc = cmErrMsg(&inst->classPtr->err, kInstResetFailDspRC, "Score file open failed.");
return rc;
}
cmDspRC_t _cmDspScoreRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
switch( evt->dstVarId )
{
case kSelScId:
cmDspSetEvent(ctx,inst,evt);
break;
case kSendScId:
{
unsigned selIdx;
if((selIdx = cmDspUInt(inst,kSelScId)) != cmInvalidIdx )
cmDspSetUInt(ctx,inst,kSelScId, selIdx );
}
break;
default:
{assert(0);}
}
return kOkDspRC;
}
struct cmDspClass_str* cmScoreClassCons( cmDspCtx_t* ctx )
{
cmDspClassSetup(&_cmScoreDC,ctx,"Score",
NULL,
_cmDspScoreAlloc,
_cmDspScoreFree,
_cmDspScoreReset,
NULL,
_cmDspScoreRecv,
NULL,NULL,
"Score control.");
return &_cmScoreDC;
}
//========================================================================================================================================== //==========================================================================================================================================
// MIDI File Player // MIDI File Player

View File

@ -7,6 +7,7 @@ extern "C" {
struct cmDspClass_str* cmKrClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmKrClassCons( cmDspCtx_t* ctx );
struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmTimeLineClassCons( cmDspCtx_t* ctx );
struct cmDspClass_str* cmScoreClassCons( cmDspCtx_t* ctx );
struct cmDspClass_str* cmMidiFilePlayClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmMidiFilePlayClassCons( cmDspCtx_t* ctx );
struct cmDspClass_str* cmScFolClassCons( cmDspCtx_t* ctx ); struct cmDspClass_str* cmScFolClassCons( cmDspCtx_t* ctx );

View File

@ -361,10 +361,10 @@ cmDspRC_t cmDspUiLabelCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned lbl
return rc; return rc;
} }
cmDspRC_t cmDspUiTimeLineCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId ) cmDspRC_t cmDspUiTimeLineCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned tlFileVarId, unsigned audPathVarId, unsigned selVarId, unsigned cursVarId )
{ {
cmDspRC_t rc; cmDspRC_t rc;
unsigned arr[] = { tlFileVarId, audPathVarId, selVarId }; unsigned arr[] = { tlFileVarId, audPathVarId, selVarId, cursVarId };
cmDspValue_t v; cmDspValue_t v;
unsigned vn = sizeof(arr)/sizeof(arr[0]); unsigned vn = sizeof(arr)/sizeof(arr[0]);
cmDsvSetUIntMtx(&v,arr,vn,1); cmDsvSetUIntMtx(&v,arr,vn,1);
@ -382,6 +382,26 @@ cmDspRC_t cmDspUiTimeLineCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned
cmDspInstVarSetFlags( ctx, inst, tlFileVarId, kUiDsvFl ); cmDspInstVarSetFlags( ctx, inst, tlFileVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, audPathVarId, kUiDsvFl ); cmDspInstVarSetFlags( ctx, inst, audPathVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, selVarId, kUiDsvFl ); cmDspInstVarSetFlags( ctx, inst, selVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, cursVarId, kUiDsvFl );
return rc;
}
cmDspRC_t cmDspUiScoreCreate( cmDspCtx_t* ctx, cmDspInst_t* inst, unsigned scFileVarId, unsigned selVarId )
{
cmDspRC_t rc;
unsigned arr[] = { scFileVarId, selVarId };
cmDspValue_t v;
unsigned vn = sizeof(arr)/sizeof(arr[0]);
cmDsvSetUIntMtx(&v,arr,vn,1);
// tell the UI to create a score control
if((rc = _cmDspUiMsg( ctx, kUiSelAsId, kScoreDuiId, 0, inst, cmInvalidId, &v )) != kOkDspRC )
return cmDspInstErr(ctx,inst,kUiEleCreateFailDspRC,"Score UI element create failed.");
// 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, scFileVarId, kUiDsvFl );
cmDspInstVarSetFlags( ctx, inst, selVarId, kUiDsvFl );
return rc; return rc;
} }