Ver código fonte

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

master
Kevin Larke 10 anos atrás
pai
commit
26060afa25
1 arquivos alterados com 19 adições e 8 exclusões
  1. 19
    8
      dsp/cmDspFx.c

+ 19
- 8
dsp/cmDspFx.c Ver arquivo

@@ -3495,6 +3495,7 @@ enum
3495 3495
 {
3496 3496
   kMaxCntMdId,
3497 3497
   kDelayMdId,
3498
+  kClearMdId,
3498 3499
   kInMdId,
3499 3500
   kOutMdId,
3500 3501
 };
@@ -3522,8 +3523,9 @@ cmDspInst_t*  _cmDspMsgDelayAlloc(cmDspCtx_t* ctx, cmDspClass_t* classPtr, unsig
3522 3523
   cmDspMsgDelay_t* p = cmDspInstAllocV(cmDspMsgDelay_t,ctx,classPtr,instSymId,id,storeSymId,va_cnt,vl,
3523 3524
     1,   "maxcnt",  kMaxCntMdId,   0, 0,              kUIntDsvFl   | kReqArgDsvFl, "Maximum count of elements in the delay",
3524 3525
     1,   "delay",   kDelayMdId,    0, 0, kInDsvFl   | kDoubleDsvFl | kOptArgDsvFl, "Delay time in millisecond.",
3525
-    1,   "in",      kInMdId,       0, 0, kInDsvFl   | kTypeDsvMask,                "Msg input",
3526
-    1,   "out",     kOutMdId,      0, 0, kOutDsvFl  | kTypeDsvMask,                "Msg input",
3526
+    1,   "clear",   kClearMdId,    0, 0, kInDsvFl   | kTypeDsvMask,                "Clear delay",
3527
+    1,   "in",      kInMdId,       0, 0, kInDsvFl   | kUIntDsvFl,                "Msg input",
3528
+    1,   "out",     kOutMdId,      0, 0, kOutDsvFl  | kUIntDsvFl,                "Msg output",
3527 3529
     0 );
3528 3530
 
3529 3531
   if( p == NULL )
@@ -3626,14 +3628,10 @@ cmDspRC_t  _cmDspMsgDelayInsert( cmDspCtx_t* ctx, cmDspMsgDelay_t* p, unsigned d
3626 3628
   return rc;
3627 3629
 }
3628 3630
 
3629
-cmDspRC_t _cmDspMsgDelayReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
3631
+void _cmDspMsgDelayClear(cmDspInst_t* inst )
3630 3632
 {
3631
-  cmDspRC_t        rc = kOkDspRC;
3632
-  cmDspMsgDelay_t* p  = (cmDspMsgDelay_t*)inst;
3633
-
3634
-  if((rc  = cmDspApplyDefault(ctx,inst,kDelayMdId)) == kOkDspRC )
3635
-  {
3636 3633
     unsigned i;
3634
+    cmDspMsgDelay_t* p  = (cmDspMsgDelay_t*)inst;
3637 3635
     unsigned maxCnt = cmDspUInt(inst,kMaxCntMdId);
3638 3636
     p->active = NULL;
3639 3637
     p->avail  = NULL;
@@ -3644,6 +3642,15 @@ cmDspRC_t _cmDspMsgDelayReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt
3644 3642
       p->array[i].link = p->avail;
3645 3643
       p->avail         = p->array + i;      
3646 3644
     }
3645
+}
3646
+
3647
+cmDspRC_t _cmDspMsgDelayReset(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_t* evt )
3648
+{
3649
+  cmDspRC_t        rc = kOkDspRC;
3650
+
3651
+  if((rc  = cmDspApplyDefault(ctx,inst,kDelayMdId)) == kOkDspRC )
3652
+  {
3653
+    _cmDspMsgDelayClear(inst);
3647 3654
   }
3648 3655
 
3649 3656
   return rc;  
@@ -3689,6 +3696,10 @@ cmDspRC_t _cmDspMsgDelayRecv(cmDspCtx_t* ctx, cmDspInst_t* inst, const cmDspEvt_
3689 3696
       rc =  cmDspSetEvent(ctx,inst,evt);
3690 3697
       break;
3691 3698
 
3699
+    case kClearMdId:
3700
+      _cmDspMsgDelayClear(inst);
3701
+      break;
3702
+
3692 3703
     case  kInMdId:
3693 3704
       {
3694 3705
         unsigned delayTimeSmp = floor(cmDspDouble(&p->inst,kDelayMdId) * cmDspSampleRate(ctx) / 1000.0);

Carregando…
Cancelar
Salvar