cmDspFx.c : Added 'clear' command to cmDspMsgDelay.

This commit is contained in:
Kevin Larke 2014-05-31 09:49:01 -07:00
parent 76a8e5cd2a
commit 26060afa25

View File

@ -3495,6 +3495,7 @@ enum
{
kMaxCntMdId,
kDelayMdId,
kClearMdId,
kInMdId,
kOutMdId,
};
@ -3522,8 +3523,9 @@ cmDspInst_t* _cmDspMsgDelayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
cmDspMsgDelay_t* p = cmDspInstAllocV(cmDspMsgDelay_t,ctx,classPtr,instSymId,id,storeSymId,va_cnt,vl,
1, "maxcnt", kMaxCntMdId, 0, 0, kUIntDsvFl | kReqArgDsvFl, "Maximum count of elements in the delay",
1, "delay", kDelayMdId, 0, 0, kInDsvFl | kDoubleDsvFl | kOptArgDsvFl, "Delay time in millisecond.",
1, "in", kInMdId, 0, 0, kInDsvFl | kTypeDsvMask, "Msg input",
1, "out", kOutMdId, 0, 0, kOutDsvFl | kTypeDsvMask, "Msg input",
1, "clear", kClearMdId, 0, 0, kInDsvFl | kTypeDsvMask, "Clear delay",
1, "in", kInMdId, 0, 0, kInDsvFl | kUIntDsvFl, "Msg input",
1, "out", kOutMdId, 0, 0, kOutDsvFl | kUIntDsvFl, "Msg output",
0 );
if( p == NULL )
@ -3626,14 +3628,10 @@ cmDspRC_t _cmDspMsgDelayInsert( cmDspCtx_t* ctx, cmDspMsgDelay_t* p, unsigned d
return rc;
}
cmDspRC_t _cmDspMsgDelayReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
cmDspRC_t rc = kOkDspRC;
cmDspMsgDelay_t* p = (cmDspMsgDelay_t*)inst;
if((rc = cmDspApplyDefault(ctx,inst,kDelayMdId)) == kOkDspRC )
void _cmDspMsgDelayClear(cmDspInst_t* inst )
{
unsigned i;
cmDspMsgDelay_t* p = (cmDspMsgDelay_t*)inst;
unsigned maxCnt = cmDspUInt(inst,kMaxCntMdId);
p->active = NULL;
p->avail = NULL;
@ -3646,6 +3644,15 @@ cmDspRC_t _cmDspMsgDelayReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
}
}
cmDspRC_t _cmDspMsgDelayReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
{
cmDspRC_t rc = kOkDspRC;
if((rc = cmDspApplyDefault(ctx,inst,kDelayMdId)) == kOkDspRC )
{
_cmDspMsgDelayClear(inst);
}
return rc;
}
@ -3689,6 +3696,10 @@ cmDspRC_t _cmDspMsgDelayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
rc = cmDspSetEvent(ctx,inst,evt);
break;
case kClearMdId:
_cmDspMsgDelayClear(inst);
break;
case kInMdId:
{
unsigned delayTimeSmp = floor(cmDspDouble(&p->inst,kDelayMdId) * cmDspSampleRate(ctx) / 1000.0);