Browse Source

Removed use of cmOp.h/c. Added features to DSP WaveTable object.

Added VECT_OP_FUNC()'s MultSumVVS() and SquaredSum().

DSP Wavetable object now transmits 'done' after last sample of the
last loop and provides running output of the current audio file
index via 'fidx'.
master
kpl 12 years ago
parent
commit
6334b34d2c
6 changed files with 78 additions and 45 deletions
  1. 54
    42
      dsp/cmDspBuiltIn.c
  2. 0
    1
      dsp/cmDspFx.c
  3. 10
    0
      vop/cmVectOpsRICode.h
  4. 1
    2
      vop/cmVectOpsRIHdr.h
  5. 10
    0
      vop/cmVectOpsTemplateCode.h
  6. 3
    0
      vop/cmVectOpsTemplateHdr.h

+ 54
- 42
dsp/cmDspBuiltIn.c View File

31
 #include "cmDspNet.h"
31
 #include "cmDspNet.h"
32
 
32
 
33
 #include "cmAudioFile.h"
33
 #include "cmAudioFile.h"
34
-#include "cmOp.h"
35
 #include "cmThread.h"  // used for threaded loading in wave table file mode
34
 #include "cmThread.h"  // used for threaded loading in wave table file mode
36
 
35
 
37
 
36
 
1055
 
1054
 
1056
   // if this channel is disabled then iChArray[chIdx] will be NULL
1055
   // if this channel is disabled then iChArray[chIdx] will be NULL
1057
   if( ctx->ctx->iChArray[chIdx]!=NULL )
1056
   if( ctx->ctx->iChArray[chIdx]!=NULL )
1058
-    vs_MultVVS(dp,ctx->ctx->iChArray[chIdx],n,gain);
1057
+    cmVOS_MultVVS(dp,n,ctx->ctx->iChArray[chIdx],(cmSample_t)gain);
1059
 
1058
 
1060
   return kOkDspRC;
1059
   return kOkDspRC;
1061
 }
1060
 }
1170
   
1169
   
1171
   // if this channel is disabled or set to pass-through then chArray[chIdx] will be NULL
1170
   // if this channel is disabled or set to pass-through then chArray[chIdx] will be NULL
1172
   if( ctx->ctx->oChArray[chIdx] != NULL )
1171
   if( ctx->ctx->oChArray[chIdx] != NULL )
1173
-    vs_MultVVS(ctx->ctx->oChArray[chIdx],sp,n,gain);
1172
+    cmVOS_MultVVS(ctx->ctx->oChArray[chIdx],n,sp,(cmSample_t)gain);
1174
 
1173
 
1175
   return kOkDspRC;
1174
   return kOkDspRC;
1176
 }
1175
 }
1329
       const cmSample_t* sp  = i==0 ? cmDspAudioBuf(ctx,inst,kIn0AofId,0) : cmDspAudioBuf(ctx,inst,kIn1AofId,0);
1328
       const cmSample_t* sp  = i==0 ? cmDspAudioBuf(ctx,inst,kIn0AofId,0) : cmDspAudioBuf(ctx,inst,kIn1AofId,0);
1330
       cmSample_t       gain = i==0 ? cmDspDouble(inst,kGain0AofId) : cmDspDouble(inst,kGain1AofId);
1329
       cmSample_t       gain = i==0 ? cmDspDouble(inst,kGain0AofId) : cmDspDouble(inst,kGain1AofId);
1331
 
1330
 
1332
-      cmVOS_MultVVS(chArray[i], n, sp, gain);
1331
+      cmVOS_MultVVS(chArray[i], n, sp, (cmSample_t)gain);
1333
 
1332
 
1334
     }
1333
     }
1335
 
1334
 
2732
   kGainWtId,
2731
   kGainWtId,
2733
   kPhsWtId,
2732
   kPhsWtId,
2734
   kOutWtId,
2733
   kOutWtId,
2735
-  kCntWtId
2734
+  kCntWtId,
2735
+  kFIdxWtId,
2736
+  kDoneWtId
2736
 };
