132{
133
134
139
140
142
143
147 real alpha, minsc, maxsc;
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
293
294
295
296 if (amdf) {
297 --amdf;
298 }
299
300
301
302
303
304
305
306
307
308
309 if (*voice == 1) {
310 *alphax = *alphax * .75f + amdf[*minptr] / 2.f;
311 } else {
312 *alphax *= .984375f;
313 }
314 alpha = *alphax / 16;
315 if (*voice == 0 && *alphax < 128.f) {
316 alpha = 8.f;
317 }
318
319
320
321 iptr = *ipoint + 1;
322 p[iptr * 60 - 60] = 1;
323 i__ = 1;
324 pbar = 1;
325 sbar = s[0];
326 i__1 = *ltau;
327 for (i__ = 1; i__ <= i__1; ++i__) {
328 sbar += alpha;
329 if (sbar < s[i__ - 1]) {
330 s[i__ - 1] = sbar;
331 p[i__ + iptr * 60 - 61] = pbar;
332 } else {
333 sbar = s[i__ - 1];
334 p[i__ + iptr * 60 - 61] = i__;
335 pbar = i__;
336 }
337 }
338
339 i__ = pbar - 1;
340 sbar = s[i__];
341 while(i__ >= 1) {
342 sbar += alpha;
343 if (sbar < s[i__ - 1]) {
344 s[i__ - 1] = sbar;
345 p[i__ + iptr * 60 - 61] = pbar;
346 } else {
347 pbar = p[i__ + iptr * 60 - 61];
348 i__ = pbar;
349 sbar = s[i__ - 1];
350 }
351 --i__;
352 }
353
354
355 s[0] += amdf[1] / 2;
356 minsc = s[0];
357 maxsc = minsc;
358 *midx = 1;
359 i__1 = *ltau;
360 for (i__ = 2; i__ <= i__1; ++i__) {
361 s[i__ - 1] += amdf[i__] / 2;
362 if (s[i__ - 1] > maxsc) {
363 maxsc = s[i__ - 1];
364 }
365 if (s[i__ - 1] < minsc) {
366 *midx = i__;
367 minsc = s[i__ - 1];
368 }
369 }
370
371 i__1 = *ltau;
372 for (i__ = 1; i__ <= i__1; ++i__) {
373 s[i__ - 1] -= minsc;
374 }
375 maxsc -= minsc;
376
377 j = 0;
378 for (i__ = 20; i__ <= 40; i__ += 10) {
379 if (*midx > i__) {
380 if (s[*midx - i__ - 1] < maxsc / 4) {
381 j = i__;
382 }
383 }
384 }
385 *midx -= j;
386
387 j = *ipoint;
388 *pitch = *midx;
389 for (i__ = 1; i__ <= 2; ++i__) {
390 j = j % 2 + 1;
391 *pitch = p[*pitch + j * 60 - 61];
392 }
393
394
395
396
397
398
399
400
401
402 *ipoint = (*ipoint + 1) % 2;
403 return 0;
404}