Asterisk - The Open Source Telephony Project  18.5.0
Functions
tbdm.c File Reference
#include "f2c.h"
Include dependency graph for tbdm.c:

Go to the source code of this file.

Functions

int tbdm_ (real *speech, integer *lpita, integer *tau, integer *ltau, real *amdf, integer *minptr, integer *maxptr, integer *mintau)
 

Function Documentation

◆ tbdm_()

int tbdm_ ( real speech,
integer lpita,
integer tau,
integer ltau,
real amdf,
integer minptr,
integer maxptr,
integer mintau 
)

Definition at line 94 of file tbdm.c.

References difmag_(), max, and min.

Referenced by analys_().

97 {
98  /* System generated locals */
99  integer i__1, i__2, i__3, i__4;
100 
101  /* Local variables */
102  real amdf2[6];
103  integer minp2, ltau2, maxp2, i__;
104  extern /* Subroutine */ int difmag_(real *, integer *, integer *, integer
105  *, integer *, real *, integer *, integer *);
106  integer minamd, ptr, tau2[6];
107 
108 /* Arguments */
109 /* REAL SPEECH(LPITA+TAU(LTAU)), AMDF(LTAU) */
110 /* Stupid TOAST doesn't understand expressions */
111 /* Local variables that need not be saved */
112 /* Local state */
113 /* None */
114 /* Compute full AMDF using log spaced lags, find coarse minimum */
115  /* Parameter adjustments */
116  --speech;
117  --amdf;
118  --tau;
119 
120  /* Function Body */
121  difmag_(&speech[1], lpita, &tau[1], ltau, &tau[*ltau], &amdf[1], minptr,
122  maxptr);
123  *mintau = tau[*minptr];
124  minamd = (integer)amdf[*minptr];
125 /* Build table containing all lags within +/- 3 of the AMDF minimum */
126 /* excluding all that have already been computed */
127  ltau2 = 0;
128  ptr = *minptr - 2;
129 /* Computing MAX */
130  i__1 = *mintau - 3;
131 /* Computing MIN */
132  i__3 = *mintau + 3, i__4 = tau[*ltau] - 1;
133  i__2 = min(i__3,i__4);
134  for (i__ = max(i__1,41); i__ <= i__2; ++i__) {
135  while(tau[ptr] < i__) {
136  ++ptr;
137  }
138  if (tau[ptr] != i__) {
139  ++ltau2;
140  tau2[ltau2 - 1] = i__;
141  }
142  }
143 /* Compute AMDF of the new lags, if there are any, and choose one */
144 /* if it is better than the coarse minimum */
145  if (ltau2 > 0) {
146  difmag_(&speech[1], lpita, tau2, &ltau2, &tau[*ltau], amdf2, &minp2, &
147  maxp2);
148  if (amdf2[minp2 - 1] < (real) minamd) {
149  *mintau = tau2[minp2 - 1];
150  minamd = (integer)amdf2[minp2 - 1];
151  }
152  }
153 /* Check one octave up, if there are any lags not yet computed */
154  if (*mintau >= 80) {
155  i__ = *mintau / 2;
156  if ((i__ & 1) == 0) {
157  ltau2 = 2;
158  tau2[0] = i__ - 1;
159  tau2[1] = i__ + 1;
160  } else {
161  ltau2 = 1;
162  tau2[0] = i__;
163  }
164  difmag_(&speech[1], lpita, tau2, &ltau2, &tau[*ltau], amdf2, &minp2, &
165  maxp2);
166  if (amdf2[minp2 - 1] < (real) minamd) {
167  *mintau = tau2[minp2 - 1];
168  minamd = (integer)amdf2[minp2 - 1];
169  *minptr += -20;
170  }
171  }
172 /* Force minimum of the AMDF array to the high resolution minimum */
173  amdf[*minptr] = (real) minamd;
174 /* Find maximum of AMDF within 1/2 octave of minimum */
175 /* Computing MAX */
176  i__2 = *minptr - 5;
177  *maxptr = max(i__2,1);
178 /* Computing MIN */
179  i__1 = *minptr + 5;
180  i__2 = min(i__1,*ltau);
181  for (i__ = *maxptr + 1; i__ <= i__2; ++i__) {
182  if (amdf[i__] > amdf[*maxptr]) {
183  *maxptr = i__;
184  }
185  }
186  return 0;
187 } /* tbdm_ */
float real
Definition: lpc10.h:79
int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr)
Definition: difmag.c:90
#define min(a, b)
Definition: f2c.h:197
INT32 integer
Definition: lpc10.h:80
#define max(a, b)
Definition: f2c.h:198