2737
 };
2737
 
2738
 
2738
 enum
2739
 enum
2762
   unsigned       wtn;           // count of empty samples (avail for writing over) in the wavetable.
2763
   unsigned       wtn;           // count of empty samples (avail for writing over) in the wavetable.
2763
   unsigned       fi;            // absolute index into the file of the next sample to read
2764
   unsigned       fi;            // absolute index into the file of the next sample to read
2764
   unsigned       fn;            // length of the file in samples
2765
   unsigned       fn;            // length of the file in samples
2766
+  unsigned       cfi;           // absolute index into the file of the beginning of the current audio vector
2767
+  unsigned       cfn;           // when cfi >= cfn and doneFl is set then the 'done' msg is sent
2765
   unsigned       loopCnt;       // current loop count
2768
   unsigned       loopCnt;       // current loop count
2766
   bool           doneFl;        // the wave table source is exhausted 
2769
   bool           doneFl;        // the wave table source is exhausted 
2767
   cmAudioFileH_t afH;           // current audio file handle
2770
   cmAudioFileH_t afH;           // current audio file handle
2774
   double         phsLast;
2777
   double         phsLast;
2775
   unsigned       onSymId;
2778
   unsigned       onSymId;
2776
   unsigned       offSymId;
2779
   unsigned       offSymId;
2780
+  unsigned       doneSymId;
2777
  } cmDspWaveTable_t;
2781
  } cmDspWaveTable_t;
2778
 
2782
 
2779
 bool _cmDspWaveTableThreadFunc( void* param);
2783
 bool _cmDspWaveTableThreadFunc( void* param);
2785
     { "len",    kLenWtId,    0, 0, kInDsvFl  | kUIntDsvFl | kOptArgDsvFl, "Wave table length in samples" },
2789
     { "len",    kLenWtId,    0, 0, kInDsvFl  | kUIntDsvFl | kOptArgDsvFl, "Wave table length in samples" },
2786
     { "shape",  kShapeWtId,  0, 0, kInDsvFl  | kUIntDsvFl | kOptArgDsvFl, "Wave shape 0=silent 1=file 2=sine 3=white"   },
2790
     { "shape",  kShapeWtId,  0, 0, kInDsvFl  | kUIntDsvFl | kOptArgDsvFl, "Wave shape 0=silent 1=file 2=sine 3=white"   },
2787
     { "fn",     kFnWtId,     0, 0, kInDsvFl  | kStrzDsvFl | kOptArgDsvFl, "Optional audio file name"     },
2791
     { "fn",     kFnWtId,     0, 0, kInDsvFl  | kStrzDsvFl | kOptArgDsvFl, "Optional audio file name"     },
2788
-    { "loop",   kLoopWtId,   0, 0, kInDsvFl  | kIntDsvFl  | kOptArgDsvFl, "-1=loop forever  >0=loop count"},
2792
+    { "loop",   kLoopWtId,   0, 0, kInDsvFl  | kIntDsvFl  | kOptArgDsvFl, "-1=loop forever  >0=loop count (dflt:-1)"},
2789
     { "beg",    kBegWtId,    0, 0, kInDsvFl  | kIntDsvFl  | kOptArgDsvFl, "File begin sample index" },
2793
     { "beg",    kBegWtId,    0, 0, kInDsvFl  | kIntDsvFl  | kOptArgDsvFl, "File begin sample index" },
2790
     { "end",    kEndWtId,    0, 0, kInDsvFl  | kIntDsvFl  | kOptArgDsvFl, "File end sample index (-1=play all)" },
2794
     { "end",    kEndWtId,    0, 0, kInDsvFl  | kIntDsvFl  | kOptArgDsvFl, "File end sample index (-1=play all)" },
2791
     { "cmd",    kCmdWtId,    0, 0, kInDsvFl  | kSymDsvFl  | kOptArgDsvFl, "Command: on off"},
2795
     { "cmd",    kCmdWtId,    0, 0, kInDsvFl  | kSymDsvFl  | kOptArgDsvFl, "Command: on off"},
