|
@@ -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
|
|