1 /*
2 
3  * Revision 1.1  1996/08/19  22:31:53  jaf
4  * Initial revision
5  *
6 
7 */
8 
9 /*  -- translated by f2c (version 19951025).
10    You must link the resulting object file with the libraries:
11 	-lf2c -lm   (in that order)
12 */
13 
14 #include "f2c.h"
15 
16 extern int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer *nsamp, real *ivrc);
17 
18 /* ********************************************************************* */
19 
20 /* 	IVFILT Version 48 */
21 
22 /*
23  * Revision 1.1  1996/08/19  22:31:53  jaf
24  * Initial revision
25  * */
26 /* Revision 1.3  1996/03/15  21:36:29  jaf */
27 /* Just added a few comments about which array indices of the arguments */
28 /* are used, and mentioning that this subroutine has no local state. */
29 
30 /* Revision 1.2  1996/03/13  00:01:00  jaf */
31 /* Comments added explaining that none of the local variables of this */
32 /* subroutine need to be saved from one invocation to the next. */
33 
34 /* Revision 1.1  1996/02/07 14:47:34  jaf */
35 /* Initial revision */
36 
37 
38 /* ********************************************************************* */
39 
40 /*   2nd order inverse filter, speech is decimated 4:1 */
41 
42 /* Input: */
43 /*  LEN    - Length of speech buffers */
44 /*  NSAMP  - Number of samples to filter */
45 /*  LPBUF  - Low pass filtered speech buffer */
46 /*           Indices LEN-NSAMP-7 through LEN read. */
47 /* Output: */
48 /*  IVBUF  - Inverse filtered speech buffer */
49 /*           Indices LEN-NSAMP+1 through LEN written. */
50 /*  IVRC   - Inverse filter reflection coefficients (for voicing) */
51 /*          Indices 1 and 2 both written (also read, but only after writing).
52 */
53 
54 /* This subroutine has no local state. */
55 
ivfilt_(real * lpbuf,real * ivbuf,integer * len,integer * nsamp,real * ivrc)56 /* Subroutine */ int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer *
57 	nsamp, real *ivrc)
58 {
59     /* System generated locals */
60     integer i__1;
61 
62     /* Local variables */
63     integer i__, j, k;
64     real r__[3], pc1, pc2;
65 
66 /* 	Arguments */
67 /*       Local variables that need not be saved */
68 /*       Local state */
69 /*       None */
70 /*  Calculate Autocorrelations */
71     /* Parameter adjustments */
72     --ivbuf;
73     --lpbuf;
74     --ivrc;
75 
76     /* Function Body */
77     for (i__ = 1; i__ <= 3; ++i__) {
78 	r__[i__ - 1] = 0.f;
79 	k = (i__ - 1) << 2;
80 	i__1 = *len;
81 	for (j = (i__ << 2) + *len - *nsamp; j <= i__1; j += 2) {
82 	    r__[i__ - 1] += lpbuf[j] * lpbuf[j - k];
83 	}
84     }
85 /*  Calculate predictor coefficients */
86     pc1 = 0.f;
87     pc2 = 0.f;
88     ivrc[1] = 0.f;
89     ivrc[2] = 0.f;
90     if (r__[0] > 1e-10f) {
91 	ivrc[1] = r__[1] / r__[0];
92 	ivrc[2] = (r__[2] - ivrc[1] * r__[1]) / (r__[0] - ivrc[1] * r__[1]);
93 	pc1 = ivrc[1] - ivrc[1] * ivrc[2];
94 	pc2 = ivrc[2];
95     }
96 /*  Inverse filter LPBUF into IVBUF */
97     i__1 = *len;
98     for (i__ = *len + 1 - *nsamp; i__ <= i__1; ++i__) {
99 	ivbuf[i__] = lpbuf[i__] - pc1 * lpbuf[i__ - 4] - pc2 * lpbuf[i__ - 8];
100     }
101     return 0;
102 } /* ivfilt_ */
103 
104