2794
     { "phs",    kPhsWtId,    0, 0, kInDsvFl  | kAudioBufDsvFl,            "Driving phase" },
2798
     { "phs",    kPhsWtId,    0, 0, kInDsvFl  | kAudioBufDsvFl,            "Driving phase" },
2795
     { "out",    kOutWtId,    0, 1, kOutDsvFl | kAudioBufDsvFl,            "Audio output" },
2799
     { "out",    kOutWtId,    0, 1, kOutDsvFl | kAudioBufDsvFl,            "Audio output" },
2796
     { "cnt",    kCntWtId,    0, 0, kOutDsvFl | kIntDsvFl,                 "Loop count event."},
2800
     { "cnt",    kCntWtId,    0, 0, kOutDsvFl | kIntDsvFl,                 "Loop count event."},
2801
+    { "fidx",   kFIdxWtId,   0, 0, kOutDsvFl | kUIntDsvFl,                "Current audio file index."},
2802
+    { "done",   kDoneWtId,   0, 0, kOutDsvFl | kSymDsvFl,                 "'done' sent after last loop."},
2797
     { NULL, 0, 0, 0, 0 }
2803
     { NULL, 0, 0, 0, 0 }
2798
   };
2804
   };
2799
 
2805
 
2804
 
2810
 
2805
   p->offSymId = cmSymTblRegisterStaticSymbol(ctx->stH,"off");
2811
   p->offSymId = cmSymTblRegisterStaticSymbol(ctx->stH,"off");
2806
   p->onSymId  = cmSymTblRegisterStaticSymbol(ctx->stH,"on");
2812
   p->onSymId  = cmSymTblRegisterStaticSymbol(ctx->stH,"on");
2813
+  p->doneSymId= cmSymTblRegisterStaticSymbol(ctx->stH,"done");
2807
 
2814
 
2808
   cmDspSetDefaultUInt(  ctx, &p->inst, kLenWtId,   0,    cmDspSampleRate(ctx));
2815
   cmDspSetDefaultUInt(  ctx, &p->inst, kLenWtId,   0,    cmDspSampleRate(ctx));
2809
   cmDspSetDefaultUInt(  ctx, &p->inst, kShapeWtId, 0,    kSilenceWtId  );
2816
   cmDspSetDefaultUInt(  ctx, &p->inst, kShapeWtId, 0,    kSilenceWtId  );
2814
   cmDspSetDefaultSymbol(ctx, &p->inst, kCmdWtId,   p->onSymId );
2821
   cmDspSetDefaultSymbol(ctx, &p->inst, kCmdWtId,   p->onSymId );
2815
   cmDspSetDefaultUInt(  ctx, &p->inst, kOtWtId,    0,     5 );
2822
   cmDspSetDefaultUInt(  ctx, &p->inst, kOtWtId,    0,     5 );
2816
   cmDspSetDefaultDouble(ctx, &p->inst, kGainWtId,  0,     1.0 );
2823
   cmDspSetDefaultDouble(ctx, &p->inst, kGainWtId,  0,     1.0 );
2824
+  cmDspSetDefaultUInt(  ctx, &p->inst, kFIdxWtId,  0,     0 );
2817
 
2825
 
2818
   return &p->inst;
2826
   return &p->inst;
2819
 }
2827
 }
2889
     if( maxLoopCnt != -1 && p->loopCnt >= maxLoopCnt )
2897
     if( maxLoopCnt != -1 && p->loopCnt >= maxLoopCnt )
2890
     {
2898
     {
2891
       p->doneFl = true;
2899
       p->doneFl = true;
2892
-      vs_Zero(wt,n1);   // zero to the end of the buffer
2900
+      cmVOS_Zero(wt,n1);   // zero to the end of the buffer
2901
+
2902
+      p->cfn = p->cfi + cmDspUInt((cmDspInst_t*)p,kLenWtId) - p->wtn - n0;
2903
+      assert( p->cfn >= p->cfi );
2904
+
2893
     }
2905
     }
