From af002db8799d3a24018645e5a2d494112ca849ce Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 26 Nov 2013 13:44:32 -0500 Subject: [PATCH] cmDspPgm.c : Added more channels to _cmDspSysPgm_Goertzel() and parameters to support window size on the Goertzel detector. --- dsp/cmDspPgm.c | 61 +++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/dsp/cmDspPgm.c b/dsp/cmDspPgm.c index 1c3bcbb..9ee9abc 100644 --- a/dsp/cmDspPgm.c +++ b/dsp/cmDspPgm.c @@ -2453,25 +2453,38 @@ cmDspRC_t _cmDspSysPgm_AvailCh( cmDspSysH_t h, void** userPtrPtr ) cmDspRC_t _cmDspSysPgm_Goertzel( cmDspSysH_t h, void** userPtrPtr ) { cmDspRC_t rc; - const unsigned chCnt = 3; - double dfltHz = 19000; - double fcHzV[] = { 18000, dfltHz, 20000 }; + const unsigned chCnt = 8; + unsigned hopFact = 2; + double dfltHz = 18000.0; unsigned sigGenMode = 2; // sine double sigGenGain = 0.9; + double dfltMixGain = 1.0/chCnt; + double fcHzV[chCnt]; + unsigned i; - cmDspInst_t* ain = cmDspSysAllocAudioIn( h, 0, 1.0); - cmDspInst_t* amtr = cmDspSysAllocInst( h, "AMeter", NULL, 0 ); - - cmDspInst_t* goer = cmDspSysAllocInst( h, "Goertzel", NULL, 2, chCnt, fcHzV ); - cmDspInst_t** mtr = cmDspSysAllocInstArray(h, chCnt,"Meter", "Mtr", NULL, 3, 0.0, 0.0, 1.0 ); + for(i=0; i" ); @@ -2481,19 +2494,17 @@ cmDspRC_t _cmDspSysPgm_Goertzel( cmDspSysH_t h, void** userPtrPtr ) cmDspSysConnectAudio(h,ain,"out", goer, "in" ); cmDspSysConnectAudio(h,ain,"out", amtr, "in" ); + + cmDspSysConnectAudioN11N(h,sgV, "out", mix, "in", chCnt ); + cmDspSysConnectAudio(h,mix,"out", ao0, "in" ); + cmDspSysConnectAudio(h,mix,"out", ao1, "in" ); - - cmDspSysConnectAudio(h,sg,"out", ao0, "in" ); - cmDspSysConnectAudio(h,sg,"out", ao1, "in" ); - - cmDspSysInstallCb( h, hz, "val", sg, "hz", NULL); - cmDspSysInstallCb( h, ogain, "val", ao0, "gain", NULL); - cmDspSysInstallCb( h, ogain, "val", ao1, "gain", NULL); cmDspSysInstallCb( h, igain, "val", ain, "gain", NULL); - cmDspSysInstallCb(h,goer,"out-0", mtr[0], "in",NULL); - cmDspSysInstallCb(h,goer,"out-1", mtr[1], "in",NULL); - cmDspSysInstallCb(h,goer,"out-2", mtr[2], "in",NULL); - //cmDspSysInstallCb(h,goer,"out-1", prnt, "in",NULL); + cmDspSysInstallCbN1N1( h, hzV, "val", sgV, "hz", chCnt); + cmDspSysInstallCbN11N( h, hzV, "val", goer, "hz", chCnt ); + cmDspSysInstallCbN11N( h, gnV, "val", mix, "gain", chCnt); + cmDspSysInstallCb1NN1( h, goer, "out", mtrV, "in", chCnt ); + cmDspSysInstallCb( h, hop, "val", goer, "hop", NULL ); errLabel: return rc;