From 834b6f421f615b4c387e3d3d8e35ef7ad161033f Mon Sep 17 00:00:00 2001 From: Kevin Larke Date: Fri, 22 May 2015 14:10:24 -0700 Subject: [PATCH] cmVectOpsTemplateHdr.h/Code.h : Added optional window function arg. and fixed high-pass filter generation in LP_Sinc(). Added use of cmAbs() generic to NormToAbsMax(). --- vop/cmVectOpsTemplateCode.h | 36 +++++++++++++++++++++++++++--------- vop/cmVectOpsTemplateHdr.h | 6 ++++-- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/vop/cmVectOpsTemplateCode.h b/vop/cmVectOpsTemplateCode.h index a0fa2fa..2c71815 100644 --- a/vop/cmVectOpsTemplateCode.h +++ b/vop/cmVectOpsTemplateCode.h @@ -332,13 +332,13 @@ unsigned VECT_OP_FUNC(NormToAbsMax)( VECT_OP_TYPE* dp, unsigned dn, VECT_OP_TY unsigned i = 0; unsigned mi = 0; - VECT_OP_TYPE mx = fabs(dp[0]); + VECT_OP_TYPE mx = cmAbs(dp[0]); for(i=1; imx ) + if( cmAbs(dp[i])>mx ) { mi = i; - mx = fabs(dp[i]); + mx = cmAbs(dp[i]); } VECT_OP_FUNC(MultVS)(dp,dn,fact/mx); @@ -2339,33 +2339,51 @@ VECT_OP_TYPE* VECT_OP_FUNC(FilterFilter)(struct cmFilter_str* f, cmRC_t (*fun -VECT_OP_TYPE* VECT_OP_FUNC(LP_Sinc)(VECT_OP_TYPE* dp, unsigned dn, double srate, double fcHz, unsigned flags ) +VECT_OP_TYPE* VECT_OP_FUNC(LP_Sinc)(VECT_OP_TYPE* dp, unsigned dn, const VECT_OP_TYPE* wndV, double srate, double fcHz, unsigned flags ) { VECT_OP_TYPE* rp = dp; int dM = dn % 2; // dM is used to handle odd length windows int M = (dn - dM)/2; int Mi = -M; - double signFact = cmIsFlag(flags, kHighPass_LPSincFl) ? -0.5 : 0.5; double phsFact = 2.0 * M_PI * fcHz / srate; double sum = 0; + VECT_OP_TYPE noWndV[ dn ]; + // if no window was given then create a unity window + if( wndV == NULL ) + { + VECT_OP_FUNC(Fill)(noWndV,dn,1); + wndV = noWndV; + } M += dM; //printf("M=%i Mi=%i sign:%f phs:%f\n",M,Mi,signFact,phsFact); - - for(; Mi