2894
     else
2906
     else
2895
     {
2907
     {
2904
       assert( actFrmCnt == n1 );
2916
       assert( actFrmCnt == n1 );
2905
 
2917
 
2906
       // reset the file index tracker
2918
       // reset the file index tracker
2907
-      p->fi = begSmpIdx + n1;
2919
+      p->fi  = begSmpIdx + n1;
2920
+      p->cfi = begSmpIdx;
2908
     }
2921
     }
2909
   }
2922
   }
2910
 
2923
 
2931
 
2944
 
2932
   assert(n1<wtSmpCnt);
2945
   assert(n1<wtSmpCnt);
2933
 
2946
 
2934
-  // if the EOF was encountered on a previous read
2947
+  // the first read always starts at p->wt + p->wti
2935
   if( p->doneFl )
2948
   if( p->doneFl )
2936
-  {
2937
-    vs_Zero(p->wt + p->wti,n0);
2938
-    vs_Zero(p->wt,n1);
2939
-  }
2949
+    cmVOS_Zero(p->wt + p->wti,n0);
2940
   else
2950
   else
2941
-  {
2942
-
2943
-    // the first read always starts at p->wt + p->wti
2944
     if( _cmDspWaveTableReadBlock(ctx, p, p->wt+p->wti, n0,begSmpIdx,endSmpIdx,maxLoopCnt  ) != kOkDspRC )
2951
     if( _cmDspWaveTableReadBlock(ctx, p, p->wt+p->wti, n0,begSmpIdx,endSmpIdx,maxLoopCnt  ) != kOkDspRC )
2945
       return cmDspInstErr(ctx,&p->inst,kVarNotValidDspRC,"An error occured while reading the wave table file.");
2952
       return cmDspInstErr(ctx,&p->inst,kVarNotValidDspRC,"An error occured while reading the wave table file.");
2946
 
2953
 
2947
-    p->wti += n0;
2954
+  p->wtn -= n0;   // decrease the count of available samples
2955
+  p->wti += n0;
2948
 
2956
 
2949
-    if( n1 > 0 )
2950
-    {
2951
-      // the second read always starts at the beginning of the wave table
2957
+  if( n1 > 0 )
2958
+  {
2959
+    // the second read always starts at the beginning of the wave table
2960
+    if( p->doneFl )
2961
+      cmVOS_Zero(p->wt,n1);
2962
+    else
2952
       if( _cmDspWaveTableReadBlock(ctx, p, p->wt, n1,begSmpIdx,endSmpIdx,maxLoopCnt  ) != kOkDspRC )
2963
       if( _cmDspWaveTableReadBlock(ctx, p, p->wt, n1,begSmpIdx,endSmpIdx,maxLoopCnt  ) != kOkDspRC )
2953
         return cmDspInstErr(ctx,&p->inst,kVarNotValidDspRC,"An error occured while reading the wave table file.");
2964
         return cmDspInstErr(ctx,&p->inst,kVarNotValidDspRC,"An error occured while reading the wave table file.");
2954
 
2965
 
2955
-      p->wti = n1;
2956
-    }
2957
-   
2966
+    p->wtn -= n1;  // decrease the count of available samples
2967
+    p->wti = n1;
2958
   }
2968
   }
2969
+   
2959
 
2970
 
2960
-  p->wtn -= rdSmpCnt;   // decrease the count of availabe sample
2971
+  //p->wtn -= rdSmpCnt;   // decrease the count of available samples
2961
 
2972
 
2962
   return kOkDspRC;
2973
   return kOkDspRC;
2963
 }
2974
 }
3003
 
3014
 
3004
   p->afH = afH;
3015
   p->afH = afH;
3005
   p->fi  = begSmpIdx;
3016
   p->fi  = begSmpIdx;
3017
+  p->cfi = begSmpIdx;
3006
   p->fn  = afInfo.frameCnt;
3018
   p->fn  = afInfo.frameCnt;
3007
   p->wti = 0;
3019
   p->wti = 0;
