ivfilt.c

Go to the documentation of this file.
00001 /*
00002 
00003 $Log$
00004 Revision 1.16  2004/06/26 03:50:14  markster
00005 Merge source cleanups (bug #1911)
00006 
00007 Revision 1.15  2003/09/19 01:20:22  markster
00008 Code cleanups (bug #66)
00009 
00010 Revision 1.2  2003/09/19 01:20:22  markster
00011 Code cleanups (bug #66)
00012 
00013 Revision 1.1.1.1  2003/02/12 13:59:15  matteo
00014 mer feb 12 14:56:57 CET 2003
00015 
00016 Revision 1.2  2000/01/05 08:20:39  markster
00017 Some OSS fixes and a few lpc changes to make it actually work
00018 
00019  * Revision 1.1  1996/08/19  22:31:53  jaf
00020  * Initial revision
00021  *
00022 
00023 */
00024 
00025 /*  -- translated by f2c (version 19951025).
00026    You must link the resulting object file with the libraries:
00027    -lf2c -lm   (in that order)
00028 */
00029 
00030 #include "f2c.h"
00031 
00032 #ifdef P_R_O_T_O_T_Y_P_E_S
00033 extern int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer *nsamp, real *ivrc);
00034 #endif
00035 
00036 /* ********************************************************************* */
00037 
00038 /*    IVFILT Version 48 */
00039 
00040 /* $Log$
00041  * Revision 1.16  2004/06/26 03:50:14  markster
00042  * Merge source cleanups (bug #1911)
00043  *
00044  * Revision 1.15  2003/09/19 01:20:22  markster
00045  * Code cleanups (bug #66)
00046  *
00047  * Revision 1.2  2003/09/19 01:20:22  markster
00048  * Code cleanups (bug #66)
00049  *
00050  * Revision 1.1.1.1  2003/02/12 13:59:15  matteo
00051  * mer feb 12 14:56:57 CET 2003
00052  *
00053  * Revision 1.2  2000/01/05 08:20:39  markster
00054  * Some OSS fixes and a few lpc changes to make it actually work
00055  *
00056  * Revision 1.1  1996/08/19  22:31:53  jaf
00057  * Initial revision
00058  * */
00059 /* Revision 1.3  1996/03/15  21:36:29  jaf */
00060 /* Just added a few comments about which array indices of the arguments */
00061 /* are used, and mentioning that this subroutine has no local state. */
00062 
00063 /* Revision 1.2  1996/03/13  00:01:00  jaf */
00064 /* Comments added explaining that none of the local variables of this */
00065 /* subroutine need to be saved from one invocation to the next. */
00066 
00067 /* Revision 1.1  1996/02/07 14:47:34  jaf */
00068 /* Initial revision */
00069 
00070 
00071 /* ********************************************************************* */
00072 
00073 /*   2nd order inverse filter, speech is decimated 4:1 */
00074 
00075 /* Input: */
00076 /*  LEN    - Length of speech buffers */
00077 /*  NSAMP  - Number of samples to filter */
00078 /*  LPBUF  - Low pass filtered speech buffer */
00079 /*           Indices LEN-NSAMP-7 through LEN read. */
00080 /* Output: */
00081 /*  IVBUF  - Inverse filtered speech buffer */
00082 /*           Indices LEN-NSAMP+1 through LEN written. */
00083 /*  IVRC   - Inverse filter reflection coefficients (for voicing) */
00084 /*          Indices 1 and 2 both written (also read, but only after writing).
00085 */
00086 
00087 /* This subroutine has no local state. */
00088 
00089 /* Subroutine */ int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer *
00090    nsamp, real *ivrc)
00091 {
00092     /* System generated locals */
00093     integer i__1;
00094 
00095     /* Local variables */
00096     integer i__, j, k;
00097     real r__[3], pc1, pc2;
00098 
00099 /*    Arguments */
00100 /*       Local variables that need not be saved */
00101 /*       Local state */
00102 /*       None */
00103 /*  Calculate Autocorrelations */
00104     /* Parameter adjustments */
00105     --ivbuf;
00106     --lpbuf;
00107     --ivrc;
00108 
00109     /* Function Body */
00110     for (i__ = 1; i__ <= 3; ++i__) {
00111    r__[i__ - 1] = 0.f;
00112    k = (i__ - 1) << 2;
00113    i__1 = *len;
00114    for (j = (i__ << 2) + *len - *nsamp; j <= i__1; j += 2) {
00115        r__[i__ - 1] += lpbuf[j] * lpbuf[j - k];
00116    }
00117     }
00118 /*  Calculate predictor coefficients */
00119     pc1 = 0.f;
00120     pc2 = 0.f;
00121     ivrc[1] = 0.f;
00122     ivrc[2] = 0.f;
00123     if (r__[0] > 1e-10f) {
00124    ivrc[1] = r__[1] / r__[0];
00125    ivrc[2] = (r__[2] - ivrc[1] * r__[1]) / (r__[0] - ivrc[1] * r__[1]);
00126    pc1 = ivrc[1] - ivrc[1] * ivrc[2];
00127    pc2 = ivrc[2];
00128     }
00129 /*  Inverse filter LPBUF into IVBUF */
00130     i__1 = *len;
00131     for (i__ = *len + 1 - *nsamp; i__ <= i__1; ++i__) {
00132    ivbuf[i__] = lpbuf[i__] - pc1 * lpbuf[i__ - 4] - pc2 * lpbuf[i__ - 8];
00133     }
00134     return 0;
00135 } /* ivfilt_ */
00136 

Generated on Thu Apr 16 06:27:37 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6