cmProc2.h : Changed name of cmFIRTest() to cmFIRTest0(). Added cmFIRTest1().
This commit is contained in:
parent
c734464b0e
commit
ba5cd463f0
37
cmProc2.c
37
cmProc2.c
@ -823,7 +823,7 @@ cmRC_t cmFIRInitKaiser( cmFIR* p, unsigned procSmpCnt, double srate, double pass
|
|||||||
// in practice the ripple must be equal in the stop and pass band - so take the minimum between the two
|
// in practice the ripple must be equal in the stop and pass band - so take the minimum between the two
|
||||||
double d = cmMin(dPass,dStop);
|
double d = cmMin(dPass,dStop);
|
||||||
|
|
||||||
// convert the ripple bcmk to db
|
// convert the ripple back to db
|
||||||
double A = -20 * log10(d);
|
double A = -20 * log10(d);
|
||||||
|
|
||||||
// compute the kaiser alpha coeff
|
// compute the kaiser alpha coeff
|
||||||
@ -914,7 +914,7 @@ cmRC_t cmFIRExec( cmFIR* p, const cmSample_t* sbp, unsigned sn )
|
|||||||
// calc the output sample
|
// calc the output sample
|
||||||
while( cbp<cep)
|
while( cbp<cep)
|
||||||
{
|
{
|
||||||
// note that the delay is being iterated bcmkwards
|
// note that the delay is being iterated backwards
|
||||||
if( di == -1 )
|
if( di == -1 )
|
||||||
di=delayCnt-1;
|
di=delayCnt-1;
|
||||||
|
|
||||||
@ -936,7 +936,7 @@ cmRC_t cmFIRExec( cmFIR* p, const cmSample_t* sbp, unsigned sn )
|
|||||||
return cmOkRC;
|
return cmOkRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmFIRTest( cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH )
|
void cmFIRTest0( cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH )
|
||||||
{
|
{
|
||||||
unsigned N = 512;
|
unsigned N = 512;
|
||||||
cmKbRecd kb;
|
cmKbRecd kb;
|
||||||
@ -978,6 +978,37 @@ void cmFIRTest( cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH )
|
|||||||
cmFIRFree(&ffp);
|
cmFIRFree(&ffp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmFIRTest1( cmCtx* ctx )
|
||||||
|
{
|
||||||
|
const char* sfn = "/home/kevin/temp/sig.va";
|
||||||
|
const char* ffn = "/home/kevin/temp/fir.va";
|
||||||
|
unsigned N = 44100;
|
||||||
|
unsigned srate = N;
|
||||||
|
unsigned procSmpCnt = N;
|
||||||
|
double passHz = 15000;
|
||||||
|
double stopHz = 14000;
|
||||||
|
double passDb = 1.0;
|
||||||
|
double stopDb = 60.0;
|
||||||
|
unsigned flags = kHighPassFIRFl;
|
||||||
|
|
||||||
|
cmSample_t x[ procSmpCnt ];
|
||||||
|
|
||||||
|
cmVOS_Fill(x,procSmpCnt,0);
|
||||||
|
x[0] = 1;
|
||||||
|
|
||||||
|
cmVOS_Random(x,procSmpCnt, -1.0, 1.0 );
|
||||||
|
|
||||||
|
cmFIR* f = cmFIRAllocKaiser( ctx, NULL, procSmpCnt, srate, passHz, stopHz, stopDb, passDb, flags );
|
||||||
|
|
||||||
|
cmFIRExec( f, x, procSmpCnt );
|
||||||
|
|
||||||
|
cmVectArrayWriteMatrixS(ctx, ffn, f->outV, 1, f->outN );
|
||||||
|
cmVectArrayWriteMatrixS(ctx, sfn, x, 1, N );
|
||||||
|
|
||||||
|
cmFIRFree(&f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,7 +190,8 @@ extern "C" {
|
|||||||
cmRC_t cmFIRInitSinc( cmFIR* p, unsigned procSmpCnt, double srate, unsigned sincSmpCnt, double fcHz, unsigned flags, const double* wndV );
|
cmRC_t cmFIRInitSinc( cmFIR* p, unsigned procSmpCnt, double srate, unsigned sincSmpCnt, double fcHz, unsigned flags, const double* wndV );
|
||||||
cmRC_t cmFIRFinal( cmFIR* p );
|
cmRC_t cmFIRFinal( cmFIR* p );
|
||||||
cmRC_t cmFIRExec( cmFIR* p, const cmSample_t* sp, unsigned sn );
|
cmRC_t cmFIRExec( cmFIR* p, const cmSample_t* sp, unsigned sn );
|
||||||
void cmFIRTest();
|
void cmFIRTest0( cmRpt_t* rpt, cmLHeapH_t lhH, cmSymTblH_t stH );
|
||||||
|
void cmFIRTest1( cmCtx* ctx );
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------
|
||||||
// Apply a generic function to a windowed signal with a one sample hop size.
|
// Apply a generic function to a windowed signal with a one sample hop size.
|
||||||
@ -771,7 +772,7 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------
|
||||||
// cmVectArray buffers row vectors of arbitrary lenght in memory.
|
// cmVectArray buffers row vectors of arbitrary length in memory.
|
||||||
// The buffers may then be access using the cmVectArrayGetXXX() functions.
|
// The buffers may then be access using the cmVectArrayGetXXX() functions.
|
||||||
// The entire contents of the file may be written to a file using atVectArrayWrite().
|
// The entire contents of the file may be written to a file using atVectArrayWrite().
|
||||||
// The file may then be read in back into memory using cmVectArrayAllocFromFile()
|
// The file may then be read in back into memory using cmVectArrayAllocFromFile()
|
||||||
|
Loading…
Reference in New Issue
Block a user