3008
   p->wtn = wtSmpCnt;
3020
   p->wtn = wtSmpCnt;
3060
   if(cmThreadIsValid(p->thH) == false)
3072
   if(cmThreadIsValid(p->thH) == false)
3061
     cmThreadCreate(&p->thH,_cmDspWaveTableThreadFunc,p,ctx->rpt);
3073
     cmThreadCreate(&p->thH,_cmDspWaveTableThreadFunc,p,ctx->rpt);
3062
 
3074
 
3063
-
3064
   if( cmThreadIsValid(p->thH) == false )
3075
   if( cmThreadIsValid(p->thH) == false )
3065
     return cmDspInstErr(ctx,&p->inst,kInvalidStateDspRC,"The audio file '%s' was not loaded because the audio load thread is invalid.",cmStringNullGuard(fn));
3076
     return cmDspInstErr(ctx,&p->inst,kInvalidStateDspRC,"The audio file '%s' was not loaded because the audio load thread is invalid.",cmStringNullGuard(fn));
3066
 
3077
 
3067
   p->loadFileFl = true;
3078
   p->loadFileFl = true;
3068
-  p->ctx    = ctx;
3079
+  p->ctx        = ctx;
3069
   cmDspSetUInt(ctx,&p->inst,kShapeWtId,kSilenceWtId);
3080
   cmDspSetUInt(ctx,&p->inst,kShapeWtId,kSilenceWtId);
3070
   cmDspSetStrcz(ctx,&p->inst,kFnWtId,fn);
3081
   cmDspSetStrcz(ctx,&p->inst,kFnWtId,fn);
3071
 
3082
 
3104
   if( p->wt == NULL )
3115
   if( p->wt == NULL )
3105
     p->wt           = cmLhResizeNZ(ctx->lhH,cmSample_t,p->wt,wtSmpCnt);
3116
     p->wt           = cmLhResizeNZ(ctx->lhH,cmSample_t,p->wt,wtSmpCnt);
3106
   else
3117
   else
3107
-    vs_Zero(p->wt,wtSmpCnt);
3118
+    cmVOS_Zero(p->wt,wtSmpCnt);
3108
 
3119
 
3109
   p->wtn          = wtSmpCnt;  // all samples in the wt are avail for filling
3120
   p->wtn          = wtSmpCnt;  // all samples in the wt are avail for filling
3110
   p->wti          = 0;         // beginning with the first sample
3121
   p->wti          = 0;         // beginning with the first sample
3122
       printf("Loading:%i %i %s\n",p->nxtBegSmpIdx,p->nxtEndSmpIdx,cmDspStrcz(&p->inst,kFnWtId));
3133
       printf("Loading:%i %i %s\n",p->nxtBegSmpIdx,p->nxtEndSmpIdx,cmDspStrcz(&p->inst,kFnWtId));
3123
       rc = _cmDspWaveTableStartFileLoadThread(ctx,p,cmDspStrcz(&p->inst,kFnWtId));
3134
       rc = _cmDspWaveTableStartFileLoadThread(ctx,p,cmDspStrcz(&p->inst,kFnWtId));
3124
       break;
3135
       break;
3125
-      /*
3126
-    case kWhiteWtId:
3127
-      vs_Rand(p->wt,wtSmpCnt,-1.0,1.0);
3128
-      break;
3129
-
3130
-    case kSineWtId:
3131
-      //vs_Sine(p->wt, wtSmpCnt, 1000.0*2*M_PI/wtSmpCnt, 0 );
3132
-      cmVOS_SynthSine(p->wt,wtSmpCnt,0,cmDspSampleRate(ctx),1.0);
3133
-      break;
3134
-      */
3135
 
3136
 
3136
     case kWhiteWtId:
3137
     case kWhiteWtId:
3137
       cmVOS_Random(p->wt,wtSmpCnt,-gain,gain);
3138
       cmVOS_Random(p->wt,wtSmpCnt,-gain,gain);
3152
       cmVOS_MultVS(p->wt,wtSmpCnt,gain);
