EXPORT_FCN void MWDSP_blms_an_wn_CC( const creal32_T *inSigU, const creal32_T *deSigU, const real32_T muU, creal32_T *inBuff, creal32_T *wgtBuff, const int_T FilterLength, const int_T BlockLength, const real32_T LkgFactor, const int_T FrmLen, creal32_T *outY, creal32_T *errY) { int_T i,j,k,m=0; const int_T FiltLen_minus_1 = FilterLength-1; const int_T NumberOfFrame = (int_T)(FrmLen/BlockLength + 0.5); /* To avoid precision problem */ const int_T bytesPerFiltLen = FilterLength*sizeof(creal32_T); const int_T bytesPerBlkLen = BlockLength*sizeof(creal32_T); memset(outY,0,sizeof(creal32_T)*FrmLen); for (i=0; i<NumberOfFrame; i++) { /* Step-1: Copy new BlockLength samples at the END of the linear buffer (has length = FilterLength+BlockLength */ memmove(inBuff, (inBuff + BlockLength), bytesPerFiltLen); memcpy((inBuff + FilterLength), inSigU + i*BlockLength, bytesPerBlkLen); /* Step-2: convolve inBuff_vector (length= FilterLength+BlockLength) and wgtIC_vector(length=FilterLength) (not yet updated) and */ /* resultantLen = FilterLength+BlockLength + FilterLength - 1, but we need only FilterLength+1:(FilterLength+BlockLength) */ for (j=0; j <BlockLength; j++) { int_T j_plus_1 = j+1; for (k=0; k < FilterLength; k++) { outY[m].re += CMULT_RE(wgtBuff[FiltLen_minus_1-k],inBuff[k+j_plus_1]); outY[m].im += CMULT_IM(wgtBuff[FiltLen_minus_1-k],inBuff[k+j_plus_1]); } /* Step-3: get error for the current sample in the block */ errY[m].re = deSigU[m].re - outY[m].re; errY[m].im = deSigU[m].im - outY[m].im; m++; } /* Step-4: correlate inBuff_vector (length= FilterLength+BlockLength) and errY_vector(length=BlockLength) and */ /* resultantLen = FilterLength+BlockLength + FilterLength - 1, but we need only BlockLength+1:(FilterLength+BlockLength) */ m=i*BlockLength; for (j=0; j <FilterLength; j++) { creal32_T tmpSum = {0,0}; int_T j_plus_1 = j+1; int_T FiltLen_minus_1_minus_j = FiltLen_minus_1-j; for (k=0; k < BlockLength; k++) { tmpSum.re += muU * CMULT_YCONJ_RE(errY[m+k], inBuff[k+j_plus_1]); tmpSum.im += muU * CMULT_YCONJ_IM(errY[m+k], inBuff[k+j_plus_1]); } wgtBuff[FiltLen_minus_1_minus_j].re = tmpSum.re + LkgFactor*(wgtBuff[FiltLen_minus_1_minus_j].re); wgtBuff[FiltLen_minus_1_minus_j].im = tmpSum.im + LkgFactor*(wgtBuff[FiltLen_minus_1_minus_j].im); } m=(i+1)*BlockLength; } }
EXPORT_FCN void MWDSP_2ChSBank_DF_ZZ( const creal_T *inputToLongFilt, const creal_T *inputToShortFilt, creal_T *out, creal_T *longFiltTapBuf, creal_T *shortFiltTapBuf, const creal_T *const longFilt, const creal_T *const shortFilt, int32_T *longFiltTapIdx, int32_T *shortFiltTapIdx, const int_T numChans, const int_T inFrameSize, const int_T polyphaseLongFiltLen, const int_T polyphaseShortFiltLen ) { const int_T iFactor = 2; /* initialize local variables to rid compiler warnings */ int_T k = numChans; int_T curTapLong = 0; int_T curTapShort = 0; int_T jlong = 0; int_T jshort = 0; creal_T sum; sum.re = 0.0; sum.im = 0.0; /* loop through k=numChans channels */ do { int_T i = inFrameSize; /* make per channel copy of long and short tap indices which are common to all channels */ curTapLong = *longFiltTapIdx; curTapShort = *shortFiltTapIdx; /* loop through inFrameSize samples in each input frame */ while (i--) { int_T m = iFactor; /* make per sample copies of filter addresses and input tap delay buffer addresses which are common to all input samples */ const creal_T *cffLong = longFilt; const creal_T *cffShort = shortFilt; creal_T *memLong = longFiltTapBuf + curTapLong; creal_T *memShort = shortFiltTapBuf + curTapShort; /* read input sample into the tap delay buffer locations */ *memLong = *inputToLongFilt++; *memShort = *inputToShortFilt++; /* loop through iFactor interpolation phases output results to output buffer location pointed at by out */ while (m--) { /* perform direct form FIR filtering on the first curTapLong taps of the Long Tap Delay Buffer (longFiltTapBuf) */ for (jlong = 0; jlong <= curTapLong; jlong++) { sum.re += CMULT_RE(*memLong, *cffLong); sum.im += CMULT_IM(*memLong, *cffLong); --memLong; ++cffLong; } /* perform direct form FIR filtering on the first curTapShort taps of the Short Tap Delay Buffer (shortFiltTapBuf) and add the intermediate result to previous sum */ for (jshort = 0; jshort <= curTapShort; jshort++) { sum.re += CMULT_RE(*memShort, *cffShort); sum.im += CMULT_IM(*memShort, *cffShort); --memShort; ++cffShort; } /* point memLong and memShort to the last tap delay buffer locations */ memLong += polyphaseLongFiltLen; memShort += polyphaseShortFiltLen; /* perform direct form FIR filtering on the remaining taps for the long and short filters and add their results */ while(jlong++ < polyphaseLongFiltLen) { sum.re += CMULT_RE(*memLong, *cffLong); sum.im += CMULT_IM(*memLong, *cffLong); --memLong; ++cffLong; } while(jshort++ < polyphaseShortFiltLen) { sum.re += CMULT_RE(*memShort, *cffShort); sum.im += CMULT_IM(*memShort, *cffShort); --memShort; ++cffShort; } /* output sum to out and reset sum */ *out++ = sum; sum.re = 0.0; sum.im = 0.0; } /* increment circular buffer pointers : curTapLong and curTapShort */ if ( (++curTapLong) >= polyphaseLongFiltLen ) curTapLong = 0; if ( (++curTapShort) >= polyphaseShortFiltLen ) curTapShort = 0; } /* inFrameSize */ /* increment for next channel */ longFiltTapBuf += polyphaseLongFiltLen; shortFiltTapBuf += polyphaseShortFiltLen; } while ((--k) > 0); /* Update stored indices for next function call */ *longFiltTapIdx = curTapLong; *shortFiltTapIdx = curTapShort; }