www.pudn.com > lpc.zip > ivfilt_i.c
/**********************************************************************
*
* IVFILT Version 48
*
**********************************************************************
* For dam9.spd fp skips 138 blocks, int skipps 299.
*
* 2nd order inverse filter, speech is decimated 4:1
*
* Inputs:
* LEN - Length of speech buffers
* NSAMP - Number of samples to filter
* LPBUF - Low pass filtered speech buffer
* Output:
* IVBUF - Inverse filtered speech buffer
* IVRC - Inverse filter reflection coefficients (for voicing)
*/
#include "ourstuff.h"
#include "config.ch"
#include "lpcdefs.h"
ivfilt_i( lpbuf, ivbuf, ivrc )
int_type ivbuf[], lpbuf[], ivrc[];
{
int_type i, j, k;
int_type r[3], pc1, pc2;
/* Calculate Autocorrelations */
for(i=0;i<=2;i++) {
r[i] = 0;
k = 4*i;
for( j = (i+1)*4+PWLEN-LFRAME;j<=PWLEN;j+=2) {
r[i] += (((long_type)lpbuf[j]*(long_type)lpbuf[j-k]) >> 14);
}
}
/* Calculate predictor coefficients */
pc1 = 0;
pc2 = 0;
ivrc[1] = 0;
ivrc[2] = 0;
if(r[0]>0) {
ivrc[1] = (r[1] << 14)/r[0];
if((r[0]-(((long_type)ivrc[1]*(long_type)r[1]) >> 14)) != 0)
ivrc[2] = ((r[2]<<14) - ivrc[1]*r[1]) / (r[0]-(((long_type)ivrc[1]*(long_type)r[1]) >> 14));
pc1 = ivrc[1] - (((long_type)ivrc[1]*(long_type)ivrc[2]) >> 14);
pc2 = ivrc[2];
}
/* Inverse filter LPBUF into IVBUF */
for(i=PWLEN+1-LFRAME;i<=PWLEN;i++) {
ivbuf[i] = lpbuf[i] - (((long_type)pc1*(long_type)lpbuf[i-4])>>14) - (((long_type)pc2*(long_type)lpbuf[i-8])>>14);
}
}