3153
       cmVOS_MultVS(p->wt,wtSmpCnt,gain);
3153
       break;
3154
       break;
3154
 
3155
 
3155
-
3156
     case kSawWtId:
3156
     case kSawWtId:
3157
       cmVOS_SynthSawtooth(p->wt,wtSmpCnt,0,sr,hz,otCnt);
3157
       cmVOS_SynthSawtooth(p->wt,wtSmpCnt,0,sr,hz,otCnt);
3158
       cmVOS_MultVS(p->wt,wtSmpCnt,gain);
3158
       cmVOS_MultVS(p->wt,wtSmpCnt,gain);
3262
     // ... and there are rdSmpCnt avail locations in the wave table
3262
     // ... and there are rdSmpCnt avail locations in the wave table
3263
     if( p->wtn >= rdSmpCnt )
3263
     if( p->wtn >= rdSmpCnt )
3264
       rc =  _cmDspWaveTableReadAudioFile(ctx, p, wtSmpCnt, rdSmpCnt );
3264
       rc =  _cmDspWaveTableReadAudioFile(ctx, p, wtSmpCnt, rdSmpCnt );
3265
+
3266
+    // send the current audio file index
3267
+    if( p->doneFl && p->cfi < p->cfn && p->cfn <= (p->cfi + outCnt) )
3268
+      cmDspSetSymbol(ctx,inst,kDoneWtId,p->doneSymId);
3269
+    else
3270
+      cmDspSetUInt(ctx,inst,kFIdxWtId,p->cfi);
3271
+
3272
+    p->cfi += outCnt;
3273
+
3265
   }
3274
   }
3266
 
3275
 
3267
   return rc;
3276
   return rc;
3321
       {
3330
       {
3322
         if( cmDspSymbol(inst,kCmdWtId) == p->onSymId )
3331
         if( cmDspSymbol(inst,kCmdWtId) == p->onSymId )
3323
         {
3332
         {
3324
-          rc = _cmDspWaveTableReset(ctx,inst, evt );
3333
+          //rc = _cmDspWaveTableReset(ctx,inst, evt );
3334
+          rc =  _cmDspWaveTableCreateTable(ctx,p);
3335
+
3325
           cmDspSetSymbol(ctx,inst,kCmdWtId,p->onSymId);
3336
           cmDspSetSymbol(ctx,inst,kCmdWtId,p->onSymId);
3326
           p->phsOffs = 0;
3337
           p->phsOffs = 0;
3327
           p->phsLast = 0;
3338
           p->phsLast = 0;
3858
     if( sp != NULL )
3869
     if( sp != NULL )
3859
     {
3870
     {
3860
       double            gain = cmDspDouble(inst,p->baseGainId+i);
3871
       double            gain = cmDspDouble(inst,p->baseGainId+i);
3861
-      vs_SumMultVVS(dp,sp,n,gain);
3872
+      cmVOS_MultSumVVS(dp,n,sp,(cmSample_t)gain);
3862
     }
3873
     }
3863
   }
3874
   }
3864
 
3875
 
4015
   {
4026
   {
4016
     cmSample_t*       dp   = cmDspAudioBuf(ctx,inst,kBaseOutAsId+i,0);
4027
     cmSample_t*       dp   = cmDspAudioBuf(ctx,inst,kBaseOutAsId+i,0);
4017
     double            gain = cmDspDouble(inst,p->baseGainId+i);
4028
     double            gain = cmDspDouble(inst,p->baseGainId+i);
4018
-    vs_MultVVS(dp,sp,n,gain);
4029
+    cmVOS_MultVVS(dp,n,sp,(cmSample_t)gain);
4019
   }
4030
   }
4020
 
4031
 
4021
   return kOkDspRC;
4032
   return kOkDspRC;
4128
     return kOkDspRC;
4139
     return kOkDspRC;
4129
   }
4140
   }
4130
 
4141
 
4131
-  p->sum += vs_SquaredSum(sp,n);
4142
+  p->sum += cmVOS_SquaredSum(sp,n);
4132
   ++p->idx;
