1.4.2.16 DSP_FilterIIRBQ16_parallel8 Function
Performs a 8 parallel single-pass IIR Biquad Filters, and sums the result.
Description
int16_t DSP_FilterIIRBQ16_parallel8(int16_t Xin, PARM_EQUAL_FILTER *pFilter);
Calculates a 8 parallel, single pass IIR biquad filters on Xin, sums the result and delivers the result as a 16-bit output. All math is performed using 32 bit instructions, which results truncated to 16-bits for the output. The delay register is stored as a 32-bit value for subsequent functions. Output is tuned by 2 multiplier factors. First each parallel section has a fractional gain (attenuation) that enables individual scaling of that section. Second, a global binary (log2N) gain is applied to the result. The combination of gain factors enable both gain and attenuation. All values are fractional Q15 and Q31, see data structure for specifics.
Y = Y7/8 + Y6/8 + Y5/8 + Y4/8 + Y3/8 + Y2/8 + Y1/8 + Y0/8 where each Yn filter element represents a unique IIR biquad: Yn = X(0)*b0 + (b1 * X(n-1)) + (b2 * X(n-2)) - (a1 * Yn(-1)) - (a2 * Yn(-2))
Preconditions
Delay register values should be initialized to zero. The sum of all fracgain should be <= 1
Parameters
Xin input data element X (int16_t)
pFilter pointer to filter coef and delay structure
Returns
Sample output Y (int16_t)
Remarks
The delay register values should be initialized to zero prior to the first call to the function, they are updated each pass. A gain of 2 has been hard coded into the function. This implies that all coefs should be input at half value. This is purposeful, since many filter designs need a div2 to have each coef between the required -1
Example
PARM_EQUAL_FILTER filtArrayPara[8]; uint16_t dataY, dataX; _// fill entire Filter Array with coefs_ for (i=0;i<8;i++) { filtArrayPara[i].Z[0]=0; filtArrayPara[i].Z[1]=0; filtArrayPara[i].G.fracGain = 0x7FFF; _// gain = 1 default_ filtArrayPara[i].G.expGain = 1; _// == 2\^N; gain of 2_ _// note all coefs are half value of original design, gain handled in algorithm_ _// none pass -- default_ filtArrayPara[i].b[0]=0; _// feed forward b0 coef_ filtArrayPara[i].b[1]=0; _// feed forward b1 coef_ filtArrayPara[i].b[2]=0; _// feed forward b2 coef_ _// note all coefs are half value of original design, gain handled in algorithm_ _// note subtract is handled in algorithm, so coefs go in at actual value_ filtArrayPara[i].a[0]=0; _// feedback a1 coef_ filtArrayPara[i].a[1]=0; _// feedback a2 coef_ } _// 1K bandpass Q=0.9_ filtArrayPara[7].G.fracGain = 0x4000; _// gain = 0.5 because using 2 outputs_ _// note all coefs are half value of original design, gain handled in algorithm_ filtArrayPara[7].b[0]=0x04ad; filtArrayPara[7].b[1]=0; _// feed forward b1 coef_ filtArrayPara[7].b[2]=0xfb53; _// feed forward b2 coef_ _// note all coefs are half value of original design, gain handled in algorithm_ _// note subtract is handled in algorithm, so coefs go in at actual value_ filtArrayPara[7].a[0]=0x8a90; _// feedback a1 coef_ filtArrayPara[7].a[1]=0x36a4; _// feedback a2 coef_ _// 300 Hz bandpass Q=0.9_ filtArrayPara[6].G.fracGain = 0x1000; _// gain = 0.125 as an example_ _// note all coefs are half value of original design, gain handled in algorithm_ filtArrayPara[6].b[0]=0x017b; _// feed forward b0 coef_ filtArrayPara[6].b[1]=0; _// feed forward b1 coef_ filtArrayPara[6].b[2]=0xfe85; _// feed forward b2 coef_ _// note all coefs are half value of original design, gain handled in algorithm_ _// note subtract is handled in algorithm, so coefs go in at actual value_ filtArrayPara[6].a[0]=0x8316; _// feedback a1 coef_ filtArrayPara[6].a[1]=0x3d08; _// feedback a2 coef_ for (i=0;i<256;i++) { _// *** get input data here_ dataX = compound_300_1K_hz16[i]; dataY = DSP_FilterIIRBQ16_cascade8_fast(dataX, filtArray); _// *** do something with the DataY here_ }
C
int16_t DSP_FilterIIRBQ16_parallel8 (int16_t Xin , PARM_EQUAL_FILTER * pFilter );