Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Functions
placea.c File Reference
#include "f2c.h"
Include dependency graph for placea.c:

Go to the source code of this file.

Functions

int placea_ (integer *ipitch, integer *voibuf, integer *obound, integer *af, integer *vwin, integer *awin, integer *ewin, integer *lframe, integer *maxwin)
 

Function Documentation

◆ placea_()

int placea_ ( integer ipitch,
integer voibuf,
integer obound,
integer af,
integer vwin,
integer awin,
integer ewin,
integer lframe,
integer maxwin 
)

Definition at line 116 of file placea.c.

119{
120 /* System generated locals */
121 real r__1;
122
123 /* Builtin functions */
125
126 /* Local variables */
127 logical allv, winv;
128 integer i__, j, k, l, hrange;
129 logical ephase;
130 integer lrange;
131
132/* Arguments */
133/* Local variables that need not be saved */
134 /* Parameter adjustments */
135 ewin -= 3;
136 awin -= 3;
137 vwin -= 3;
138 --voibuf;
139
140 /* Function Body */
141 lrange = (*af - 2) * *lframe + 1;
142 hrange = *af * *lframe;
143/* Place the Analysis window based on the voicing window */
144/* placement, onsets, tentative voicing decision, and pitch. */
145
146/* Case 1: Sustained Voiced Speech */
147/* If the five most recent voicing decisions are */
148/* voiced, then the window is placed phase-synchronously with the */
149/* previous window, as close to the present voicing window if possible.
150*/
151/* If onsets bound the voicing window, then preference is given to */
152/* a phase-synchronous placement which does not overlap these onsets. */
153
154/* Case 2: Voiced Transition */
155/* If at least one voicing decision in AF is voiced, and there are no
156*/
157/* onsets, then the window is placed as in case 1. */
158
159/* Case 3: Unvoiced Speech or Onsets */
160/* If both voicing decisions in AF are unvoiced, or there are onsets, */
161/* then the window is placed coincident with the voicing window. */
162
163/* Note: During phase-synchronous placement of windows, the length */
164/* is not altered from MAXWIN, since this would defeat the purpose */
165/* of phase-synchronous placement. */
166/* Check for case 1 and case 2 */
167 allv = voibuf[((*af - 2) << 1) + 2] == 1;
168 allv = allv && voibuf[((*af - 1) << 1) + 1] == 1;
169 allv = allv && voibuf[((*af - 1) << 1) + 2] == 1;
170 allv = allv && voibuf[(*af << 1) + 1] == 1;
171 allv = allv && voibuf[(*af << 1) + 2] == 1;
172 winv = voibuf[(*af << 1) + 1] == 1 || voibuf[(*af << 1) + 2] == 1;
173 if (allv || (winv && *obound == 0)) {
174/* APHASE: Phase synchronous window placement. */
175/* Get minimum lower index of the window. */
176 i__ = (lrange + *ipitch - 1 - awin[((*af - 1) << 1) + 1]) / *ipitch;
177 i__ *= *ipitch;
178 i__ += awin[((*af - 1) << 1) + 1];
179/* L = the actual length of this frame's analysis window. */
180 l = *maxwin;
181/* Calculate the location where a perfectly centered window would star
182t. */
183 k = (vwin[(*af << 1) + 1] + vwin[(*af << 1) + 2] + 1 - l) / 2;
184/* Choose the actual location to be the pitch multiple closest to this
185. */
186 r__1 = (real) (k - i__) / *ipitch;
187 awin[(*af << 1) + 1] = i__ + i_nint(&r__1) * *ipitch;
188 awin[(*af << 1) + 2] = awin[(*af << 1) + 1] + l - 1;
189/* If there is an onset bounding the right of the voicing window and t
190he */
191/* analysis window overlaps that, then move the analysis window backwa
192rd */
193/* to avoid this onset. */
194 if (*obound >= 2 && awin[(*af << 1) + 2] > vwin[(*af << 1) + 2]) {
195 awin[(*af << 1) + 1] -= *ipitch;
196 awin[(*af << 1) + 2] -= *ipitch;
197 }
198/* Similarly for the left of the voicing window. */
199 if ((*obound == 1 || *obound == 3) && awin[(*af << 1) + 1] < vwin[(*
200 af << 1) + 1]) {
201 awin[(*af << 1) + 1] += *ipitch;
202 awin[(*af << 1) + 2] += *ipitch;
203 }
204/* If this placement puts the analysis window above HRANGE, then */
205/* move it backward an integer number of pitch periods. */
206 while(awin[(*af << 1) + 2] > hrange) {
207 awin[(*af << 1) + 1] -= *ipitch;
208 awin[(*af << 1) + 2] -= *ipitch;
209 }
210/* Similarly if the placement puts the analysis window below LRANGE.
211*/
212 while(awin[(*af << 1) + 1] < lrange) {
213 awin[(*af << 1) + 1] += *ipitch;
214 awin[(*af << 1) + 2] += *ipitch;
215 }
216/* Make Energy window be phase-synchronous. */
217 ephase = TRUE_;
218/* Case 3 */
219 } else {
220 awin[(*af << 1) + 1] = vwin[(*af << 1) + 1];
221 awin[(*af << 1) + 2] = vwin[(*af << 1) + 2];
222 ephase = FALSE_;
223 }
224/* RMS is computed over an integer number of pitch periods in the analysis
225 */
226/*window. When it is not placed phase-synchronously, it is placed as clos
227e*/
228/* as possible to onsets. */
229 j = (awin[(*af << 1) + 2] - awin[(*af << 1) + 1] + 1) / *ipitch * *ipitch;
230 if (j == 0 || ! winv) {
231 ewin[(*af << 1) + 1] = vwin[(*af << 1) + 1];
232 ewin[(*af << 1) + 2] = vwin[(*af << 1) + 2];
233 } else if (! ephase && *obound == 2) {
234 ewin[(*af << 1) + 1] = awin[(*af << 1) + 2] - j + 1;
235 ewin[(*af << 1) + 2] = awin[(*af << 1) + 2];
236 } else {
237 ewin[(*af << 1) + 1] = awin[(*af << 1) + 1];
238 ewin[(*af << 1) + 2] = awin[(*af << 1) + 1] + j - 1;
239 }
240 return 0;
241} /* placea_ */
integer lframe
Definition: analys.c:66
integer i_nint(real *x)
Definition: f2clib.c:80
#define TRUE_
Definition: f2c.h:67
#define FALSE_
Definition: f2c.h:68
float real
Definition: lpc10.h:79
INT32 integer
Definition: lpc10.h:80
INT32 logical
Definition: lpc10.h:81

References FALSE_, i_nint(), lframe, and TRUE_.

Referenced by analys_().