4143
   ++p->idx;
4133
 
4144
 
4134
   if( p->idx == p->bufN )
4145
   if( p->idx == p->bufN )
4991
   cmSegLineClassCons,
5002
   cmSegLineClassCons,
4992
   
5003
   
4993
   cmTimeLineClassCons,
5004
   cmTimeLineClassCons,
5005
+  cmScoreClassCons,
4994
   cmMidiFilePlayClassCons,
5006
   cmMidiFilePlayClassCons,
4995
   cmScFolClassCons,
5007
   cmScFolClassCons,
4996
 
5008
 

+ 0
- 1
dsp/cmDspFx.c View File

26
 #include "cmDspClass.h"
26
 #include "cmDspClass.h"
27
 #include "cmDspUi.h"
27
 #include "cmDspUi.h"
28
 #include "cmAudioFile.h"
28
 #include "cmAudioFile.h"
29
-#include "cmOp.h"
30
 
29
 
31
 #include "cmProcObj.h"
30
 #include "cmProcObj.h"
32
 #include "cmProcTemplateMain.h"
31
 #include "cmProcTemplateMain.h"

+ 10
- 0
vop/cmVectOpsRICode.h View File

504
   return dp;
504
   return dp;
505
 }
505
 }
506
 
506
 
507
+VECT_OP_TYPE* VECT_OP_FUNC(MultSumVVS)(VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp, VECT_OP_TYPE s )
508
+{
509
+  const VECT_OP_TYPE* dep = dbp + dn;
510
+  VECT_OP_TYPE* dp = dbp;
511
+  while( dbp < dep )
512
+    *dbp++ += *sbp++ * s;
513
+  return dp;
514
+}
515
+
516
+
507
 
517
 
508
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, VECT_OP_TYPE s1 )
518
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, VECT_OP_TYPE s1 )
509
 {
519
 {

+ 1
- 2
vop/cmVectOpsRIHdr.h View File

77
 VECT_OP_TYPE* VECT_OP_FUNC(SubVVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
77
 VECT_OP_TYPE* VECT_OP_FUNC(SubVVV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
78
 VECT_OP_TYPE* VECT_OP_FUNC(SubVSV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE  s0, const VECT_OP_TYPE* sb1p );
78
 VECT_OP_TYPE* VECT_OP_FUNC(SubVSV)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE  s0, const VECT_OP_TYPE* sb1p );
79
 
79
 
80
-
81
 VECT_OP_TYPE* VECT_OP_FUNC(AddVS)(  VECT_OP_TYPE* dp, unsigned dn, VECT_OP_TYPE v );
80
 VECT_OP_TYPE* VECT_OP_FUNC(AddVS)(  VECT_OP_TYPE* dp, unsigned dn, VECT_OP_TYPE v );
82
 VECT_OP_TYPE* VECT_OP_FUNC(AddVV)(  VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* v );
81
 VECT_OP_TYPE* VECT_OP_FUNC(AddVV)(  VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* v );
83
 VECT_OP_TYPE* VECT_OP_FUNC(AddVVS)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* v, VECT_OP_TYPE s );
82
 VECT_OP_TYPE* VECT_OP_FUNC(AddVVS)( VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* v, VECT_OP_TYPE s );
90
 VECT_OP_TYPE* VECT_OP_FUNC(MultVS)(  VECT_OP_TYPE* dbp, unsigned dn, VECT_OP_TYPE s );
89
 VECT_OP_TYPE* VECT_OP_FUNC(MultVS)(  VECT_OP_TYPE* dbp, unsigned dn, VECT_OP_TYPE s );
91
 VECT_OP_TYPE* VECT_OP_FUNC(MultVVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp, VECT_OP_TYPE s );
90
 VECT_OP_TYPE* VECT_OP_FUNC(MultVVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp, VECT_OP_TYPE s );
92
 VECT_OP_TYPE* VECT_OP_FUNC(MultVaVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp, VECT_OP_TYPE s );
91
 VECT_OP_TYPE* VECT_OP_FUNC(MultVaVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp, VECT_OP_TYPE s );
92
+VECT_OP_TYPE* VECT_OP_FUNC(MultSumVVS)(VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sbp, VECT_OP_TYPE s );
93
 
93
 
94
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, VECT_OP_TYPE sb1 );
94
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVS)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, VECT_OP_TYPE sb1 );
95
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVV)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
95
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVV)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
102
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVVZ)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
102
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVVZ)( VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p, const VECT_OP_TYPE* sb1p );
103
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVZ)(  VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p );
103
 VECT_OP_TYPE* VECT_OP_FUNC(DivVVZ)(  VECT_OP_TYPE* dbp, unsigned dn, const VECT_OP_TYPE* sb0p );
