1 /*
2 
3  * Revision 1.1  1996/08/19  22:32:31  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 difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr);
17 
18 /* ********************************************************************** */
19 
20 /* 	DIFMAG Version 49 */
21 
22 /*
23  * Revision 1.1  1996/08/19  22:32:31  jaf
24  * Initial revision
25  * */
26 /* Revision 1.3  1996/03/15  23:09:39  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  14:41:31  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:45:04  jaf */
35 /* Initial revision */
36 
37 
38 /* ********************************************************************* */
39 
40 /*  Compute Average Magnitude Difference Function */
41 
42 /* Inputs: */
43 /*  SPEECH - Low pass filtered speech */
44 /*           Indices MIN_N1 through MAX_N1+LPITA-1 are read, where */
45 /*      MIN_N1 = (MAXLAG - MAX_TAU)/2+1  MAX_TAU = max of TAU(I) for I=1,LTAU
46 */
47 /*      MAX_N1 = (MAXLAG - MIN_TAU)/2+1  MIN_TAU = min of TAU(I) for I=1,LTAU
48 */
49 /*  LPITA  - Length of speech buffer */
50 /*  TAU    - Table of lags */
51 /*           Indices 1 through LTAU read. */
52 /*  LTAU   - Number of lag values to compute */
53 /*  MAXLAG - Maximum possible lag value */
54 /* Outputs: */
55 /*  (All of these outputs are also read, but only after being written.) */
56 /*  AMDF   - Average Magnitude Difference for each lag in TAU */
57 /*           Indices 1 through LTAU written */
58 /*  MINPTR - Index of minimum AMDF value */
59 /*  MAXPTR - Index of maximum AMDF value */
60 
61 /* This subroutine has no local state. */
62 
difmag_(real * speech,integer * lpita,integer * tau,integer * ltau,integer * maxlag,real * amdf,integer * minptr,integer * maxptr)63 /* Subroutine */ int difmag_(real *speech, integer *lpita, integer *tau,
64 	integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *
65 	maxptr)
66 {
67     /* System generated locals */
68     integer i__1, i__2;
69     real r__1;
70 
71     /* Local variables */
72     integer i__, j, n1, n2;
73     real sum;
74 
75 /*       Arguments */
76 /*       Local variables that need not be saved */
77 /*       Local state */
78 /*       None */
79     /* Parameter adjustments */
80     --amdf;
81     --tau;
82     --speech;
83 
84     /* Function Body */
85     *minptr = 1;
86     *maxptr = 1;
87     i__1 = *ltau;
88     for (i__ = 1; i__ <= i__1; ++i__) {
89 	n1 = (*maxlag - tau[i__]) / 2 + 1;
90 	n2 = n1 + *lpita - 1;
91 	sum = 0.f;
92 	i__2 = n2;
93 	for (j = n1; j <= i__2; j += 4) {
94 	    sum += (r__1 = speech[j] - speech[j + tau[i__]], abs(r__1));
95 	}
96 	amdf[i__] = sum;
97 	if (amdf[i__] < amdf[*minptr]) {
98 	    *minptr = i__;
99 	}
100 	if (amdf[i__] > amdf[*maxptr]) {
101 	    *maxptr = i__;
102 	}
103     }
104     return 0;
105 } /* difmag_ */
106 
107