3 * Revision 1.1 1996/08/19 22:30:26 jaf
9 /* -- translated by f2c (version 19951025).
10 You must link the resulting object file with the libraries:
11 -lf2c -lm (in that order)
16 extern int tbdm_(real
*speech
, integer
*lpita
, integer
*tau
, integer
*ltau
, real
*amdf
, integer
*minptr
, integer
*maxptr
, integer
*mintau
);
18 /* ********************************************************************** */
23 * Revision 1.1 1996/08/19 22:30:26 jaf
26 /* Revision 1.3 1996/03/18 22:14:00 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. */
30 /* Revision 1.2 1996/03/13 14:48:37 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. */
34 /* Revision 1.1 1996/02/07 14:49:54 jaf */
35 /* Initial revision */
38 /* ********************************************************************* */
40 /*TURBO DIFMAG: Compute High Resolution Average Magnitude Difference Function
43 /* Note: There are several constants in here that appear to depend on a */
44 /* particular TAU table. That's not a problem for the LPC10 coder, but */
45 /* watch out if you change the contents of TAU in the subroutine ANALYS. */
48 /* SPEECH - Low pass filtered speech */
49 /* Indices 1 through MAX+LPITA-1 are read, where: */
50 /* MAX = (TAU(LTAU)-TAU(1))/2+1 */
51 /* (If TAU(1) .LT. 39, then larger indices could be read */
52 /* by the last call to DIFMAG below.) */
53 /* LPITA - Length of speech buffer */
54 /* TAU - Table of lags, sorted in increasing order. */
55 /* Indices 1 through LTAU read. */
56 /* LTAU - Number of lag values to compute */
58 /* AMDF - Average Magnitude Difference for each lag in TAU */
59 /* Indices 1 through LTAU written, and several might then be read.*/
60 /* MINPTR - Index of minimum AMDF value */
61 /* MAXPTR - Index of maximum AMDF value within +/- 1/2 octave of min */
62 /* MINTAU - Lag corresponding to minimum AMDF value */
64 /* This subroutine has no local state. */
66 /* Subroutine */ int tbdm_(real
*speech
, integer
*lpita
, integer
*tau
,
67 integer
*ltau
, real
*amdf
, integer
*minptr
, integer
*maxptr
, integer
*
70 /* System generated locals */
71 integer i__1
, i__2
, i__3
, i__4
;
75 integer minp2
, ltau2
, maxp2
, i__
;
76 extern /* Subroutine */ int difmag_(real
*, integer
*, integer
*, integer
77 *, integer
*, real
*, integer
*, integer
*);
78 integer minamd
, ptr
, tau2
[6];
81 /* REAL SPEECH(LPITA+TAU(LTAU)), AMDF(LTAU) */
82 /* Stupid TOAST doesn't understand expressions */
83 /* Local variables that need not be saved */
86 /* Compute full AMDF using log spaced lags, find coarse minimum */
87 /* Parameter adjustments */
93 difmag_(&speech
[1], lpita
, &tau
[1], ltau
, &tau
[*ltau
], &amdf
[1], minptr
,
95 *mintau
= tau
[*minptr
];
96 minamd
= amdf
[*minptr
];
97 /* Build table containing all lags within +/- 3 of the AMDF minimum */
98 /* excluding all that have already been computed */
104 i__3
= *mintau
+ 3, i__4
= tau
[*ltau
] - 1;
105 i__2
= min(i__3
,i__4
);
106 for (i__
= max(i__1
,41); i__
<= i__2
; ++i__
) {
107 while(tau
[ptr
] < i__
) {
110 if (tau
[ptr
] != i__
) {
112 tau2
[ltau2
- 1] = i__
;
115 /* Compute AMDF of the new lags, if there are any, and choose one */
116 /* if it is better than the coarse minimum */
118 difmag_(&speech
[1], lpita
, tau2
, <au2
, &tau
[*ltau
], amdf2
, &minp2
, &
120 if (amdf2
[minp2
- 1] < (real
) minamd
) {
121 *mintau
= tau2
[minp2
- 1];
122 minamd
= amdf2
[minp2
- 1];
125 /* Check one octave up, if there are any lags not yet computed */
128 if ((i__
& 1) == 0) {
136 difmag_(&speech
[1], lpita
, tau2
, <au2
, &tau
[*ltau
], amdf2
, &minp2
, &
138 if (amdf2
[minp2
- 1] < (real
) minamd
) {
139 *mintau
= tau2
[minp2
- 1];
140 minamd
= amdf2
[minp2
- 1];
144 /* Force minimum of the AMDF array to the high resolution minimum */
145 amdf
[*minptr
] = (real
) minamd
;
146 /* Find maximum of AMDF within 1/2 octave of minimum */
149 *maxptr
= max(i__2
,1);
152 i__2
= min(i__1
,*ltau
);
153 for (i__
= *maxptr
+ 1; i__
<= i__2
; ++i__
) {
154 if (amdf
[i__
] > amdf
[*maxptr
]) {