104
 
104
 
105
-
106
 // Divide columns of dp[:,i] by each value in the source vector sp[i]. 
105
 // Divide columns of dp[:,i] by each value in the source vector sp[i]. 
107
 VECT_OP_TYPE*  VECT_OP_FUNC(DivMS)(    VECT_OP_TYPE* dp, unsigned drn, unsigned dcn, const VECT_OP_TYPE* sp ); 
106
 VECT_OP_TYPE*  VECT_OP_FUNC(DivMS)(    VECT_OP_TYPE* dp, unsigned drn, unsigned dcn, const VECT_OP_TYPE* sp ); 
108
 
107
 

+ 10
- 0
vop/cmVectOpsTemplateCode.h View File

502
   return n;
502
   return n;
503
 }
503
 }
504
 
504
 
505
+VECT_OP_TYPE VECT_OP_FUNC(SquaredSum)( const VECT_OP_TYPE* bp, unsigned bn )
506
+{
507
+  VECT_OP_TYPE        sum = 0;
508
+  const VECT_OP_TYPE* ep  = bp + bn;
509
+
510
+  for(; bp < ep; ++bp )
511
+    sum += *bp * *bp;
512
+  return sum;
513
+}
514
+
505
 VECT_OP_TYPE  VECT_OP_FUNC(RMS)( const VECT_OP_TYPE* bp, unsigned bn, unsigned wndSmpCnt )
515
 VECT_OP_TYPE  VECT_OP_FUNC(RMS)( const VECT_OP_TYPE* bp, unsigned bn, unsigned wndSmpCnt )
506
 {
516
 {
507
   const VECT_OP_TYPE* ep = bp + bn;
517
   const VECT_OP_TYPE* ep = bp + bn;

+ 3
- 0
vop/cmVectOpsTemplateHdr.h View File

103
 /// Successive call to to ZeroCrossCount should preserve the value pointed to by delaySmpPtr.
103
 /// Successive call to to ZeroCrossCount should preserve the value pointed to by delaySmpPtr.
104
 unsigned      VECT_OP_FUNC(ZeroCrossCount)( const VECT_OP_TYPE* sp, unsigned n, VECT_OP_TYPE* delaySmpPtr);
104
 unsigned      VECT_OP_FUNC(ZeroCrossCount)( const VECT_OP_TYPE* sp, unsigned n, VECT_OP_TYPE* delaySmpPtr);
105
 
105
 
106
+// Calculuate the sum of the squares of all elements in bp[bn]. 
107
+VECT_OP_TYPE VECT_OP_FUNC(SquaredSum)( const VECT_OP_TYPE* bp, unsigned bn );
108
+
106
 /// sn must be <= wndSmpCnt. If sn < wndSmpCnt then sp[sn] is treated as a
109
 /// sn must be <= wndSmpCnt. If sn < wndSmpCnt then sp[sn] is treated as a
107
 /// a partially filled buffer padded with wndSmpCnt-sn zeros.
110
 /// a partially filled buffer padded with wndSmpCnt-sn zeros.
108
 /// rms = sqrt( sum(sp[1:sn] .* sp[1:sn]) / wndSmpCnt )
111
 /// rms = sqrt( sum(sp[1:sn] .* sp[1:sn]) / wndSmpCnt )

Loading…
Cancel
Save