Selaa lähdekoodia

cmProc2.h : Changed name of cmFIRTest() to cmFIRTest0(). Added cmFIRTest1().

master
Kevin Larke 9 vuotta sitten
vanhempi
commit
ba5cd463f0
2 muutettua tiedostoa jossa 38 lisäystä ja 6 poistoa
  1. 34
    3
      cmProc2.c
  2. 4
    3
      cmProc2.h

+ 34
- 3
cmProc2.c Näytä tiedosto

@@ -823,7 +823,7 @@ cmRC_t cmFIRInitKaiser( cmFIR* p, unsigned procSmpCnt, double srate, double pass
823 823
   // in practice the ripple must be equal in the stop and pass band - so take the minimum between the two
824 824
   double d        = cmMin(dPass,dStop);
825 825
 
826
-  // convert the ripple bcmk to db
826
+  // convert the ripple back to db
827 827
   double A = -20 * log10(d);
828 828
 
829 829
   // compute the kaiser alpha coeff
@@ -914,7 +914,7 @@ cmRC_t cmFIRExec( cmFIR* p, const cmSample_t* sbp, unsigned sn )
914 914
     // calc the output sample
915 915
     while( cbp<cep)
916 916
     {
917
-      // note that the delay is being iterated bcmkwards
917
+      // note that the delay is being iterated backwards
918 918
       if( di == -1 )
919 919
       di=delayCnt-1;
920 920
 
@@ -936,7 +936,7 @@ cmRC_t cmFIRExec( cmFIR* p, const cmSample_t* sbp, unsigned sn )
936 936
   return cmOkRC;
937 937
 }
938 938
 
939
-void cmFIRTest( cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH )
939
+void cmFIRTest0( cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH )
940 940
 {
941 941
   unsigned N = 512;
942 942
   cmKbRecd kb;
@@ -978,6 +978,37 @@ void cmFIRTest( cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH )
978 978
   cmFIRFree(&ffp);
979 979
 }
980 980
 
981
+void cmFIRTest1( cmCtx* ctx )
982
+{
983
+  const char* sfn        = "/home/kevin/temp/sig.va";
984
+  const char* ffn        = "/home/kevin/temp/fir.va";
985
+  unsigned    N          = 44100;
986
+  unsigned    srate      = N;
987
+  unsigned    procSmpCnt = N;
988
+  double      passHz     = 15000;
989
+  double      stopHz     = 14000;
990
+  double      passDb     = 1.0;
991
+  double      stopDb     = 60.0;
992
+  unsigned    flags      = kHighPassFIRFl;
993
+  
994
+  cmSample_t x[ procSmpCnt ];
995
+  
996
+  cmVOS_Fill(x,procSmpCnt,0);
997
+  x[0] = 1;
998
+
999
+  cmVOS_Random(x,procSmpCnt, -1.0, 1.0 );
1000
+
1001
+  cmFIR* f = cmFIRAllocKaiser( ctx, NULL, procSmpCnt, srate, passHz, stopHz, stopDb, passDb, flags );
1002
+
1003
+  cmFIRExec( f, x, procSmpCnt ); 
1004
+
1005
+  cmVectArrayWriteMatrixS(ctx, ffn, f->outV, 1, f->outN );
1006
+  cmVectArrayWriteMatrixS(ctx, sfn, x,       1, N );
1007
+
1008
+  cmFIRFree(&f);
1009
+  
1010
+}
1011
+
981 1012
 //------------------------------------------------------------------------------------------------------------
982 1013
 
983 1014
 

+ 4
- 3
cmProc2.h Näytä tiedosto

@@ -190,8 +190,9 @@ extern "C" {
190 190
   cmRC_t cmFIRInitSinc(   cmFIR* p, unsigned procSmpCnt, double srate, unsigned sincSmpCnt, double fcHz,   unsigned flags, const double* wndV );
191 191
   cmRC_t cmFIRFinal(      cmFIR* p );
192 192
   cmRC_t cmFIRExec(       cmFIR* p, const cmSample_t* sp, unsigned sn );
193
-  void   cmFIRTest();
194
-
193
+  void   cmFIRTest0( cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH );
194
+  void   cmFIRTest1( cmCtx* ctx );
195
+  
195 196
   //------------------------------------------------------------------------------------------------------------
196 197
   // Apply a generic function to a windowed signal with a one sample hop size.
197 198
 
@@ -771,7 +772,7 @@ extern "C" {
771 772
 
772 773
 
773 774
   //------------------------------------------------------------------------------------------------------------
774
-  // cmVectArray buffers row vectors of arbitrary lenght in  memory.
775
+  // cmVectArray buffers row vectors of arbitrary length in  memory.
775 776
   // The buffers may then be access using the cmVectArrayGetXXX() functions.
776 777
   // The entire contents of the file may be written to a file using atVectArrayWrite().
777 778
   // The file may then be read in back into memory using cmVectArrayAllocFromFile()

Loading…
Peruuta
Tallenna