1 /*
2 * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 /**
17 * @file picosig2.c
18 *
19 * Signal Generation PU - Internal functions - Implementation
20 *
21 * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
22 * All rights reserved.
23 *
24 * History:
25 * - 2009-04-20 -- initial version
26 *
27 */
28 #include "picoos.h"
29 #include "picodsp.h"
30 #include "picosig2.h"
31 #include "picofftsg.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 #if 0
37 }
38 #endif
39 /*---------------------------------------------------------------------------
40 * INTERNAL FUNCTIONS DECLARATION
41 *---------------------------------------------------------------------------*/
42 static void gen_hann2(sig_innerobj_t *sig_inObj);
43 static void get_simple_excitation(sig_innerobj_t *sig_inObj,
44 picoos_int16 *nextPeak);
45 static void enh_wind_init(sig_innerobj_t *sig_inObj);
46 static void init_rand(sig_innerobj_t *sig_inObj);
47 static void get_trig(picoos_int32 ang, picoos_int32 *table, picoos_int32 *cs,
48 picoos_int32 *sn);
49
50 /*---------------------------------------------------------------------------
51 * PICO SYSTEM FUNCTIONS
52 *---------------------------------------------------------------------------*/
53 /**
54 * allocation of DSP memory for SIG PU
55 * @param mm : memory manager
56 * @param sig_inObj : sig PU internal object of the sub-object
57 * @return PICO_OK : allocation successful
58 * @return PICO_ERR_OTHER : allocation NOT successful
59 * @callgraph
60 * @callergraph
61 */
sigAllocate(picoos_MemoryManager mm,sig_innerobj_t * sig_inObj)62 pico_status_t sigAllocate(picoos_MemoryManager mm, sig_innerobj_t *sig_inObj)
63 {
64 picoos_int16 *data_i;
65 picoos_int32 *d32;
66 picoos_int32 nCount;
67
68 sig_inObj->int_vec22 =
69 sig_inObj->int_vec23 =
70 sig_inObj->int_vec24 =
71 sig_inObj->int_vec25 =
72 sig_inObj->int_vec26 =
73 sig_inObj->int_vec28 =
74 sig_inObj->int_vec29 =
75 sig_inObj->int_vec38 =
76 sig_inObj->int_vec30 =
77 sig_inObj->int_vec31 =
78 sig_inObj->int_vec32 =
79 sig_inObj->int_vec33 =
80 sig_inObj->int_vec34 =
81 sig_inObj->int_vec35 =
82 sig_inObj->int_vec36 =
83 sig_inObj->int_vec37 =
84 sig_inObj->int_vec38 =
85 sig_inObj->int_vec39 =
86 sig_inObj->int_vec40 = NULL;
87
88 sig_inObj->sig_vec1 = NULL;
89
90 sig_inObj->idx_vect1 = sig_inObj->idx_vect2 = sig_inObj->idx_vect4 = NULL;
91 sig_inObj->idx_vect5 = sig_inObj->idx_vect6 = sig_inObj->idx_vect7 =
92 sig_inObj->idx_vect8 = sig_inObj->idx_vect9 = NULL;
93 sig_inObj->ivalue17 = sig_inObj->ivalue18 = 0;
94
95 /*-----------------------------------------------------------------
96 * Memory allocations
97 * NOTE : it would be far better to do a single allocation
98 * and to do pointer initialization inside this routine
99 * ------------------------------------------------------------------*/
100 data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
101 * PICODSP_FFTSIZE);
102 if (NULL == data_i) {
103 sigDeallocate(mm, sig_inObj);
104 return PICO_ERR_OTHER;
105 }
106 sig_inObj->idx_vect1 = data_i;
107
108 data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
109 * PICODSP_HFFTSIZE_P1);
110 if (NULL == data_i) {
111 sigDeallocate(mm, sig_inObj);
112 return PICO_ERR_OTHER;
113 }
114 sig_inObj->idx_vect2 = data_i;
115
116 data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
117 * PICODSP_FFTSIZE);
118 if (NULL == data_i) {
119 sigDeallocate(mm, sig_inObj);
120 return PICO_ERR_OTHER;
121 }
122 sig_inObj->idx_vect4 = data_i;
123
124 data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
125 * PICODSP_FFTSIZE);
126 if (NULL == data_i) {
127 sigDeallocate(mm, sig_inObj);
128 return PICO_ERR_OTHER;
129 }
130 sig_inObj->idx_vect5 = data_i;
131
132 data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
133 * PICODSP_FFTSIZE);
134 if (NULL == data_i) {
135 sigDeallocate(mm, sig_inObj);
136 return PICO_ERR_OTHER;
137 }
138 sig_inObj->idx_vect6 = data_i;
139
140 data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
141 * PICODSP_HFFTSIZE_P1);
142 if (NULL == data_i) {
143 sigDeallocate(mm, sig_inObj);
144 return PICO_ERR_OTHER;
145 }
146 sig_inObj->idx_vect7 = data_i;
147
148 data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
149 * PICODSP_MAX_EX);
150 if (NULL == data_i) {
151 sigDeallocate(mm, sig_inObj);
152 return PICO_ERR_OTHER;
153 }
154 sig_inObj->idx_vect8 = data_i;
155
156 data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
157 * PICODSP_MAX_EX);
158 if (data_i == NULL) {
159 sigDeallocate(mm, sig_inObj);
160 return PICO_ERR_OTHER;
161 }
162 sig_inObj->idx_vect9 = data_i;
163
164 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
165 * PICODSP_FFTSIZE);
166 if (NULL == d32) {
167 sigDeallocate(mm, sig_inObj);
168 return PICO_ERR_OTHER;
169 }
170 sig_inObj->int_vec22 = d32;
171 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
172 * PICODSP_FFTSIZE);
173 if (NULL == d32) {
174 sigDeallocate(mm, sig_inObj);
175 return PICO_ERR_OTHER;
176 }
177 sig_inObj->int_vec23 = d32;
178 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
179 * PICODSP_FFTSIZE);
180 if (NULL == d32) {
181 sigDeallocate(mm, sig_inObj);
182 return PICO_ERR_OTHER;
183 }
184 sig_inObj->int_vec24 = d32;
185 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
186 * PICODSP_FFTSIZE);
187 if (NULL == d32) {
188 sigDeallocate(mm, sig_inObj);
189 return PICO_ERR_OTHER;
190 }
191 sig_inObj->int_vec25 = d32;
192 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
193 * PICODSP_FFTSIZE * 2);
194 if (NULL == d32) {
195 sigDeallocate(mm, sig_inObj);
196 return PICO_ERR_OTHER;
197 }
198 sig_inObj->int_vec26 = d32;
199
200 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
201 * PICODSP_FFTSIZE);
202 if (NULL == d32) {
203 sigDeallocate(mm, sig_inObj);
204 return PICO_ERR_OTHER;
205 }
206 sig_inObj->int_vec28 = d32;
207 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
208 * PICODSP_FFTSIZE);
209 if (NULL == d32) {
210 sigDeallocate(mm, sig_inObj);
211 return PICO_ERR_OTHER;
212 }
213 sig_inObj->int_vec29 = d32;
214 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
215 * PICODSP_FFTSIZE);
216 if (NULL == d32) {
217 sigDeallocate(mm, sig_inObj);
218 return PICO_ERR_OTHER;
219 }
220 sig_inObj->int_vec38 = d32;
221 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
222 * PICODSP_FFTSIZE);
223 if (NULL == d32) {
224 sigDeallocate(mm, sig_inObj);
225 return PICO_ERR_OTHER;
226 }
227 sig_inObj->int_vec30 = d32;
228 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
229 * PICODSP_FFTSIZE);
230 if (NULL == d32) {
231 sigDeallocate(mm, sig_inObj);
232 return PICO_ERR_OTHER;
233 }
234 sig_inObj->int_vec31 = d32;
235
236 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
237 * PICODSP_FFTSIZE);
238 if (NULL == d32) {
239 sigDeallocate(mm, sig_inObj);
240 return PICO_ERR_OTHER;
241 }
242 sig_inObj->int_vec32 = d32;
243 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
244 * PICODSP_FFTSIZE);
245 if (NULL == d32) {
246 sigDeallocate(mm, sig_inObj);
247 return PICO_ERR_OTHER;
248 }
249 sig_inObj->int_vec33 = d32;
250 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
251 * PICODSP_N_RAND_TABLE);
252 if (NULL == d32) {
253 sigDeallocate(mm, sig_inObj);
254 return PICO_ERR_OTHER;
255 }
256 sig_inObj->int_vec34 = d32;
257 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
258 * PICODSP_N_RAND_TABLE);
259 if (NULL == d32) {
260 sigDeallocate(mm, sig_inObj);
261 return PICO_ERR_OTHER;
262 }
263 sig_inObj->int_vec35 = d32;
264 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
265 * PICODSP_N_RAND_TABLE);
266 if (NULL == d32) {
267 sigDeallocate(mm, sig_inObj);
268 return PICO_ERR_OTHER;
269 }
270 sig_inObj->int_vec36 = d32;
271 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
272 * PICODSP_N_RAND_TABLE);
273 if (NULL == d32) {
274 sigDeallocate(mm, sig_inObj);
275 return PICO_ERR_OTHER;
276 }
277 sig_inObj->int_vec37 = d32;
278
279 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
280 * PICODSP_HFFTSIZE_P1);
281 if (NULL == d32) {
282 sigDeallocate(mm, sig_inObj);
283 return PICO_ERR_OTHER;
284 }
285 sig_inObj->int_vec39 = d32;
286 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32) * (1
287 + PICODSP_COS_TABLE_LEN));
288 if (NULL == d32) {
289 sigDeallocate(mm, sig_inObj);
290 return PICO_ERR_OTHER;
291 }
292 sig_inObj->int_vec40 = d32;
293
294 for (nCount = 0; nCount < CEPST_BUFF_SIZE; nCount++) {
295 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32) * (PICODSP_CEPORDER));
296 if (NULL == d32) {
297 sigDeallocate(mm, sig_inObj);
298 return PICO_ERR_OTHER;
299 }
300 sig_inObj->int_vec41[nCount] = d32;
301 }
302
303 for (nCount = 0; nCount < PHASE_BUFF_SIZE; nCount++) {
304 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32) * (PICODSP_PHASEORDER));
305 if (NULL == d32) {
306 sigDeallocate(mm, sig_inObj);
307 return PICO_ERR_OTHER;
308 }
309 sig_inObj->int_vec42[nCount] = d32;
310 }
311
312 d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
313 * PICODSP_FFTSIZE * 2); /* - fixed point */
314 if (NULL == d32) {
315 sigDeallocate(mm, sig_inObj);
316 return PICO_ERR_OTHER;
317 }
318 sig_inObj->sig_vec1 = d32;
319
320 return PICO_OK;
321 }/*sigAllocate*/
322
323 /**
324 * frees DSP memory for SIG PU
325 * @param mm : memory manager
326 * @param sig_inObj : sig PU internal object of the sub-object
327 * @return void
328 * @callgraph
329 * @callergraph
330 */
sigDeallocate(picoos_MemoryManager mm,sig_innerobj_t * sig_inObj)331 void sigDeallocate(picoos_MemoryManager mm, sig_innerobj_t *sig_inObj)
332 {
333 picoos_int32 nCount;
334 /*-----------------------------------------------------------------
335 * Memory de-allocations
336 * ------------------------------------------------------------------*/
337 if (NULL != sig_inObj->idx_vect1)
338 picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect1));
339 if (NULL != sig_inObj->idx_vect2)
340 picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect2));
341 if (NULL != sig_inObj->idx_vect4)
342 picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect4));
343 if (NULL != sig_inObj->idx_vect5)
344 picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect5));
345 if (NULL != sig_inObj->idx_vect6)
346 picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect6));
347 if (NULL != sig_inObj->idx_vect7)
348 picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect7));
349 if (NULL != sig_inObj->idx_vect8)
350 picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect8));
351 if (NULL != sig_inObj->idx_vect9)
352 picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect9));
353
354 if (NULL != sig_inObj->int_vec22)
355 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec22));
356 if (NULL != sig_inObj->int_vec23)
357 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec23));
358 if (NULL != sig_inObj->int_vec24)
359 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec24));
360 if (NULL != sig_inObj->int_vec25)
361 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec25));
362 if (NULL != sig_inObj->int_vec26)
363 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec26));
364 if (NULL != sig_inObj->int_vec28)
365 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec28));
366 if (NULL != sig_inObj->int_vec29)
367 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec29));
368 if (NULL != sig_inObj->int_vec38)
369 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec38));
370 if (NULL != sig_inObj->int_vec30)
371 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec30));
372 if (NULL != sig_inObj->int_vec31)
373 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec31));
374 if (NULL != sig_inObj->int_vec32)
375 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec32));
376 if (NULL != sig_inObj->int_vec33)
377 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec33));
378 if (NULL != sig_inObj->int_vec34)
379 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec34));
380 if (NULL != sig_inObj->int_vec35)
381 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec35));
382 if (NULL != sig_inObj->int_vec36)
383 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec36));
384 if (NULL != sig_inObj->int_vec37)
385 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec37));
386 if (NULL != sig_inObj->int_vec39)
387 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec39));
388 if (NULL != sig_inObj->int_vec40)
389 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec40));
390
391 for (nCount = 0; nCount < CEPST_BUFF_SIZE; nCount++) {
392 if (NULL != sig_inObj->int_vec41[nCount]) {
393 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec41[nCount]));
394 }
395 }
396
397 for (nCount = 0; nCount < PHASE_BUFF_SIZE; nCount++) {
398 if (NULL != sig_inObj->int_vec42[nCount]) {
399 picoos_deallocate(mm, (void *) &(sig_inObj->int_vec42[nCount]));
400 }
401 }
402
403 if (NULL != sig_inObj->sig_vec1) {
404 picoos_deallocate(mm, (void *) &(sig_inObj->sig_vec1));
405 }
406 }/*sigDeAllocate*/
407
408 /**
409 * initializes all memory neededed by DSP at instance creation time
410 * @param sig_inObj : sig PU internal object of the sub-object
411 * @return void
412 * @callgraph
413 * @callergraph
414 */
sigDspInitialize(sig_innerobj_t * sig_inObj,picoos_int32 resetMode)415 void sigDspInitialize(sig_innerobj_t *sig_inObj, picoos_int32 resetMode)
416 {
417 picoos_int32 i, j;
418 picoos_int32 *pnt;
419
420 if (resetMode == PICO_RESET_SOFT) {
421 /*minimal initialization when receiving a soft reset */
422 return;
423 }
424 /*-----------------------------------------------------------------
425 * Initialization
426 * ------------------------------------------------------------------*/
427 sig_inObj->warp_p = PICODSP_FREQ_WARP_FACT;
428 sig_inObj->VCutoff_p = PICODSP_V_CUTOFF_FREQ; /*voicing cut off frequency in Hz (will be modeled in the future)*/
429 sig_inObj->UVCutoff_p = PICODSP_UV_CUTOFF_FREQ;/*unvoiced frames only (periodize lowest components to mask bad voicing transitions)*/
430 sig_inObj->Fs_p = PICODSP_SAMP_FREQ; /*Sampling freq*/
431
432 sig_inObj->m1_p = PICODSP_CEPORDER;
433 sig_inObj->m2_p = PICODSP_FFTSIZE; /*also initializes windowLen*/
434 sig_inObj->framesz_p = PICODSP_DISPLACE; /*1/4th of the frame size = displacement*/
435 sig_inObj->hfftsize_p = PICODSP_H_FFTSIZE; /*half of the FFT size*/
436 sig_inObj->voxbnd_p = (picoos_int32) ((picoos_single) sig_inObj->hfftsize_p
437 / ((picoos_single) sig_inObj->Fs_p / (picoos_single) 2)
438 * (picoos_single) sig_inObj->VCutoff_p);
439 sig_inObj->voxbnd2_p
440 = (picoos_int32) ((picoos_single) sig_inObj->hfftsize_p
441 / ((picoos_single) sig_inObj->Fs_p / (picoos_single) 2)
442 * (picoos_single) sig_inObj->UVCutoff_p);
443 sig_inObj->hop_p = sig_inObj->framesz_p;
444 sig_inObj->nextPeak_p = (((int) (PICODSP_FFTSIZE))
445 / ((int) PICODSP_DISPLACE) - 1) * sig_inObj->hop_p;
446 sig_inObj->phId_p = 0; /*phonetic id*/
447 sig_inObj->E_p = (picoos_single) 0.0f;
448 sig_inObj->F0_p = (picoos_single) 0.0f;
449 sig_inObj->voiced_p = 0;
450 sig_inObj->nV = sig_inObj->nU = 0;
451 sig_inObj->sMod_p = (picoos_single) 1.0f;
452
453 /*cleanup vectors*/
454 for (i = 0; i < 2 * PICODSP_FFTSIZE; i++) {
455 sig_inObj->sig_vec1[i] = 0;
456 sig_inObj->int_vec26[i] = 0; /*wav buff cleanup */
457 }
458
459 for (i = 0; i < PICODSP_FFTSIZE; i++) {
460 sig_inObj->idx_vect1[i] = sig_inObj->idx_vect4[i]
461 = sig_inObj->idx_vect5[i] = sig_inObj->idx_vect6[i] = 0;
462 sig_inObj->int_vec32[i] = sig_inObj->int_vec33[i] = 0;
463 }
464
465 for (i = 0; i < PICODSP_HFFTSIZE_P1; i++) {
466 sig_inObj->idx_vect2[i] = (picoos_int16) 0;
467 }
468
469 for (i = 0; i < CEPST_BUFF_SIZE; i++) {
470 sig_inObj->F0Buff[i]=0;
471 sig_inObj->PhIdBuff[i]=0;
472 sig_inObj->VoicingBuff[i]=0;
473 sig_inObj->FuVBuff[i]=0;
474 if (NULL != sig_inObj->CepBuff[i]) {
475 pnt = sig_inObj->CepBuff[i];
476 for (j = 0; j < PICODSP_CEPORDER; j++) {
477 pnt[j] = 0;
478 }
479 }
480 }
481
482 for (i = 0; i < PHASE_BUFF_SIZE; i++) {
483 if (NULL != sig_inObj->int_vec42[i]) {
484 pnt = sig_inObj->int_vec42[i];
485 for (j = 0; j < PICODSP_PHASEORDER; j++) {
486 pnt[j] = 0;
487 }
488 }
489 }
490 sig_inObj->n_available=0;
491 /*---------------------------------------------
492 Init formant enhancement window
493 hanning window,
494 Post Filter Hermite's interpolator Matrix
495 Mel-2-Lin lookup tables
496 ---------------------------------------------*/
497 enh_wind_init(sig_inObj); /*creates the formant enhancement window*/
498 init_rand(sig_inObj);
499 gen_hann2(sig_inObj);
500 mel_2_lin_init(sig_inObj);
501
502 }/*sigDspInitialize*/
503
504 /*-------------------------------------------------------------------------------
505 PROCESSING FUNCTIONS : CALLED WITHIN sigStep (cfr. picosig.c)
506 --------------------------------------------------------------------------------*/
507 /**
508 * convert from mel scale to linear scale
509 * @param sig_inObj : sig PU internal object of the sub-object
510 * @param scmeanMGC : mean value of the MGC
511 * @return void
512 * @callgraph
513 * @callergraph
514 * @remarks translated from matlab code to c-code
515 * Input
516 * - c1 : input mfcc vector (ceporder=m1, real)
517 * - m1 : input order
518 * - A,B,D : lookup tables
519 * - m2 : output order
520 * - Xr,Xi (m2=FFT size, real) temporary arrays for FFT
521 * - WNr,WNi (m2=FFT size, real) cos and sin precalculated tables
522 * Output
523 * - Xr (m2=FFT size, real) linear cepstral vector
524 */
mel_2_lin_lookup(sig_innerobj_t * sig_inObj,picoos_uint32 scmeanMGC)525 void mel_2_lin_lookup(sig_innerobj_t *sig_inObj, picoos_uint32 scmeanMGC)
526 {
527 /*Local vars*/
528 picoos_int16 nI, k;
529 picoos_int32 delta, term1, term2;
530
531 /*Local vars to be linked with sig data object*/
532 picoos_int32 *c1, *XXr;
533 picoos_single K1;
534 picoos_int32 *D, K2, shift;
535 picoos_int16 m1, *A, m2, m4, voiced, i;
536
537 /*Link local variables with sig data object*/
538 c1 = sig_inObj->wcep_pI;
539 m1 = sig_inObj->m1_p;
540 m2 = PICODSP_FFTSIZE;
541 m4 = m2 >> 1;
542
543 A = sig_inObj->A_p;
544 D = sig_inObj->d_p;
545
546 XXr = sig_inObj->wcep_pI;
547 voiced = sig_inObj->voiced_p;
548
549 shift = 27 - scmeanMGC;
550 K2 = 1 << shift;
551 K1 = (picoos_single) PICODSP_START_FLOAT_NORM * K2;
552 XXr[0] = (picoos_int32) ((picoos_single) c1[0] * K1);
553 for (nI = 1; nI < m1; nI++) {
554 XXr[nI] = c1[nI] << shift;
555 }
556 i = sizeof(picoos_int32) * (PICODSP_FFTSIZE + 1 - m1);
557 picoos_mem_set(XXr + m1, 0, i);
558 dfct_nmf(m4, XXr); /* DFCT directly in fixed point */
559
560 /* *****************************************************************************************
561 Linear frequency scale envelope through interpolation.
562 Two additions and one multiplication per entry.
563
564 Optimization of linear interpolation algorithm
565 - Start from 1 and stop at PICODSP_H_FFTSIZE-1 because 0 and PICODSP_H_FFTSIZE are invariant points
566 - B[k]=A[k]+1 except for 0 and PICODSP_H_FFTSIZE
567 - get rid of extra -1 operation by adapting the table A[]
568
569 *******************************************************************************************/
570 for (nI = 1; nI < PICODSP_H_FFTSIZE; nI++) {
571 k = A[nI];
572 term2 = XXr[k];
573 term1 = XXr[k + 1];
574 delta = term1 - term2;
575 XXr[nI] = term2 + ((D[nI] * delta) >> 5); /* ok because nI<=A[nI] <=B[nI] */
576 }
577 }/*mel_2_lin_lookup*/
578
579 /**
580 * calculate phase
581 * @remarks voiced phase taken from phase codebook and smoothed,
582 * @remarks unvoiced phase - random
583 * @param sig_inObj : sig PU internal object of the sub-object
584 * @return void
585 * @callgraph
586 * @callergraph
587 */
phase_spec2(sig_innerobj_t * sig_inObj)588 void phase_spec2(sig_innerobj_t *sig_inObj)
589 {
590 picoos_int16 nI, iRand, firstUV;
591 picoos_int32 *tmp1, *tmp2;
592 picoos_int16 VOXBND_M1;
593 picoos_int32 *spect, *ang;
594 picoos_int16 voiced, m2;
595 picoos_int32 *co, *so, *c, *s, voxbnd, voxbnd2;
596 picoos_int16 i,j, k, n_comp;
597 picoos_int16 *Pvoxbnd;
598 picoos_int32 *phs_p2, *phs_p1, *phs_n1, *phs_n2;
599 picoos_int32 *phs;
600
601 /*Link local variables to sig data object*/
602 spect = sig_inObj->wcep_pI; /* spect_p;*/
603 /* current spect scale : times PICODSP_FIX_SCALE1 */
604 ang = sig_inObj->ang_p;
605 voxbnd = (picoos_int32) (sig_inObj->voxbnd_p * sig_inObj->voicing);
606 voxbnd2 = sig_inObj->voxbnd2_p;
607 voiced = sig_inObj->voiced_p;
608 m2 = sig_inObj->m2_p;
609 VOXBND_M1 = voxbnd - 1;
610 firstUV = 1;
611
612 /*code starts here*/
613 if (voiced == 1) {
614 firstUV = voxbnd;
615 Pvoxbnd = sig_inObj->VoxBndBuff;
616 n_comp = Pvoxbnd[2];
617 phs_p2 = sig_inObj->PhsBuff[0];
618 phs_p1 = sig_inObj->PhsBuff[1];
619 phs = sig_inObj->PhsBuff[2];
620 phs_n1 = sig_inObj->PhsBuff[3];
621 phs_n2 = sig_inObj->PhsBuff[4];
622
623 /* find and smooth components which have full context */
624 j = n_comp;
625 for (i=0; i<5; i++) {
626 if (Pvoxbnd[i]<j) j = Pvoxbnd[i];
627 }
628 for (i=0; i<j; i++) {
629 ang[i] = -(((phs_p2[i]+phs_p1[i]+phs[i]+phs_n1[i]+phs_n2[i])<<6) / 5);
630 }
631
632 /* find and smooth components which at least one component on each side */
633 k = n_comp;
634 if (Pvoxbnd[2]<k) k = Pvoxbnd[2];
635 if (Pvoxbnd[4]<k) k = Pvoxbnd[4];
636 for (i=j; i<k; i++) { /* smooth using only two surrounding neighbours */
637 ang[i] = -(((phs_p1[i]+phs[i]+phs_n1[i])<<6) / 3);
638 }
639
640 /* handle rest of components - at least one side does not exist */
641 for (i=k; i<n_comp; i++) {
642 ang[i] = -(phs[i]<<6); /* - simple copy without smoothing */
643 }
644
645 /*Phase unwrap - cumsum */
646 tmp1 = &(ang[1]);
647 tmp2 = &(ang[0]);
648 /* current ang scale : PICODSP_M_PI = PICODSP_FIX_SCALE2 */
649 FAST_DEVICE(VOXBND_M1,*(tmp1++)+=*(tmp2)-PICODSP_FIX_SCALE2;*(tmp2)=(*tmp2>=0)?(*tmp2)>>PICODSP_SHIFT_FACT4:-((-(*tmp2))>>PICODSP_SHIFT_FACT4);tmp2++);
650 *tmp2 = (*tmp2 >= 0) ? (*tmp2) >> PICODSP_SHIFT_FACT4 : -((-(*tmp2))
651 >> PICODSP_SHIFT_FACT4); /*ang[voxbnd-1]/=2;*/
652 }
653
654 /* now for the unvoiced part */
655 iRand = sig_inObj->iRand;
656 c = sig_inObj->randCosTbl + iRand;
657 s = sig_inObj->randSinTbl + iRand;
658 co = sig_inObj->outCosTbl + firstUV;
659 so = sig_inObj->outSinTbl + firstUV;
660 for (nI = firstUV; nI < PICODSP_HFFTSIZE_P1 - 1; nI++) {
661 *co++ = *c++;
662 *so++ = *s++;
663 }
664 *co = 1;
665 *so = 0;
666 sig_inObj->iRand += (PICODSP_HFFTSIZE_P1 - firstUV);
667 if (sig_inObj->iRand > PICODSP_N_RAND_TABLE - PICODSP_HFFTSIZE_P1)
668 sig_inObj->iRand = 1 + sig_inObj->iRand + PICODSP_HFFTSIZE_P1
669 - PICODSP_N_RAND_TABLE;
670 }/*phase_spec2*/
671
672 /**
673 * Prepare Envelope spectrum for inverse FFT
674 * @param sig_inObj : sig PU internal object of the sub-object
675 * @return void
676 * @remarks make phase bilateral -->> angh (FFT size, real)
677 * @remarks combine in complex input vector for IFFT F = e**(spet/2+j*ang)
678 * @remarks Compute energy -->> E (scalar, real)
679 * @callgraph
680 * @callergraph
681 * Input
682 * - spect (FFT size, real)
683 * - ang (half FFT size -1, real)
684 * - m2 fftsize
685 * - WNr,WNi (FFT size, real) the tabulated sine and cosine values
686 * - brev (FFT size, real) the tabulated bit reversal indexes
687 * Output
688 * - Fr, Fi (FFT size, complex) the envelope spectrum
689 * - E (scalar, real) the energy
690 */
env_spec(sig_innerobj_t * sig_inObj)691 void env_spec(sig_innerobj_t *sig_inObj)
692 {
693
694 picoos_int16 nI;
695 picoos_int32 fcX, fsX, fExp, voxbnd;
696 picoos_int32 *spect, *ang, *ctbl;
697 picoos_int16 voiced, prev_voiced;
698 picoos_int32 *co, *so;
699 picoos_int32 *Fr, *Fi;
700 picoos_single mult;
701
702 /*Link local variables to sig object*/
703 spect = sig_inObj->wcep_pI; /*spect_p*/
704 /* current spect scale : times PICODSP_FIX_SCALE1 */
705 ang = sig_inObj->ang_p;
706 /* current spect scale : PICODSP_M_PI = PICODSP_FIX_SCALE2 */
707 Fr = sig_inObj->F2r_p;
708 Fi = sig_inObj->F2i_p;
709 voiced = sig_inObj->voiced_p;
710 prev_voiced = sig_inObj->prevVoiced_p;
711 voxbnd = (picoos_int32) (sig_inObj->voxbnd_p * sig_inObj->voicing);
712 ctbl = sig_inObj->cos_table;
713 /* ctbl scale : times 4096 */
714 mult = PICODSP_ENVSPEC_K1 / PICODSP_FIX_SCALE1;
715
716 /*remove dc from real part*/
717 if (sig_inObj->F0_p > 120) {
718 spect[0] = spect[1] = 0;
719 spect[2] /= PICODSP_ENVSPEC_K2;
720 } else {
721 spect[0] = 0;
722 }
723
724 /* if using rand table, use sin and cos tables as well */
725 if (voiced || (prev_voiced)) {
726 /*Envelope becomes a complex exponential : F=exp(.5*spect + j*angh);*/
727 for (nI = 0; nI < voxbnd; nI++) {
728 get_trig(ang[nI], ctbl, &fcX, &fsX);
729 fExp = (picoos_int32) EXP((double)spect[nI]*mult);
730 Fr[nI] = fExp * fcX;
731 Fi[nI] = fExp * fsX;
732 }
733 /* ao=sig_inObj->ang_p+(picoos_int32)voxbnd; */
734 co = sig_inObj->outCosTbl + voxbnd;
735 so = sig_inObj->outSinTbl + voxbnd;
736
737 for (nI = voxbnd; nI < PICODSP_HFFTSIZE_P1; nI++) {
738 fcX = *co++;
739 fsX = *so++;
740 fExp = (picoos_int32) EXP((double)spect[nI]*mult);
741 Fr[nI] = fExp * fcX;
742 Fi[nI] = fExp * fsX;
743 }
744 } else {
745 /*ao=sig_inObj->ang_p+1;*/
746 co = sig_inObj->outCosTbl + 1;
747 so = sig_inObj->outSinTbl + 1;
748 for (nI = 1; nI < PICODSP_HFFTSIZE_P1; nI++) {
749 fcX = *co++;
750 fsX = *so++;
751 fExp = (picoos_int32) EXP((double)spect[nI]*mult);
752
753 Fr[nI] = fExp * fcX;
754 Fi[nI] = fExp * fsX;
755 }
756 }
757
758 }/*env_spec*/
759
760 /**
761 * Calculates the impulse response of the comlpex spectrum through inverse rFFT
762 * @param sig_inObj : sig PU internal object of the sub-object
763 * @return void
764 * @remarks Imp corresponds with the real part of the FFT
765 * @callgraph
766 * @callergraph
767 * Input
768 * - Fr, Fi (FFT size, real & imaginary) the complex envelope spectrum (only first half of spectrum)
769 * Output
770 * - Imp: impulse response (length: m2)
771 * - E (scalar, real) RMS value
772 */
impulse_response(sig_innerobj_t * sig_inObj)773 void impulse_response(sig_innerobj_t *sig_inObj)
774 {
775 /*Define local variables*/
776 picoos_single f;
777 picoos_int16 nI, nn, m2, m4, voiced;
778 picoos_single *E;
779 picoos_int32 *norm_window; /* - fixed point */
780 picoos_int32 *fr, *Fr, *Fi, *t1, ff; /* - fixed point */
781
782 /*Link local variables with sig object*/
783 m2 = sig_inObj->m2_p;
784 m4 = m2 >> 1;
785 Fr = sig_inObj->F2r_p;
786 Fi = sig_inObj->F2i_p;
787 norm_window = sig_inObj->norm_window_p;
788 E = &(sig_inObj->E_p); /*as pointer: value will be modified*/
789 voiced = sig_inObj->voiced_p;
790 fr = sig_inObj->imp_p;
791
792 /*Inverse FFT*/
793 for (nI = 0, nn = 0; nI < m4; nI++, nn += 2) {
794 fr[nn] = Fr[nI]; /* - fixed point */
795 }
796
797 fr[1] = (picoos_int32) (Fr[m4]);
798 for (nI = 1, nn = 3; nI < m4; nI++, nn += 2) {
799 fr[nn] = -Fi[nI]; /* - fixed point */
800 }
801
802 rdft(m2, -1, fr);
803 /*window, normalize and differentiate*/
804 *E = norm_result(m2, fr, norm_window);
805
806 if (*E > 0) {
807 f = *E * PICODSP_FIXRESP_NORM;
808 } else {
809 f = 20; /*PICODSP_FIXRESP_NORM*/
810 }
811 ff = (picoos_int32) f;
812 if (ff < 1)
813 ff = 1;
814 /*normalize impulse response*/
815 t1 = fr;FAST_DEVICE(PICODSP_FFTSIZE,*(t1++) /= ff;); /* - fixed point */
816
817 } /* impulse_response */
818
819 /**
820 * time domain pitch synchronous overlap add over two frames (when no voicing transition)
821 * @param sig_inObj : sig PU internal object of the sub-object
822 * @return void
823 * @remarks Special treatment at voicing boundaries
824 * @remarks Introduced to get rid of time-domain aliasing (and additional speed up)
825 * @callgraph
826 * @callergraph
827 */
td_psola2(sig_innerobj_t * sig_inObj)828 void td_psola2(sig_innerobj_t *sig_inObj)
829 {
830 picoos_int16 nI;
831 picoos_int16 hop, m2, *nextPeak, voiced;
832 picoos_int32 *t1, *t2;
833 picoos_int16 cnt;
834 picoos_int32 *fr, *v1, ff, f;
835 picoos_int16 a, i;
836 picoos_int32 *window;
837 picoos_int16 s = (picoos_int16) 1;
838 window = sig_inObj->window_p;
839
840 /*Link local variables with sig object*/
841 hop = sig_inObj->hop_p;
842 m2 = sig_inObj->m2_p;
843 nextPeak = &(sig_inObj->nextPeak_p);
844 voiced = sig_inObj->voiced_p;
845 fr = sig_inObj->imp_p;
846 /*toggle the pointers and initialize signal vector */
847 v1 = sig_inObj->sig_vec1;
848
849 t1 = v1;
850 FAST_DEVICE(PICODSP_FFTSIZE-PICODSP_DISPLACE,*(t1++)=0;);
851 t1 = &(v1[PICODSP_FFTSIZE - PICODSP_DISPLACE]);
852 t2 = &(v1[PICODSP_FFTSIZE]);
853 FAST_DEVICE(PICODSP_FFTSIZE, *(t1++)=*(t2++););
854 t1 = &(v1[2 * PICODSP_FFTSIZE - PICODSP_DISPLACE]);FAST_DEVICE(PICODSP_DISPLACE,*(t1++)=0;);
855 /*calculate excitation points*/
856 get_simple_excitation(sig_inObj, nextPeak);
857
858 /*TD-PSOLA based on excitation vector */
859 if ((sig_inObj->nU == 0) && (sig_inObj->voiced_p == 1)) {
860 /* purely voiced */
861 for (nI = 0; nI < sig_inObj->nV; nI++) {
862 f = sig_inObj->EnV[nI];
863 a = 0;
864 cnt = PICODSP_FFTSIZE;
865 ff = (f * window[sig_inObj->LocV[nI]]) >> PICODSP_SHIFT_FACT1;
866 t1 = &(v1[a + sig_inObj->LocV[nI]]);
867 t2 = &(fr[a]);
868 if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff;);
869 }
870 } else if ((sig_inObj->nV == 0) && (sig_inObj->voiced_p == 0)) {
871 /* PURELY UNVOICED*/
872 for (nI = 0; nI < sig_inObj->nU; nI++) {
873 f = sig_inObj->EnU[nI];
874 s = -s; /*reverse order to reduce the periodicity effect*/
875 if (s == 1) {
876 a = 0;
877 cnt = PICODSP_FFTSIZE;
878 ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
879 t1 = &(v1[a + sig_inObj->LocU[nI]]);
880 t2 = &(fr[a]);
881 if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff; );
882 } else { /*s==-1*/
883 a = 0;
884 cnt = PICODSP_FFTSIZE;
885 ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
886 t1 = &(v1[(m2 - 1 - a) + sig_inObj->LocU[nI]]);
887 t2 = &(fr[a]);
888 if (cnt > 0)FAST_DEVICE(cnt,*(t1--)+=*(t2++)*ff; );
889 }
890 }
891 } else if (sig_inObj->VoicTrans == 0) {
892 /*voicing transition from unvoiced to voiced*/
893 for (nI = 0; nI < sig_inObj->nV; nI++) {
894 f = sig_inObj->EnV[nI];
895 a = 0;
896 cnt = PICODSP_FFTSIZE;
897 ff = (f * window[sig_inObj->LocV[nI]]) >> PICODSP_SHIFT_FACT1;
898 t1 = &(v1[a + sig_inObj->LocV[nI]]);
899 t2 = &(fr[a]);
900 if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff;);
901 }
902 /*add remaining stuff from unvoiced part*/
903 for (nI = 0; nI < sig_inObj->nU; nI++) {
904 f = sig_inObj->EnU[nI];
905 s = -s; /*reverse order to reduce the periodicity effect*/
906 if (s == 1) {
907 a = 0;
908 cnt = PICODSP_FFTSIZE;
909 ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
910 t1 = &(v1[a + sig_inObj->LocU[nI]]);
911 t2 = &(sig_inObj->ImpResp_p[a]); /*saved impulse response*/
912 if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff; );
913 } else {
914 a = 0;
915 cnt = PICODSP_FFTSIZE;
916 ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
917 t1 = &(v1[(m2 - 1 - a) + sig_inObj->LocU[nI]]);
918 t2 = &(sig_inObj->ImpResp_p[a]);
919 if (cnt > 0)FAST_DEVICE(cnt,*(t1--)+=*(t2++)*ff; );
920 }
921 }
922 } else {
923 /*voiced to unvoiced*/
924 for (nI = 0; nI < sig_inObj->nU; nI++) {
925 f = sig_inObj->EnU[nI];
926 s = -s; /*reverse order to reduce the periodicity effect*/
927 if (s > 0) {
928 a = 0;
929 cnt = PICODSP_FFTSIZE;
930 ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
931 t1 = &(v1[a + sig_inObj->LocU[nI]]);
932 t2 = &(fr[a]);
933 if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff; );
934 } else {
935 a = 0;
936 cnt = PICODSP_FFTSIZE;
937 ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
938 t1 = &(v1[(m2 - 1 - a) + sig_inObj->LocU[nI]]);
939 t2 = &(fr[a]);
940 if (cnt > 0)FAST_DEVICE(cnt,*(t1--)+=*(t2++)*ff; );
941 }
942 }
943 /*add remaining stuff from voiced part*/
944 for (nI = 0; nI < sig_inObj->nV; nI++) {
945 f = sig_inObj->EnV[nI];
946 a = 0;
947 cnt = PICODSP_FFTSIZE;
948 ff = (f * window[sig_inObj->LocV[nI]]) >> PICODSP_SHIFT_FACT1;
949 t1 = &(v1[a + sig_inObj->LocV[nI]]);
950 t2 = &(sig_inObj->ImpResp_p[a]);
951 if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff;);
952 }
953 }
954
955 t1 = sig_inObj->sig_vec1;
956 for (i = 0; i < PICODSP_FFTSIZE; i++, t1++) {
957 if (*t1 >= 0)
958 *t1 >>= PICODSP_SHIFT_FACT5;
959 else
960 *t1 = -((-*t1) >> PICODSP_SHIFT_FACT5);
961 }
962
963 }/*td_psola2*/
964
965 /**
966 * overlap + add summing of impulse responses on the final destination sample buffer
967 * @param sig_inObj : sig PU internal object of the sub-object
968 * @return void
969 * @remarks Special treatment at voicing boundaries
970 * @remarks Introduced to get rid of time-domain aliasing (and additional speed up)
971 * Input
972 * - wlet : the generic impulse response (FFT size, real)
973 * - window : the windowing funcion (FFT size, real) fixed
974 * - WavBuff : the destination buffer with past samples (FFT size*2, short)
975 * - m2 : fftsize
976 * Output
977 * - WavBuff : the destination buffer with updated samples (FFT size*2, short)
978 * @callgraph
979 * @callergraph
980 */
overlap_add(sig_innerobj_t * sig_inObj)981 void overlap_add(sig_innerobj_t *sig_inObj)
982 {
983 /*Local variables*/
984 picoos_int32 *w, *v;
985
986 /*Link local variables with sig object*/
987 w = sig_inObj->WavBuff_p;
988 v = sig_inObj->sig_vec1;
989
990 FAST_DEVICE(PICODSP_FFTSIZE, *(w++)+=*(v++)<<PICODSP_SHIFT_FACT6;);
991
992 }/*overlap_add*/
993
994 /*-------------------------------------------------------------------------------
995 INITIALIZATION AND INTERNAL FUNCTIONS
996 --------------------------------------------------------------------------------*/
997 /**
998 * Hanning window initialization
999 * @param sig_inObj : sig PU internal object of the sub-object
1000 * @return PICO_OK
1001 * @callgraph
1002 * @callergraph
1003 */
gen_hann2(sig_innerobj_t * sig_inObj)1004 static void gen_hann2(sig_innerobj_t *sig_inObj)
1005 {
1006 picoos_int32 *hann;
1007 picoos_int32 *norm;
1008 /*link local variables with sig object*/
1009 hann = sig_inObj->window_p;
1010 norm = sig_inObj->norm_window_p;
1011
1012 norm[0] = 80224;
1013 norm[1] = 320832;
1014 norm[2] = 721696;
1015 norm[3] = 1282560;
1016 norm[4] = 2003104;
1017 norm[5] = 2882880;
1018 norm[6] = 3921376;
1019 norm[7] = 5117984;
1020 norm[8] = 6471952;
1021 norm[9] = 7982496;
1022 norm[10] = 9648720;
1023 norm[11] = 11469616;
1024 norm[12] = 13444080;
1025 norm[13] = 15570960;
1026 norm[14] = 17848976;
1027 norm[15] = 20276752;
1028 norm[16] = 22852864;
1029 norm[17] = 25575744;
1030 norm[18] = 28443776;
1031 norm[19] = 31455264;
1032 norm[20] = 34608368;
1033 norm[21] = 37901248;
1034 norm[22] = 41331904;
1035 norm[23] = 44898304;
1036 norm[24] = 48598304;
1037 norm[25] = 52429696;
1038 norm[26] = 56390192;
1039 norm[27] = 60477408;
1040 norm[28] = 64688944;
1041 norm[29] = 69022240;
1042 norm[30] = 73474720;
1043 norm[31] = 78043744;
1044 norm[32] = 82726544;
1045 norm[33] = 87520352;
1046 norm[34] = 92422272;
1047 norm[35] = 97429408;
1048 norm[36] = 102538752;
1049 norm[37] = 107747248;
1050 norm[38] = 113051776;
1051 norm[39] = 118449184;
1052 norm[40] = 123936224;
1053 norm[41] = 129509648;
1054 norm[42] = 135166080;
1055 norm[43] = 140902192;
1056 norm[44] = 146714528;
1057 norm[45] = 152599584;
1058 norm[46] = 158553904;
1059 norm[47] = 164573888;
1060 norm[48] = 170655936;
1061 norm[49] = 176796448;
1062 norm[50] = 182991712;
1063 norm[51] = 189238064;
1064 norm[52] = 195531744;
1065 norm[53] = 201868992;
1066 norm[54] = 208246016;
1067 norm[55] = 214659040;
1068 norm[56] = 221104176;
1069 norm[57] = 227577616;
1070 norm[58] = 234075488;
1071 norm[59] = 240593872;
1072 norm[60] = 247128912;
1073 norm[61] = 253676688;
1074 norm[62] = 260233280;
1075 norm[63] = 266794768;
1076 norm[64] = 273357248;
1077 norm[65] = 279916768;
1078 norm[66] = 286469440;
1079 norm[67] = 293011360;
1080 norm[68] = 299538560;
1081 norm[69] = 306047168;
1082 norm[70] = 312533312;
1083 norm[71] = 318993088;
1084 norm[72] = 325422656;
1085 norm[73] = 331818144;
1086 norm[74] = 338175744;
1087 norm[75] = 344491680;
1088 norm[76] = 350762176;
1089 norm[77] = 356983424;
1090 norm[78] = 363151808;
1091 norm[79] = 369263520;
1092 norm[80] = 375315008;
1093 norm[81] = 381302592;
1094 norm[82] = 387222720;
1095 norm[83] = 393071872;
1096 norm[84] = 398846528;
1097 norm[85] = 404543232;
1098 norm[86] = 410158560;
1099 norm[87] = 415689216;
1100 norm[88] = 421131840;
1101 norm[89] = 426483200;
1102 norm[90] = 431740096;
1103 norm[91] = 436899392;
1104 norm[92] = 441958016;
1105 norm[93] = 446912928;
1106 norm[94] = 451761152;
1107 norm[95] = 456499840;
1108 norm[96] = 461126080;
1109 norm[97] = 465637152;
1110 norm[98] = 470030400;
1111 norm[99] = 474303104;
1112 norm[100] = 478452800;
1113 norm[101] = 482476960;
1114 norm[102] = 486373184;
1115 norm[103] = 490139200;
1116 norm[104] = 493772640;
1117 norm[105] = 497271424;
1118 norm[106] = 500633440;
1119 norm[107] = 503856704;
1120 norm[108] = 506939200;
1121 norm[109] = 509879168;
1122 norm[110] = 512674880;
1123 norm[111] = 515324544;
1124 norm[112] = 517826688;
1125 norm[113] = 520179776;
1126 norm[114] = 522382368;
1127 norm[115] = 524433184;
1128 norm[116] = 526331008;
1129 norm[117] = 528074688;
1130 norm[118] = 529663200;
1131 norm[119] = 531095552;
1132 norm[120] = 532370944;
1133 norm[121] = 533488576;
1134 norm[122] = 534447808;
1135 norm[123] = 535248000;
1136 norm[124] = 535888768;
1137 norm[125] = 536369664;
1138 norm[126] = 536690432;
1139 norm[127] = 536850880;
1140 norm[128] = 536850880;
1141 norm[129] = 536690432;
1142 norm[130] = 536369664;
1143 norm[131] = 535888768;
1144 norm[132] = 535248000;
1145 norm[133] = 534447808;
1146 norm[134] = 533488576;
1147 norm[135] = 532370944;
1148 norm[136] = 531095552;
1149 norm[137] = 529663200;
1150 norm[138] = 528074688;
1151 norm[139] = 526331008;
1152 norm[140] = 524433216;
1153 norm[141] = 522382368;
1154 norm[142] = 520179776;
1155 norm[143] = 517826688;
1156 norm[144] = 515324544;
1157 norm[145] = 512674880;
1158 norm[146] = 509879168;
1159 norm[147] = 506939200;
1160 norm[148] = 503856704;
1161 norm[149] = 500633472;
1162 norm[150] = 497271424;
1163 norm[151] = 493772672;
1164 norm[152] = 490139200;
1165 norm[153] = 486373184;
1166 norm[154] = 482476992;
1167 norm[155] = 478452800;
1168 norm[156] = 474303104;
1169 norm[157] = 470030400;
1170 norm[158] = 465637184;
1171 norm[159] = 461126080;
1172 norm[160] = 456499840;
1173 norm[161] = 451761152;
1174 norm[162] = 446912960;
1175 norm[163] = 441958016;
1176 norm[164] = 436899424;
1177 norm[165] = 431740096;
1178 norm[166] = 426483200;
1179 norm[167] = 421131840;
1180 norm[168] = 415689216;
1181 norm[169] = 410158560;
1182 norm[170] = 404543232;
1183 norm[171] = 398846528;
1184 norm[172] = 393071872;
1185 norm[173] = 387222720;
1186 norm[174] = 381302592;
1187 norm[175] = 375315008;
1188 norm[176] = 369263552;
1189 norm[177] = 363151808;
1190 norm[178] = 356983456;
1191 norm[179] = 350762176;
1192 norm[180] = 344491712;
1193 norm[181] = 338175776;
1194 norm[182] = 331818144;
1195 norm[183] = 325422656;
1196 norm[184] = 318993088;
1197 norm[185] = 312533312;
1198 norm[186] = 306047168;
1199 norm[187] = 299538560;
1200 norm[188] = 293011360;
1201 norm[189] = 286469472;
1202 norm[190] = 279916800;
1203 norm[191] = 273357248;
1204 norm[192] = 266794784;
1205 norm[193] = 260233280;
1206 norm[194] = 253676688;
1207 norm[195] = 247128928;
1208 norm[196] = 240593888;
1209 norm[197] = 234075488;
1210 norm[198] = 227577632;
1211 norm[199] = 221104192;
1212 norm[200] = 214659040;
1213 norm[201] = 208246032;
1214 norm[202] = 201868992;
1215 norm[203] = 195531744;
1216 norm[204] = 189238080;
1217 norm[205] = 182991728;
1218 norm[206] = 176796448;
1219 norm[207] = 170655952;
1220 norm[208] = 164573888;
1221 norm[209] = 158553920;
1222 norm[210] = 152599600;
1223 norm[211] = 146714528;
1224 norm[212] = 140902208;
1225 norm[213] = 135166096;
1226 norm[214] = 129509648;
1227 norm[215] = 123936240;
1228 norm[216] = 118449184;
1229 norm[217] = 113051776;
1230 norm[218] = 107747248;
1231 norm[219] = 102538752;
1232 norm[220] = 97429424;
1233 norm[221] = 92422288;
1234 norm[222] = 87520352;
1235 norm[223] = 82726544;
1236 norm[224] = 78043744;
1237 norm[225] = 73474736;
1238 norm[226] = 69022240;
1239 norm[227] = 64688944;
1240 norm[228] = 60477424;
1241 norm[229] = 56390192;
1242 norm[230] = 52429696;
1243 norm[231] = 48598304;
1244 norm[232] = 44898304;
1245 norm[233] = 41331904;
1246 norm[234] = 37901248;
1247 norm[235] = 34608384;
1248 norm[236] = 31455264;
1249 norm[237] = 28443792;
1250 norm[238] = 25575744;
1251 norm[239] = 22852864;
1252 norm[240] = 20276752;
1253 norm[241] = 17848976;
1254 norm[242] = 15570960;
1255 norm[243] = 13444080;
1256 norm[244] = 11469616;
1257 norm[245] = 9648720;
1258 norm[246] = 7982512;
1259 norm[247] = 6471952;
1260 norm[248] = 5117984;
1261 norm[249] = 3921376;
1262 norm[250] = 2882880;
1263 norm[251] = 2003104;
1264 norm[252] = 1282560;
1265 norm[253] = 721696;
1266 norm[254] = 320832;
1267 norm[255] = 80224;
1268 hann[0] = 0;
1269 hann[1] = 0;
1270 hann[2] = 1;
1271 hann[3] = 2;
1272 hann[4] = 3;
1273 hann[5] = 5;
1274 hann[6] = 7;
1275 hann[7] = 9;
1276 hann[8] = 12;
1277 hann[9] = 15;
1278 hann[10] = 18;
1279 hann[11] = 21;
1280 hann[12] = 25;
1281 hann[13] = 29;
1282 hann[14] = 34;
1283 hann[15] = 38;
1284 hann[16] = 43;
1285 hann[17] = 48;
1286 hann[18] = 54;
1287 hann[19] = 59;
1288 hann[20] = 66;
1289 hann[21] = 72;
1290 hann[22] = 78;
1291 hann[23] = 85;
1292 hann[24] = 92;
1293 hann[25] = 100;
1294 hann[26] = 107;
1295 hann[27] = 115;
1296 hann[28] = 123;
1297 hann[29] = 131;
1298 hann[30] = 140;
1299 hann[31] = 148;
1300 hann[32] = 157;
1301 hann[33] = 166;
1302 hann[34] = 176;
1303 hann[35] = 185;
1304 hann[36] = 195;
1305 hann[37] = 205;
1306 hann[38] = 215;
1307 hann[39] = 225;
1308 hann[40] = 236;
1309 hann[41] = 247;
1310 hann[42] = 257;
1311 hann[43] = 268;
1312 hann[44] = 279;
1313 hann[45] = 291;
1314 hann[46] = 302;
1315 hann[47] = 313;
1316 hann[48] = 325;
1317 hann[49] = 337;
1318 hann[50] = 349;
1319 hann[51] = 360;
1320 hann[52] = 372;
1321 hann[53] = 385;
1322 hann[54] = 397;
1323 hann[55] = 409;
1324 hann[56] = 421;
1325 hann[57] = 434;
1326 hann[58] = 446;
1327 hann[59] = 458;
1328 hann[60] = 471;
1329 hann[61] = 483;
1330 hann[62] = 496;
1331 hann[63] = 508;
1332 hann[64] = 521;
1333 hann[65] = 533;
1334 hann[66] = 546;
1335 hann[67] = 558;
1336 hann[68] = 571;
1337 hann[69] = 583;
1338 hann[70] = 596;
1339 hann[71] = 608;
1340 hann[72] = 620;
1341 hann[73] = 632;
1342 hann[74] = 645;
1343 hann[75] = 657;
1344 hann[76] = 669;
1345 hann[77] = 680;
1346 hann[78] = 692;
1347 hann[79] = 704;
1348 hann[80] = 715;
1349 hann[81] = 727;
1350 hann[82] = 738;
1351 hann[83] = 749;
1352 hann[84] = 760;
1353 hann[85] = 771;
1354 hann[86] = 782;
1355 hann[87] = 792;
1356 hann[88] = 803;
1357 hann[89] = 813;
1358 hann[90] = 823;
1359 hann[91] = 833;
1360 hann[92] = 842;
1361 hann[93] = 852;
1362 hann[94] = 861;
1363 hann[95] = 870;
1364 hann[96] = 879;
1365 hann[97] = 888;
1366 hann[98] = 896;
1367 hann[99] = 904;
1368 hann[100] = 912;
1369 hann[101] = 920;
1370 hann[102] = 927;
1371 hann[103] = 934;
1372 hann[104] = 941;
1373 hann[105] = 948;
1374 hann[106] = 954;
1375 hann[107] = 961;
1376 hann[108] = 966;
1377 hann[109] = 972;
1378 hann[110] = 977;
1379 hann[111] = 982;
1380 hann[112] = 987;
1381 hann[113] = 992;
1382 hann[114] = 996;
1383 hann[115] = 1000;
1384 hann[116] = 1003;
1385 hann[117] = 1007;
1386 hann[118] = 1010;
1387 hann[119] = 1012;
1388 hann[120] = 1015;
1389 hann[121] = 1017;
1390 hann[122] = 1019;
1391 hann[123] = 1020;
1392 hann[124] = 1022;
1393 hann[125] = 1023;
1394 hann[126] = 1023;
1395 hann[127] = 1023;
1396 hann[128] = 1023;
1397 hann[129] = 1023;
1398 hann[130] = 1023;
1399 hann[131] = 1022;
1400 hann[132] = 1020;
1401 hann[133] = 1019;
1402 hann[134] = 1017;
1403 hann[135] = 1015;
1404 hann[136] = 1012;
1405 hann[137] = 1010;
1406 hann[138] = 1007;
1407 hann[139] = 1003;
1408 hann[140] = 1000;
1409 hann[141] = 996;
1410 hann[142] = 992;
1411 hann[143] = 987;
1412 hann[144] = 982;
1413 hann[145] = 977;
1414 hann[146] = 972;
1415 hann[147] = 966;
1416 hann[148] = 961;
1417 hann[149] = 954;
1418 hann[150] = 948;
1419 hann[151] = 941;
1420 hann[152] = 934;
1421 hann[153] = 927;
1422 hann[154] = 920;
1423 hann[155] = 912;
1424 hann[156] = 904;
1425 hann[157] = 896;
1426 hann[158] = 888;
1427 hann[159] = 879;
1428 hann[160] = 870;
1429 hann[161] = 861;
1430 hann[162] = 852;
1431 hann[163] = 842;
1432 hann[164] = 833;
1433 hann[165] = 823;
1434 hann[166] = 813;
1435 hann[167] = 803;
1436 hann[168] = 792;
1437 hann[169] = 782;
1438 hann[170] = 771;
1439 hann[171] = 760;
1440 hann[172] = 749;
1441 hann[173] = 738;
1442 hann[174] = 727;
1443 hann[175] = 715;
1444 hann[176] = 704;
1445 hann[177] = 692;
1446 hann[178] = 680;
1447 hann[179] = 669;
1448 hann[180] = 657;
1449 hann[181] = 645;
1450 hann[182] = 632;
1451 hann[183] = 620;
1452 hann[184] = 608;
1453 hann[185] = 596;
1454 hann[186] = 583;
1455 hann[187] = 571;
1456 hann[188] = 558;
1457 hann[189] = 546;
1458 hann[190] = 533;
1459 hann[191] = 521;
1460 hann[192] = 508;
1461 hann[193] = 496;
1462 hann[194] = 483;
1463 hann[195] = 471;
1464 hann[196] = 458;
1465 hann[197] = 446;
1466 hann[198] = 434;
1467 hann[199] = 421;
1468 hann[200] = 409;
1469 hann[201] = 397;
1470 hann[202] = 385;
1471 hann[203] = 372;
1472 hann[204] = 360;
1473 hann[205] = 349;
1474 hann[206] = 337;
1475 hann[207] = 325;
1476 hann[208] = 313;
1477 hann[209] = 302;
1478 hann[210] = 291;
1479 hann[211] = 279;
1480 hann[212] = 268;
1481 hann[213] = 257;
1482 hann[214] = 247;
1483 hann[215] = 236;
1484 hann[216] = 225;
1485 hann[217] = 215;
1486 hann[218] = 205;
1487 hann[219] = 195;
1488 hann[220] = 185;
1489 hann[221] = 176;
1490 hann[222] = 166;
1491 hann[223] = 157;
1492 hann[224] = 148;
1493 hann[225] = 140;
1494 hann[226] = 131;
1495 hann[227] = 123;
1496 hann[228] = 115;
1497 hann[229] = 107;
1498 hann[230] = 100;
1499 hann[231] = 92;
1500 hann[232] = 85;
1501 hann[233] = 78;
1502 hann[234] = 72;
1503 hann[235] = 66;
1504 hann[236] = 59;
1505 hann[237] = 54;
1506 hann[238] = 48;
1507 hann[239] = 43;
1508 hann[240] = 38;
1509 hann[241] = 34;
1510 hann[242] = 29;
1511 hann[243] = 25;
1512 hann[244] = 21;
1513 hann[245] = 18;
1514 hann[246] = 15;
1515 hann[247] = 12;
1516 hann[248] = 9;
1517 hann[249] = 7;
1518 hann[250] = 5;
1519 hann[251] = 3;
1520 hann[252] = 2;
1521 hann[253] = 1;
1522 hann[254] = 0;
1523 hann[255] = 0;
1524
1525 } /* gen_hann2 */
1526
1527 /**
1528 * Creates the non uniform enhancement window (bilinearly mapped hannning window)
1529 * in order to reduce the formant enhancement in the high spectrum
1530 * @param mm : memory manager
1531 * @param sig_inObj : sig PU internal object of the sub-object
1532 * @return void
1533 * @callgraph
1534 * @callergraph
1535 * @remarks the outgput is based on the matlab script below\n
1536 matlab script
1537 -------------
1538 function makeEnhWind(alpha)
1539 N=129; % =HFFTSIZEE_P1
1540 s=(bilinmap(alpha,N));
1541 h=[hann(N)'];
1542 x=(1:N)/N;
1543 W=interp1(x,h,s); W(1)=0;
1544
1545 fid=fopen('enhwind.txt','wt');
1546 fprintf(fid,'picoos_int16 enh_wind_init(sig_innerobj_t *sig_inObj) {\n');
1547 for i=1:N,
1548 fprintf(fid,[' sig_inObj->enhwind[' int2str(i) '] = (picoos_single)' num2str(W(i),'%0.7g') ';\n']);
1549 end;
1550 fprintf(fid,' return PICO_OK;\n');
1551 fprintf(fid,' }; \n');
1552 fclose(fid);
1553 %figure(1); plot(x*8,W);
1554 */
enh_wind_init(sig_innerobj_t * sig_inObj)1555 static void enh_wind_init(sig_innerobj_t *sig_inObj)
1556 {
1557 /* picoos_int16 i; */
1558 picoos_int32 *c;
1559
1560 c = sig_inObj->cos_table;
1561
1562 c[0] = 4096;
1563 c[1] = 4095;
1564 c[2] = 4095;
1565 c[3] = 4095;
1566 c[4] = 4095;
1567 c[5] = 4095;
1568 c[6] = 4095;
1569 c[7] = 4095;
1570 c[8] = 4094;
1571 c[9] = 4094;
1572 c[10] = 4094;
1573 c[11] = 4093;
1574 c[12] = 4093;
1575 c[13] = 4092;
1576 c[14] = 4092;
1577 c[15] = 4091;
1578 c[16] = 4091;
1579 c[17] = 4090;
1580 c[18] = 4089;
1581 c[19] = 4089;
1582 c[20] = 4088;
1583 c[21] = 4087;
1584 c[22] = 4086;
1585 c[23] = 4085;
1586 c[24] = 4084;
1587 c[25] = 4083;
1588 c[26] = 4082;
1589 c[27] = 4081;
1590 c[28] = 4080;
1591 c[29] = 4079;
1592 c[30] = 4078;
1593 c[31] = 4077;
1594 c[32] = 4076;
1595 c[33] = 4075;
1596 c[34] = 4073;
1597 c[35] = 4072;
1598 c[36] = 4071;
1599 c[37] = 4069;
1600 c[38] = 4068;
1601 c[39] = 4066;
1602 c[40] = 4065;
1603 c[41] = 4063;
1604 c[42] = 4062;
1605 c[43] = 4060;
1606 c[44] = 4058;
1607 c[45] = 4057;
1608 c[46] = 4055;
1609 c[47] = 4053;
1610 c[48] = 4051;
1611 c[49] = 4049;
1612 c[50] = 4047;
1613 c[51] = 4045;
1614 c[52] = 4043;
1615 c[53] = 4041;
1616 c[54] = 4039;
1617 c[55] = 4037;
1618 c[56] = 4035;
1619 c[57] = 4033;
1620 c[58] = 4031;
1621 c[59] = 4029;
1622 c[60] = 4026;
1623 c[61] = 4024;
1624 c[62] = 4022;
1625 c[63] = 4019;
1626 c[64] = 4017;
1627 c[65] = 4014;
1628 c[66] = 4012;
1629 c[67] = 4009;
1630 c[68] = 4007;
1631 c[69] = 4004;
1632 c[70] = 4001;
1633 c[71] = 3999;
1634 c[72] = 3996;
1635 c[73] = 3993;
1636 c[74] = 3990;
1637 c[75] = 3988;
1638 c[76] = 3985;
1639 c[77] = 3982;
1640 c[78] = 3979;
1641 c[79] = 3976;
1642 c[80] = 3973;
1643 c[81] = 3970;
1644 c[82] = 3967;
1645 c[83] = 3963;
1646 c[84] = 3960;
1647 c[85] = 3957;
1648 c[86] = 3954;
1649 c[87] = 3950;
1650 c[88] = 3947;
1651 c[89] = 3944;
1652 c[90] = 3940;
1653 c[91] = 3937;
1654 c[92] = 3933;
1655 c[93] = 3930;
1656 c[94] = 3926;
1657 c[95] = 3923;
1658 c[96] = 3919;
1659 c[97] = 3915;
1660 c[98] = 3912;
1661 c[99] = 3908;
1662 c[100] = 3904;
1663 c[101] = 3900;
1664 c[102] = 3897;
1665 c[103] = 3893;
1666 c[104] = 3889;
1667 c[105] = 3885;
1668 c[106] = 3881;
1669 c[107] = 3877;
1670 c[108] = 3873;
1671 c[109] = 3869;
1672 c[110] = 3864;
1673 c[111] = 3860;
1674 c[112] = 3856;
1675 c[113] = 3852;
1676 c[114] = 3848;
1677 c[115] = 3843;
1678 c[116] = 3839;
1679 c[117] = 3834;
1680 c[118] = 3830;
1681 c[119] = 3826;
1682 c[120] = 3821;
1683 c[121] = 3816;
1684 c[122] = 3812;
1685 c[123] = 3807;
1686 c[124] = 3803;
1687 c[125] = 3798;
1688 c[126] = 3793;
1689 c[127] = 3789;
1690 c[128] = 3784;
1691 c[129] = 3779;
1692 c[130] = 3774;
1693 c[131] = 3769;
1694 c[132] = 3764;
1695 c[133] = 3759;
1696 c[134] = 3754;
1697 c[135] = 3749;
1698 c[136] = 3744;
1699 c[137] = 3739;
1700 c[138] = 3734;
1701 c[139] = 3729;
1702 c[140] = 3723;
1703 c[141] = 3718;
1704 c[142] = 3713;
1705 c[143] = 3708;
1706 c[144] = 3702;
1707 c[145] = 3697;
1708 c[146] = 3691;
1709 c[147] = 3686;
1710 c[148] = 3680;
1711 c[149] = 3675;
1712 c[150] = 3669;
1713 c[151] = 3664;
1714 c[152] = 3658;
1715 c[153] = 3652;
1716 c[154] = 3647;
1717 c[155] = 3641;
1718 c[156] = 3635;
1719 c[157] = 3629;
1720 c[158] = 3624;
1721 c[159] = 3618;
1722 c[160] = 3612;
1723 c[161] = 3606;
1724 c[162] = 3600;
1725 c[163] = 3594;
1726 c[164] = 3588;
1727 c[165] = 3582;
1728 c[166] = 3576;
1729 c[167] = 3570;
1730 c[168] = 3563;
1731 c[169] = 3557;
1732 c[170] = 3551;
1733 c[171] = 3545;
1734 c[172] = 3538;
1735 c[173] = 3532;
1736 c[174] = 3526;
1737 c[175] = 3519;
1738 c[176] = 3513;
1739 c[177] = 3506;
1740 c[178] = 3500;
1741 c[179] = 3493;
1742 c[180] = 3487;
1743 c[181] = 3480;
1744 c[182] = 3473;
1745 c[183] = 3467;
1746 c[184] = 3460;
1747 c[185] = 3453;
1748 c[186] = 3447;
1749 c[187] = 3440;
1750 c[188] = 3433;
1751 c[189] = 3426;
1752 c[190] = 3419;
1753 c[191] = 3412;
1754 c[192] = 3405;
1755 c[193] = 3398;
1756 c[194] = 3391;
1757 c[195] = 3384;
1758 c[196] = 3377;
1759 c[197] = 3370;
1760 c[198] = 3363;
1761 c[199] = 3356;
1762 c[200] = 3348;
1763 c[201] = 3341;
1764 c[202] = 3334;
1765 c[203] = 3326;
1766 c[204] = 3319;
1767 c[205] = 3312;
1768 c[206] = 3304;
1769 c[207] = 3297;
1770 c[208] = 3289;
1771 c[209] = 3282;
1772 c[210] = 3274;
1773 c[211] = 3267;
1774 c[212] = 3259;
1775 c[213] = 3252;
1776 c[214] = 3244;
1777 c[215] = 3236;
1778 c[216] = 3229;
1779 c[217] = 3221;
1780 c[218] = 3213;
1781 c[219] = 3205;
1782 c[220] = 3197;
1783 c[221] = 3190;
1784 c[222] = 3182;
1785 c[223] = 3174;
1786 c[224] = 3166;
1787 c[225] = 3158;
1788 c[226] = 3150;
1789 c[227] = 3142;
1790 c[228] = 3134;
1791 c[229] = 3126;
1792 c[230] = 3117;
1793 c[231] = 3109;
1794 c[232] = 3101;
1795 c[233] = 3093;
1796 c[234] = 3085;
1797 c[235] = 3076;
1798 c[236] = 3068;
1799 c[237] = 3060;
1800 c[238] = 3051;
1801 c[239] = 3043;
1802 c[240] = 3034;
1803 c[241] = 3026;
1804 c[242] = 3018;
1805 c[243] = 3009;
1806 c[244] = 3000;
1807 c[245] = 2992;
1808 c[246] = 2983;
1809 c[247] = 2975;
1810 c[248] = 2966;
1811 c[249] = 2957;
1812 c[250] = 2949;
1813 c[251] = 2940;
1814 c[252] = 2931;
1815 c[253] = 2922;
1816 c[254] = 2914;
1817 c[255] = 2905;
1818 c[256] = 2896;
1819 c[257] = 2887;
1820 c[258] = 2878;
1821 c[259] = 2869;
1822 c[260] = 2860;
1823 c[261] = 2851;
1824 c[262] = 2842;
1825 c[263] = 2833;
1826 c[264] = 2824;
1827 c[265] = 2815;
1828 c[266] = 2806;
1829 c[267] = 2796;
1830 c[268] = 2787;
1831 c[269] = 2778;
1832 c[270] = 2769;
1833 c[271] = 2760;
1834 c[272] = 2750;
1835 c[273] = 2741;
1836 c[274] = 2732;
1837 c[275] = 2722;
1838 c[276] = 2713;
1839 c[277] = 2703;
1840 c[278] = 2694;
1841 c[279] = 2684;
1842 c[280] = 2675;
1843 c[281] = 2665;
1844 c[282] = 2656;
1845 c[283] = 2646;
1846 c[284] = 2637;
1847 c[285] = 2627;
1848 c[286] = 2617;
1849 c[287] = 2608;
1850 c[288] = 2598;
1851 c[289] = 2588;
1852 c[290] = 2578;
1853 c[291] = 2569;
1854 c[292] = 2559;
1855 c[293] = 2549;
1856 c[294] = 2539;
1857 c[295] = 2529;
1858 c[296] = 2519;
1859 c[297] = 2510;
1860 c[298] = 2500;
1861 c[299] = 2490;
1862 c[300] = 2480;
1863 c[301] = 2470;
1864 c[302] = 2460;
1865 c[303] = 2450;
1866 c[304] = 2439;
1867 c[305] = 2429;
1868 c[306] = 2419;
1869 c[307] = 2409;
1870 c[308] = 2399;
1871 c[309] = 2389;
1872 c[310] = 2379;
1873 c[311] = 2368;
1874 c[312] = 2358;
1875 c[313] = 2348;
1876 c[314] = 2337;
1877 c[315] = 2327;
1878 c[316] = 2317;
1879 c[317] = 2306;
1880 c[318] = 2296;
1881 c[319] = 2286;
1882 c[320] = 2275;
1883 c[321] = 2265;
1884 c[322] = 2254;
1885 c[323] = 2244;
1886 c[324] = 2233;
1887 c[325] = 2223;
1888 c[326] = 2212;
1889 c[327] = 2201;
1890 c[328] = 2191;
1891 c[329] = 2180;
1892 c[330] = 2170;
1893 c[331] = 2159;
1894 c[332] = 2148;
1895 c[333] = 2138;
1896 c[334] = 2127;
1897 c[335] = 2116;
1898 c[336] = 2105;
1899 c[337] = 2094;
1900 c[338] = 2084;
1901 c[339] = 2073;
1902 c[340] = 2062;
1903 c[341] = 2051;
1904 c[342] = 2040;
1905 c[343] = 2029;
1906 c[344] = 2018;
1907 c[345] = 2007;
1908 c[346] = 1997;
1909 c[347] = 1986;
1910 c[348] = 1975;
1911 c[349] = 1964;
1912 c[350] = 1952;
1913 c[351] = 1941;
1914 c[352] = 1930;
1915 c[353] = 1919;
1916 c[354] = 1908;
1917 c[355] = 1897;
1918 c[356] = 1886;
1919 c[357] = 1875;
1920 c[358] = 1864;
1921 c[359] = 1852;
1922 c[360] = 1841;
1923 c[361] = 1830;
1924 c[362] = 1819;
1925 c[363] = 1807;
1926 c[364] = 1796;
1927 c[365] = 1785;
1928 c[366] = 1773;
1929 c[367] = 1762;
1930 c[368] = 1751;
1931 c[369] = 1739;
1932 c[370] = 1728;
1933 c[371] = 1717;
1934 c[372] = 1705;
1935 c[373] = 1694;
1936 c[374] = 1682;
1937 c[375] = 1671;
1938 c[376] = 1659;
1939 c[377] = 1648;
1940 c[378] = 1636;
1941 c[379] = 1625;
1942 c[380] = 1613;
1943 c[381] = 1602;
1944 c[382] = 1590;
1945 c[383] = 1579;
1946 c[384] = 1567;
1947 c[385] = 1555;
1948 c[386] = 1544;
1949 c[387] = 1532;
1950 c[388] = 1520;
1951 c[389] = 1509;
1952 c[390] = 1497;
1953 c[391] = 1485;
1954 c[392] = 1474;
1955 c[393] = 1462;
1956 c[394] = 1450;
1957 c[395] = 1438;
1958 c[396] = 1427;
1959 c[397] = 1415;
1960 c[398] = 1403;
1961 c[399] = 1391;
1962 c[400] = 1379;
1963 c[401] = 1368;
1964 c[402] = 1356;
1965 c[403] = 1344;
1966 c[404] = 1332;
1967 c[405] = 1320;
1968 c[406] = 1308;
1969 c[407] = 1296;
1970 c[408] = 1284;
1971 c[409] = 1272;
1972 c[410] = 1260;
1973 c[411] = 1248;
1974 c[412] = 1237;
1975 c[413] = 1225;
1976 c[414] = 1213;
1977 c[415] = 1201;
1978 c[416] = 1189;
1979 c[417] = 1176;
1980 c[418] = 1164;
1981 c[419] = 1152;
1982 c[420] = 1140;
1983 c[421] = 1128;
1984 c[422] = 1116;
1985 c[423] = 1104;
1986 c[424] = 1092;
1987 c[425] = 1080;
1988 c[426] = 1068;
1989 c[427] = 1056;
1990 c[428] = 1043;
1991 c[429] = 1031;
1992 c[430] = 1019;
1993 c[431] = 1007;
1994 c[432] = 995;
1995 c[433] = 983;
1996 c[434] = 970;
1997 c[435] = 958;
1998 c[436] = 946;
1999 c[437] = 934;
2000 c[438] = 921;
2001 c[439] = 909;
2002 c[440] = 897;
2003 c[441] = 885;
2004 c[442] = 872;
2005 c[443] = 860;
2006 c[444] = 848;
2007 c[445] = 836;
2008 c[446] = 823;
2009 c[447] = 811;
2010 c[448] = 799;
2011 c[449] = 786;
2012 c[450] = 774;
2013 c[451] = 762;
2014 c[452] = 749;
2015 c[453] = 737;
2016 c[454] = 725;
2017 c[455] = 712;
2018 c[456] = 700;
2019 c[457] = 687;
2020 c[458] = 675;
2021 c[459] = 663;
2022 c[460] = 650;
2023 c[461] = 638;
2024 c[462] = 625;
2025 c[463] = 613;
2026 c[464] = 601;
2027 c[465] = 588;
2028 c[466] = 576;
2029 c[467] = 563;
2030 c[468] = 551;
2031 c[469] = 538;
2032 c[470] = 526;
2033 c[471] = 513;
2034 c[472] = 501;
2035 c[473] = 488;
2036 c[474] = 476;
2037 c[475] = 463;
2038 c[476] = 451;
2039 c[477] = 438;
2040 c[478] = 426;
2041 c[479] = 413;
2042 c[480] = 401;
2043 c[481] = 388;
2044 c[482] = 376;
2045 c[483] = 363;
2046 c[484] = 351;
2047 c[485] = 338;
2048 c[486] = 326;
2049 c[487] = 313;
2050 c[488] = 301;
2051 c[489] = 288;
2052 c[490] = 276;
2053 c[491] = 263;
2054 c[492] = 251;
2055 c[493] = 238;
2056 c[494] = 226;
2057 c[495] = 213;
2058 c[496] = 200;
2059 c[497] = 188;
2060 c[498] = 175;
2061 c[499] = 163;
2062 c[500] = 150;
2063 c[501] = 138;
2064 c[502] = 125;
2065 c[503] = 113;
2066 c[504] = 100;
2067 c[505] = 87;
2068 c[506] = 75;
2069 c[507] = 62;
2070 c[508] = 50;
2071 c[509] = 37;
2072 c[510] = 25;
2073 c[511] = 12;
2074 c[512] = 0;
2075 } /*enh_wind_init*/
2076
2077 /**
2078 * Initializes a useful large array of random numbers
2079 * @param sig_inObj : sig PU internal object of the sub-object
2080 * @return void
2081 * @callgraph
2082 * @callergraph
2083 */
init_rand(sig_innerobj_t * sig_inObj)2084 static void init_rand(sig_innerobj_t *sig_inObj)
2085 {
2086 picoos_int32 *q = sig_inObj->int_vec34;
2087 picoos_int32 *r = sig_inObj->int_vec35;
2088
2089 sig_inObj->iRand = 0;
2090
2091 q[0] = -2198;
2092 r[0] = 3455;
2093 q[1] = 3226;
2094 r[1] = -2522;
2095 q[2] = -845;
2096 r[2] = 4007;
2097 q[3] = -1227;
2098 r[3] = 3907;
2099 q[4] = -3480;
2100 r[4] = 2158;
2101 q[5] = -1325;
2102 r[5] = -3875;
2103 q[6] = 2089;
2104 r[6] = -3522;
2105 q[7] = -468;
2106 r[7] = 4069;
2107 q[8] = 711;
2108 r[8] = -4033;
2109 q[9] = 3862;
2110 r[9] = 1362;
2111 q[10] = 4054;
2112 r[10] = -579;
2113 q[11] = 2825;
2114 r[11] = 2965;
2115 q[12] = 2704;
2116 r[12] = -3076;
2117 q[13] = 4081;
2118 r[13] = 344;
2119 q[14] = -3912;
2120 r[14] = 1211;
2121 q[15] = -3541;
2122 r[15] = 2058;
2123 q[16] = 2694;
2124 r[16] = 3084;
2125 q[17] = 835;
2126 r[17] = 4009;
2127 q[18] = -2578;
2128 r[18] = -3182;
2129 q[19] = 3205;
2130 r[19] = 2550;
2131 q[20] = -4074;
2132 r[20] = -418;
2133 q[21] = -183;
2134 r[21] = -4091;
2135 q[22] = -2665;
2136 r[22] = -3110;
2137 q[23] = -1367;
2138 r[23] = 3860;
2139 q[24] = -2266;
2140 r[24] = -3411;
2141 q[25] = 3327;
2142 r[25] = -2387;
2143 q[26] = -2807;
2144 r[26] = -2982;
2145 q[27] = -3175;
2146 r[27] = -2587;
2147 q[28] = -4095;
2148 r[28] = 27;
2149 q[29] = -811;
2150 r[29] = -4014;
2151 q[30] = 4082;
2152 r[30] = 332;
2153 q[31] = -2175;
2154 r[31] = 3470;
2155 q[32] = 3112;
2156 r[32] = 2662;
2157 q[33] = 1168;
2158 r[33] = -3925;
2159 q[34] = 2659;
2160 r[34] = 3115;
2161 q[35] = 4048;
2162 r[35] = 622;
2163 q[36] = 4092;
2164 r[36] = -165;
2165 q[37] = -4036;
2166 r[37] = 697;
2167 q[38] = 1081;
2168 r[38] = -3950;
2169 q[39] = -548;
2170 r[39] = 4059;
2171 q[40] = 4038;
2172 r[40] = 685;
2173 q[41] = -511;
2174 r[41] = 4063;
2175 q[42] = 3317;
2176 r[42] = -2402;
2177 q[43] = -3180;
2178 r[43] = 2580;
2179 q[44] = 851;
2180 r[44] = -4006;
2181 q[45] = 2458;
2182 r[45] = -3276;
2183 q[46] = -1453;
2184 r[46] = 3829;
2185 q[47] = -3577;
2186 r[47] = 1995;
2187 q[48] = -3708;
2188 r[48] = -1738;
2189 q[49] = -3890;
2190 r[49] = 1282;
2191 q[50] = 4041;
2192 r[50] = 666;
2193 q[51] = -3511;
2194 r[51] = -2108;
2195 q[52] = -1454;
2196 r[52] = -3828;
2197 q[53] = 2124;
2198 r[53] = 3502;
2199 q[54] = -3159;
2200 r[54] = 2606;
2201 q[55] = 2384;
2202 r[55] = -3330;
2203 q[56] = -3767;
2204 r[56] = -1607;
2205 q[57] = -4063;
2206 r[57] = -513;
2207 q[58] = 3952;
2208 r[58] = -1075;
2209 q[59] = -3778;
2210 r[59] = -1581;
2211 q[60] = -301;
2212 r[60] = -4084;
2213 q[61] = -4026;
2214 r[61] = 751;
2215 q[62] = -3346;
2216 r[62] = 2361;
2217 q[63] = -2426;
2218 r[63] = 3299;
2219 q[64] = 428;
2220 r[64] = -4073;
2221 q[65] = 3968;
2222 r[65] = 1012;
2223 q[66] = 2900;
2224 r[66] = -2892;
2225 q[67] = -263;
2226 r[67] = 4087;
2227 q[68] = 4083;
2228 r[68] = 322;
2229 q[69] = 2024;
2230 r[69] = 3560;
2231 q[70] = 4015;
2232 r[70] = 808;
2233 q[71] = -3971;
2234 r[71] = -1000;
2235 q[72] = 3785;
2236 r[72] = -1564;
2237 q[73] = -3726;
2238 r[73] = 1701;
2239 q[74] = -3714;
2240 r[74] = 1725;
2241 q[75] = 743;
2242 r[75] = 4027;
2243 q[76] = 875;
2244 r[76] = -4001;
2245 q[77] = 294;
2246 r[77] = 4085;
2247 q[78] = 2611;
2248 r[78] = 3155;
2249 q[79] = 2491;
2250 r[79] = -3251;
2251 q[80] = 1558;
2252 r[80] = 3787;
2253 q[81] = -2063;
2254 r[81] = -3538;
2255 q[82] = 3809;
2256 r[82] = -1505;
2257 q[83] = -2987;
2258 r[83] = 2802;
2259 q[84] = -1955;
2260 r[84] = 3599;
2261 q[85] = 1980;
2262 r[85] = -3585;
2263 q[86] = -539;
2264 r[86] = -4060;
2265 q[87] = -3210;
2266 r[87] = 2543;
2267 q[88] = 2415;
2268 r[88] = -3308;
2269 q[89] = 1587;
2270 r[89] = 3775;
2271 q[90] = -3943;
2272 r[90] = 1106;
2273 q[91] = 3476;
2274 r[91] = 2165;
2275 q[92] = 2253;
2276 r[92] = 3420;
2277 q[93] = -2584;
2278 r[93] = 3177;
2279 q[94] = 3804;
2280 r[94] = -1518;
2281 q[95] = -3637;
2282 r[95] = 1883;
2283 q[96] = 3289;
2284 r[96] = -2440;
2285 q[97] = -1621;
2286 r[97] = 3761;
2287 q[98] = 1645;
2288 r[98] = 3751;
2289 q[99] = -3471;
2290 r[99] = 2173;
2291 q[100] = 4071;
2292 r[100] = -449;
2293 q[101] = -872;
2294 r[101] = -4001;
2295 q[102] = -3897;
2296 r[102] = 1259;
2297 q[103] = -3590;
2298 r[103] = 1970;
2299 q[104] = -2456;
2300 r[104] = -3277;
2301 q[105] = -3004;
2302 r[105] = 2783;
2303 q[106] = 2589;
2304 r[106] = 3173;
2305 q[107] = 3727;
2306 r[107] = -1698;
2307 q[108] = 2992;
2308 r[108] = 2796;
2309 q[109] = 794;
2310 r[109] = -4018;
2311 q[110] = -918;
2312 r[110] = 3991;
2313 q[111] = 1446;
2314 r[111] = -3831;
2315 q[112] = 3871;
2316 r[112] = -1338;
2317 q[113] = -612;
2318 r[113] = -4049;
2319 q[114] = -1566;
2320 r[114] = -3784;
2321 q[115] = 672;
2322 r[115] = -4040;
2323 q[116] = 3841;
2324 r[116] = 1422;
2325 q[117] = 3545;
2326 r[117] = -2051;
2327 q[118] = -1982;
2328 r[118] = -3584;
2329 q[119] = -3413;
2330 r[119] = 2263;
2331 q[120] = -3265;
2332 r[120] = -2473;
2333 q[121] = -2876;
2334 r[121] = -2915;
2335 q[122] = 4094;
2336 r[122] = -117;
2337 q[123] = -269;
2338 r[123] = 4087;
2339 q[124] = -4077;
2340 r[124] = 391;
2341 q[125] = -3759;
2342 r[125] = 1626;
2343 q[126] = 1639;
2344 r[126] = 3753;
2345 q[127] = 3041;
2346 r[127] = -2743;
2347 q[128] = 5;
2348 r[128] = 4095;
2349 q[129] = 2778;
2350 r[129] = -3009;
2351 q[130] = 1121;
2352 r[130] = -3939;
2353 q[131] = -455;
2354 r[131] = -4070;
2355 q[132] = 3532;
2356 r[132] = 2073;
2357 q[133] = -143;
2358 r[133] = -4093;
2359 q[134] = -2357;
2360 r[134] = -3349;
2361 q[135] = 458;
2362 r[135] = 4070;
2363 q[136] = -2887;
2364 r[136] = -2904;
2365 q[137] = -1104;
2366 r[137] = 3944;
2367 q[138] = -2104;
2368 r[138] = -3513;
2369 q[139] = 126;
2370 r[139] = 4094;
2371 q[140] = -3655;
2372 r[140] = -1848;
2373 q[141] = -3896;
2374 r[141] = 1263;
2375 q[142] = -3874;
2376 r[142] = -1327;
2377 q[143] = 4058;
2378 r[143] = 553;
2379 q[144] = -1831;
2380 r[144] = -3663;
2381 q[145] = -255;
2382 r[145] = -4088;
2383 q[146] = -1211;
2384 r[146] = 3912;
2385 q[147] = 445;
2386 r[147] = 4071;
2387 q[148] = 2268;
2388 r[148] = 3410;
2389 q[149] = -4010;
2390 r[149] = 833;
2391 q[150] = 2621;
2392 r[150] = 3147;
2393 q[151] = -250;
2394 r[151] = 4088;
2395 q[152] = -3409;
2396 r[152] = -2269;
2397 q[153] = -2710;
2398 r[153] = -3070;
2399 q[154] = 4063;
2400 r[154] = 518;
2401 q[155] = -3611;
2402 r[155] = -1933;
2403 q[156] = -3707;
2404 r[156] = -1741;
2405 q[157] = -1151;
2406 r[157] = -3930;
2407 q[158] = 3976;
2408 r[158] = -983;
2409 q[159] = -1736;
2410 r[159] = 3709;
2411 q[160] = 3669;
2412 r[160] = 1820;
2413 q[161] = -143;
2414 r[161] = 4093;
2415 q[162] = -3879;
2416 r[162] = -1313;
2417 q[163] = -2242;
2418 r[163] = -3427;
2419 q[164] = -4095;
2420 r[164] = 0;
2421 q[165] = -1159;
2422 r[165] = -3928;
2423 q[166] = -3155;
2424 r[166] = 2611;
2425 q[167] = -2887;
2426 r[167] = -2904;
2427 q[168] = -4095;
2428 r[168] = 56;
2429 q[169] = -3861;
2430 r[169] = -1364;
2431 q[170] = -2814;
2432 r[170] = 2976;
2433 q[171] = -3680;
2434 r[171] = -1798;
2435 q[172] = -4094;
2436 r[172] = -107;
2437 q[173] = -3626;
2438 r[173] = 1903;
2439 q[174] = 3403;
2440 r[174] = 2278;
2441 q[175] = -1735;
2442 r[175] = -3710;
2443 q[176] = -2126;
2444 r[176] = -3500;
2445 q[177] = 3183;
2446 r[177] = -2577;
2447 q[178] = -3499;
2448 r[178] = 2128;
2449 q[179] = -1736;
2450 r[179] = 3709;
2451 q[180] = 2592;
2452 r[180] = -3170;
2453 q[181] = 3875;
2454 r[181] = 1326;
2455 q[182] = 3596;
2456 r[182] = 1960;
2457 q[183] = 3915;
2458 r[183] = -1202;
2459 q[184] = 1570;
2460 r[184] = 3783;
2461 q[185] = -3319;
2462 r[185] = -2400;
2463 q[186] = 4019;
2464 r[186] = 787;
2465 q[187] = -187;
2466 r[187] = 4091;
2467 q[188] = 1370;
2468 r[188] = -3859;
2469 q[189] = -4091;
2470 r[189] = 199;
2471 q[190] = 3626;
2472 r[190] = 1904;
2473 q[191] = -2943;
2474 r[191] = 2848;
2475 q[192] = 56;
2476 r[192] = 4095;
2477 q[193] = 2824;
2478 r[193] = 2966;
2479 q[194] = -3994;
2480 r[194] = -904;
2481 q[195] = 56;
2482 r[195] = 4095;
2483 q[196] = -2045;
2484 r[196] = 3548;
2485 q[197] = -3653;
2486 r[197] = 1850;
2487 q[198] = -2864;
2488 r[198] = 2927;
2489 q[199] = -1996;
2490 r[199] = 3576;
2491 q[200] = -4061;
2492 r[200] = 527;
2493 q[201] = 159;
2494 r[201] = 4092;
2495 q[202] = -3363;
2496 r[202] = 2336;
2497 q[203] = -4074;
2498 r[203] = 421;
2499 q[204] = 2043;
2500 r[204] = 3549;
2501 q[205] = 4095;
2502 r[205] = -70;
2503 q[206] = -2107;
2504 r[206] = -3512;
2505 q[207] = -1973;
2506 r[207] = 3589;
2507 q[208] = -3138;
2508 r[208] = 2631;
2509 q[209] = -3625;
2510 r[209] = -1905;
2511 q[210] = 2413;
2512 r[210] = 3309;
2513 q[211] = -50;
2514 r[211] = -4095;
2515 q[212] = 2813;
2516 r[212] = 2976;
2517 q[213] = -535;
2518 r[213] = -4060;
2519 q[214] = 1250;
2520 r[214] = 3900;
2521 q[215] = 1670;
2522 r[215] = -3739;
2523 q[216] = 1945;
2524 r[216] = -3604;
2525 q[217] = -476;
2526 r[217] = -4068;
2527 q[218] = -3659;
2528 r[218] = -1840;
2529 q[219] = 2745;
2530 r[219] = 3039;
2531 q[220] = -674;
2532 r[220] = -4040;
2533 q[221] = 2383;
2534 r[221] = 3330;
2535 q[222] = 4086;
2536 r[222] = 274;
2537 q[223] = -4030;
2538 r[223] = 730;
2539 q[224] = 768;
2540 r[224] = -4023;
2541 q[225] = 3925;
2542 r[225] = 1170;
2543 q[226] = 785;
2544 r[226] = 4019;
2545 q[227] = -3101;
2546 r[227] = -2675;
2547 q[228] = 4030;
2548 r[228] = -729;
2549 q[229] = 3422;
2550 r[229] = 2249;
2551 q[230] = -3847;
2552 r[230] = 1403;
2553 q[231] = 3902;
2554 r[231] = -1243;
2555 q[232] = 2114;
2556 r[232] = -3507;
2557 q[233] = -2359;
2558 r[233] = 3348;
2559 q[234] = 3754;
2560 r[234] = -1638;
2561 q[235] = -4095;
2562 r[235] = -83;
2563 q[236] = 2301;
2564 r[236] = -3388;
2565 q[237] = 3336;
2566 r[237] = 2375;
2567 q[238] = -2045;
2568 r[238] = 3548;
2569 q[239] = -413;
2570 r[239] = -4075;
2571 q[240] = 1848;
2572 r[240] = 3655;
2573 q[241] = 4072;
2574 r[241] = -437;
2575 q[242] = 4069;
2576 r[242] = -463;
2577 q[243] = 1386;
2578 r[243] = -3854;
2579 q[244] = 966;
2580 r[244] = 3980;
2581 q[245] = -1684;
2582 r[245] = -3733;
2583 q[246] = 2953;
2584 r[246] = 2837;
2585 q[247] = -3961;
2586 r[247] = -1040;
2587 q[248] = 3512;
2588 r[248] = -2107;
2589 q[249] = 1363;
2590 r[249] = 3862;
2591 q[250] = 1883;
2592 r[250] = 3637;
2593 q[251] = 2657;
2594 r[251] = 3116;
2595 q[252] = 2347;
2596 r[252] = -3356;
2597 q[253] = -1635;
2598 r[253] = -3755;
2599 q[254] = 3170;
2600 r[254] = 2593;
2601 q[255] = 2856;
2602 r[255] = 2935;
2603 q[256] = 494;
2604 r[256] = 4066;
2605 q[257] = 1936;
2606 r[257] = -3609;
2607 q[258] = 245;
2608 r[258] = 4088;
2609 q[259] = -1211;
2610 r[259] = -3912;
2611 q[260] = -3600;
2612 r[260] = 1952;
2613 q[261] = 1632;
2614 r[261] = 3756;
2615 q[262] = 2341;
2616 r[262] = 3360;
2617 q[263] = 186;
2618 r[263] = -4091;
2619 q[264] = 4011;
2620 r[264] = 829;
2621 q[265] = -3490;
2622 r[265] = -2143;
2623 q[266] = 269;
2624 r[266] = -4087;
2625 q[267] = -2939;
2626 r[267] = 2852;
2627 q[268] = 1600;
2628 r[268] = 3770;
2629 q[269] = -3405;
2630 r[269] = -2275;
2631 q[270] = -3134;
2632 r[270] = -2636;
2633 q[271] = 2642;
2634 r[271] = -3129;
2635 q[272] = 3629;
2636 r[272] = 1898;
2637 q[273] = 3413;
2638 r[273] = 2264;
2639 q[274] = 2050;
2640 r[274] = 3545;
2641 q[275] = 988;
2642 r[275] = -3975;
2643 q[276] = -660;
2644 r[276] = 4042;
2645 q[277] = 978;
2646 r[277] = -3977;
2647 q[278] = 1965;
2648 r[278] = -3593;
2649 q[279] = -1513;
2650 r[279] = -3806;
2651 q[280] = -4076;
2652 r[280] = 401;
2653 q[281] = -4094;
2654 r[281] = -92;
2655 q[282] = -1914;
2656 r[282] = 3621;
2657 q[283] = 2006;
2658 r[283] = -3570;
2659 q[284] = -1550;
2660 r[284] = -3791;
2661 q[285] = 3774;
2662 r[285] = -1591;
2663 q[286] = -3958;
2664 r[286] = 1052;
2665 q[287] = -3576;
2666 r[287] = 1997;
2667 q[288] = -382;
2668 r[288] = 4078;
2669 q[289] = 1288;
2670 r[289] = 3888;
2671 q[290] = -2965;
2672 r[290] = -2825;
2673 q[291] = 1608;
2674 r[291] = 3767;
2675 q[292] = 3052;
2676 r[292] = -2731;
2677 q[293] = -622;
2678 r[293] = 4048;
2679 q[294] = -3836;
2680 r[294] = 1434;
2681 q[295] = -3542;
2682 r[295] = 2056;
2683 q[296] = -2648;
2684 r[296] = 3124;
2685 q[297] = -1178;
2686 r[297] = -3922;
2687 q[298] = -1109;
2688 r[298] = 3942;
2689 q[299] = 3910;
2690 r[299] = 1217;
2691 q[300] = 1199;
2692 r[300] = -3916;
2693 q[301] = -3386;
2694 r[301] = 2303;
2695 q[302] = -3453;
2696 r[302] = 2202;
2697 q[303] = -2877;
2698 r[303] = 2914;
2699 q[304] = 4095;
2700 r[304] = -47;
2701 q[305] = 3635;
2702 r[305] = 1886;
2703 q[306] = -2134;
2704 r[306] = -3495;
2705 q[307] = 613;
2706 r[307] = -4049;
2707 q[308] = -2700;
2708 r[308] = 3079;
2709 q[309] = 4091;
2710 r[309] = -195;
2711 q[310] = 3989;
2712 r[310] = -927;
2713 q[311] = -2385;
2714 r[311] = 3329;
2715 q[312] = 4094;
2716 r[312] = -103;
2717 q[313] = 1044;
2718 r[313] = -3960;
2719 q[314] = -1734;
2720 r[314] = -3710;
2721 q[315] = 1646;
2722 r[315] = 3750;
2723 q[316] = 575;
2724 r[316] = 4055;
2725 q[317] = -2629;
2726 r[317] = -3140;
2727 q[318] = 3266;
2728 r[318] = 2471;
2729 q[319] = 4091;
2730 r[319] = -194;
2731 q[320] = -2154;
2732 r[320] = 3483;
2733 q[321] = 659;
2734 r[321] = 4042;
2735 q[322] = -1785;
2736 r[322] = -3686;
2737 q[323] = -717;
2738 r[323] = -4032;
2739 q[324] = 4095;
2740 r[324] = -37;
2741 q[325] = -2963;
2742 r[325] = -2827;
2743 q[326] = -2645;
2744 r[326] = -3126;
2745 q[327] = 2619;
2746 r[327] = -3148;
2747 q[328] = 1855;
2748 r[328] = -3651;
2749 q[329] = -3726;
2750 r[329] = 1699;
2751 q[330] = -3437;
2752 r[330] = 2227;
2753 q[331] = 2948;
2754 r[331] = 2842;
2755 q[332] = -2125;
2756 r[332] = 3501;
2757 q[333] = -1700;
2758 r[333] = 3726;
2759 q[334] = 4094;
2760 r[334] = -101;
2761 q[335] = 2084;
2762 r[335] = -3525;
2763 q[336] = 3225;
2764 r[336] = -2524;
2765 q[337] = 2220;
2766 r[337] = 3442;
2767 q[338] = 3174;
2768 r[338] = 2588;
2769 q[339] = 229;
2770 r[339] = -4089;
2771 q[340] = -2381;
2772 r[340] = -3332;
2773 q[341] = -3677;
2774 r[341] = -1803;
2775 q[342] = -3191;
2776 r[342] = -2567;
2777 q[343] = 2465;
2778 r[343] = 3270;
2779 q[344] = 2681;
2780 r[344] = -3096;
2781 q[345] = 975;
2782 r[345] = -3978;
2783 q[346] = 2004;
2784 r[346] = -3572;
2785 q[347] = -3442;
2786 r[347] = -2219;
2787 q[348] = 3676;
2788 r[348] = -1805;
2789 q[349] = -3753;
2790 r[349] = 1638;
2791 q[350] = 3544;
2792 r[350] = 2053;
2793 q[351] = 397;
2794 r[351] = -4076;
2795 q[352] = 2221;
2796 r[352] = 3440;
2797 q[353] = -302;
2798 r[353] = 4084;
2799 q[354] = 4083;
2800 r[354] = -323;
2801 q[355] = -2253;
2802 r[355] = -3420;
2803 q[356] = -3038;
2804 r[356] = 2746;
2805 q[357] = 2884;
2806 r[357] = 2908;
2807 q[358] = 4070;
2808 r[358] = 454;
2809 q[359] = -1072;
2810 r[359] = -3953;
2811 q[360] = 3831;
2812 r[360] = 1449;
2813 q[361] = 3663;
2814 r[361] = -1831;
2815 q[362] = -1971;
2816 r[362] = 3590;
2817 q[363] = 3226;
2818 r[363] = -2522;
2819 q[364] = -145;
2820 r[364] = -4093;
2821 q[365] = 1882;
2822 r[365] = -3637;
2823 q[366] = 529;
2824 r[366] = 4061;
2825 q[367] = 2637;
2826 r[367] = 3133;
2827 q[368] = -4077;
2828 r[368] = 389;
2829 q[369] = 2156;
2830 r[369] = -3482;
2831 q[370] = -3276;
2832 r[370] = 2458;
2833 q[371] = -2687;
2834 r[371] = -3090;
2835 q[372] = 3469;
2836 r[372] = -2177;
2837 q[373] = -4093;
2838 r[373] = -139;
2839 q[374] = -850;
2840 r[374] = 4006;
2841 q[375] = -625;
2842 r[375] = 4048;
2843 q[376] = 1110;
2844 r[376] = -3942;
2845 q[377] = -3078;
2846 r[377] = -2702;
2847 q[378] = -2719;
2848 r[378] = 3063;
2849 q[379] = 742;
2850 r[379] = 4028;
2851 q[380] = -3902;
2852 r[380] = -1245;
2853 q[381] = 3888;
2854 r[381] = -1287;
2855 q[382] = -4081;
2856 r[382] = 347;
2857 q[383] = 1070;
2858 r[383] = 3953;
2859 q[384] = -996;
2860 r[384] = -3972;
2861 q[385] = 4041;
2862 r[385] = -668;
2863 q[386] = -2712;
2864 r[386] = 3069;
2865 q[387] = -3403;
2866 r[387] = -2279;
2867 q[388] = -3320;
2868 r[388] = -2398;
2869 q[389] = 3036;
2870 r[389] = -2749;
2871 q[390] = 1308;
2872 r[390] = -3881;
2873 q[391] = 2256;
2874 r[391] = 3418;
2875 q[392] = -1486;
2876 r[392] = 3816;
2877 q[393] = -2771;
2878 r[393] = -3015;
2879 q[394] = -3883;
2880 r[394] = -1302;
2881 q[395] = -3867;
2882 r[395] = -1349;
2883 q[396] = 3952;
2884 r[396] = -1075;
2885 q[397] = -789;
2886 r[397] = 4019;
2887 q[398] = 1458;
2888 r[398] = 3827;
2889 q[399] = 3832;
2890 r[399] = -1446;
2891 q[400] = -3001;
2892 r[400] = -2787;
2893 q[401] = 3463;
2894 r[401] = 2186;
2895 q[402] = 3606;
2896 r[402] = 1942;
2897 q[403] = 4023;
2898 r[403] = 764;
2899 q[404] = 3387;
2900 r[404] = 2303;
2901 q[405] = 2648;
2902 r[405] = -3124;
2903 q[406] = 1370;
2904 r[406] = -3860;
2905 q[407] = -3134;
2906 r[407] = 2636;
2907 q[408] = 4051;
2908 r[408] = -600;
2909 q[409] = -1977;
2910 r[409] = -3587;
2911 q[410] = 3160;
2912 r[410] = 2605;
2913 q[411] = 4042;
2914 r[411] = 659;
2915 q[412] = 3004;
2916 r[412] = 2783;
2917 q[413] = 3370;
2918 r[413] = 2327;
2919 q[414] = -419;
2920 r[414] = -4074;
2921 q[415] = -1968;
2922 r[415] = 3591;
2923 q[416] = -3705;
2924 r[416] = -1746;
2925 q[417] = -3331;
2926 r[417] = -2383;
2927 q[418] = -3634;
2928 r[418] = 1888;
2929 q[419] = -1981;
2930 r[419] = -3584;
2931 q[420] = 4069;
2932 r[420] = -469;
2933 q[421] = -628;
2934 r[421] = -4047;
2935 q[422] = -1900;
2936 r[422] = 3628;
2937 q[423] = 1039;
2938 r[423] = -3961;
2939 q[424] = 2554;
2940 r[424] = -3201;
2941 q[425] = -2955;
2942 r[425] = 2836;
2943 q[426] = 2286;
2944 r[426] = -3398;
2945 q[427] = -1624;
2946 r[427] = 3760;
2947 q[428] = 2213;
2948 r[428] = 3446;
2949 q[429] = -3989;
2950 r[429] = -926;
2951 q[430] = 192;
2952 r[430] = -4091;
2953 q[431] = -723;
2954 r[431] = 4031;
2955 q[432] = 2878;
2956 r[432] = 2913;
2957 q[433] = -2109;
2958 r[433] = 3511;
2959 q[434] = 1463;
2960 r[434] = -3825;
2961 q[435] = -741;
2962 r[435] = -4028;
2963 q[436] = -1314;
2964 r[436] = -3879;
2965 q[437] = 3115;
2966 r[437] = 2659;
2967 q[438] = -3160;
2968 r[438] = -2605;
2969 q[439] = 1868;
2970 r[439] = 3644;
2971 q[440] = -824;
2972 r[440] = 4012;
2973 q[441] = 781;
2974 r[441] = 4020;
2975 q[442] = -1257;
2976 r[442] = -3898;
2977 q[443] = 3331;
2978 r[443] = -2382;
2979 q[444] = 1642;
2980 r[444] = -3752;
2981 q[445] = 3748;
2982 r[445] = -1650;
2983 q[446] = -487;
2984 r[446] = -4066;
2985 q[447] = 3085;
2986 r[447] = -2694;
2987 q[448] = 4009;
2988 r[448] = 839;
2989 q[449] = -2308;
2990 r[449] = -3383;
2991 q[450] = 3850;
2992 r[450] = 1397;
2993 q[451] = -4078;
2994 r[451] = -374;
2995 q[452] = 2989;
2996 r[452] = -2799;
2997 q[453] = 3023;
2998 r[453] = -2762;
2999 q[454] = 1397;
3000 r[454] = -3850;
3001 q[455] = 323;
3002 r[455] = 4083;
3003 q[456] = 268;
3004 r[456] = -4087;
3005 q[457] = 2414;
3006 r[457] = 3308;
3007 q[458] = 3876;
3008 r[458] = 1322;
3009 q[459] = -3584;
3010 r[459] = 1982;
3011 q[460] = 1603;
3012 r[460] = 3769;
3013 q[461] = -1502;
3014 r[461] = 3810;
3015 q[462] = 1318;
3016 r[462] = 3878;
3017 q[463] = 1554;
3018 r[463] = -3789;
3019 q[464] = 2492;
3020 r[464] = 3250;
3021 q[465] = -4093;
3022 r[465] = -154;
3023 q[466] = 4008;
3024 r[466] = 842;
3025 q[467] = -2279;
3026 r[467] = 3403;
3027 q[468] = 3013;
3028 r[468] = 2774;
3029 q[469] = 2557;
3030 r[469] = 3199;
3031 q[470] = 4068;
3032 r[470] = 475;
3033 q[471] = 3324;
3034 r[471] = -2392;
3035 q[472] = 2653;
3036 r[472] = -3120;
3037 q[473] = 796;
3038 r[473] = 4017;
3039 q[474] = -1312;
3040 r[474] = 3880;
3041 q[475] = 1794;
3042 r[475] = 3681;
3043 q[476] = -2347;
3044 r[476] = -3356;
3045 q[477] = -4008;
3046 r[477] = -840;
3047 q[478] = -3773;
3048 r[478] = -1592;
3049 q[479] = 1609;
3050 r[479] = 3766;
3051 q[480] = -1564;
3052 r[480] = -3785;
3053 q[481] = 3004;
3054 r[481] = 2784;
3055 q[482] = 1258;
3056 r[482] = 3897;
3057 q[483] = 3729;
3058 r[483] = 1693;
3059 q[484] = -4095;
3060 r[484] = -28;
3061 q[485] = -4093;
3062 r[485] = -146;
3063 q[486] = 1393;
3064 r[486] = -3851;
3065 q[487] = 297;
3066 r[487] = -4085;
3067 q[488] = 2294;
3068 r[488] = 3393;
3069 q[489] = -2562;
3070 r[489] = 3195;
3071 q[490] = -1716;
3072 r[490] = -3718;
3073 q[491] = 2224;
3074 r[491] = -3439;
3075 q[492] = 2032;
3076 r[492] = 3555;
3077 q[493] = -2968;
3078 r[493] = 2822;
3079 q[494] = 2338;
3080 r[494] = 3363;
3081 q[495] = 1584;
3082 r[495] = -3776;
3083 q[496] = -3072;
3084 r[496] = 2708;
3085 q[497] = -1596;
3086 r[497] = -3771;
3087 q[498] = -2256;
3088 r[498] = -3418;
3089 q[499] = 4095;
3090 r[499] = 89;
3091 q[500] = -1949;
3092 r[500] = 3602;
3093 q[501] = 1844;
3094 r[501] = 3657;
3095 q[502] = -3375;
3096 r[502] = 2319;
3097 q[503] = -1481;
3098 r[503] = -3818;
3099 q[504] = 3228;
3100 r[504] = -2520;
3101 q[505] = 1116;
3102 r[505] = 3940;
3103 q[506] = -2783;
3104 r[506] = 3004;
3105 q[507] = 3915;
3106 r[507] = 1201;
3107 q[508] = 283;
3108 r[508] = 4086;
3109 q[509] = -3732;
3110 r[509] = 1685;
3111 q[510] = -433;
3112 r[510] = -4072;
3113 q[511] = -3667;
3114 r[511] = 1823;
3115 q[512] = 3883;
3116 r[512] = 1300;
3117 q[513] = -3742;
3118 r[513] = 1663;
3119 q[514] = 4093;
3120 r[514] = -143;
3121 q[515] = 3874;
3122 r[515] = 1328;
3123 q[516] = -3800;
3124 r[516] = 1528;
3125 q[517] = -1257;
3126 r[517] = 3898;
3127 q[518] = -1606;
3128 r[518] = 3767;
3129 q[519] = 3394;
3130 r[519] = 2291;
3131 q[520] = 2255;
3132 r[520] = 3419;
3133 q[521] = -4094;
3134 r[521] = 120;
3135 q[522] = -3767;
3136 r[522] = 1606;
3137 q[523] = 1849;
3138 r[523] = -3654;
3139 q[524] = -2883;
3140 r[524] = 2908;
3141 q[525] = 3469;
3142 r[525] = 2176;
3143 q[526] = 2654;
3144 r[526] = 3119;
3145 q[527] = -239;
3146 r[527] = 4088;
3147 q[528] = -651;
3148 r[528] = 4043;
3149 q[529] = -1140;
3150 r[529] = 3934;
3151 q[530] = 328;
3152 r[530] = -4082;
3153 q[531] = 3246;
3154 r[531] = 2497;
3155 q[532] = 4026;
3156 r[532] = -753;
3157 q[533] = -2041;
3158 r[533] = -3550;
3159 q[534] = -1154;
3160 r[534] = 3929;
3161 q[535] = -2710;
3162 r[535] = 3070;
3163 q[536] = -2860;
3164 r[536] = 2932;
3165 q[537] = 2097;
3166 r[537] = 3517;
3167 q[538] = 3492;
3168 r[538] = -2140;
3169 q[539] = 3123;
3170 r[539] = 2649;
3171 q[540] = 3360;
3172 r[540] = 2342;
3173 q[541] = 2498;
3174 r[541] = 3245;
3175 q[542] = 3976;
3176 r[542] = 982;
3177 q[543] = -2441;
3178 r[543] = -3288;
3179 q[544] = 3601;
3180 r[544] = 1951;
3181 q[545] = -4008;
3182 r[545] = -842;
3183 q[546] = 1243;
3184 r[546] = 3902;
3185 q[547] = 4069;
3186 r[547] = 466;
3187 q[548] = -2031;
3188 r[548] = 3556;
3189 q[549] = 4077;
3190 r[549] = 386;
3191 q[550] = -3112;
3192 r[550] = -2663;
3193 q[551] = 4087;
3194 r[551] = -262;
3195 q[552] = 4087;
3196 r[552] = 266;
3197 q[553] = -3907;
3198 r[553] = -1228;
3199 q[554] = -1611;
3200 r[554] = 3765;
3201 q[555] = 3066;
3202 r[555] = -2715;
3203 q[556] = 2657;
3204 r[556] = 3117;
3205 q[557] = 3912;
3206 r[557] = -1213;
3207 q[558] = -2531;
3208 r[558] = -3220;
3209 q[559] = 3500;
3210 r[559] = -2127;
3211 q[560] = -76;
3212 r[560] = -4095;
3213 q[561] = 3413;
3214 r[561] = -2264;
3215 q[562] = -4071;
3216 r[562] = -448;
3217 q[563] = 828;
3218 r[563] = 4011;
3219 q[564] = 3664;
3220 r[564] = 1830;
3221 q[565] = -1578;
3222 r[565] = 3779;
3223 q[566] = 3555;
3224 r[566] = 2033;
3225 q[567] = 3868;
3226 r[567] = -1345;
3227 q[568] = 4054;
3228 r[568] = -580;
3229 q[569] = -4094;
3230 r[569] = 124;
3231 q[570] = -3820;
3232 r[570] = -1477;
3233 q[571] = -3658;
3234 r[571] = -1842;
3235 q[572] = 2595;
3236 r[572] = 3168;
3237 q[573] = 3354;
3238 r[573] = 2350;
3239 q[574] = -701;
3240 r[574] = -4035;
3241 q[575] = -772;
3242 r[575] = -4022;
3243 q[576] = 2799;
3244 r[576] = 2990;
3245 q[577] = -3632;
3246 r[577] = 1893;
3247 q[578] = 310;
3248 r[578] = 4084;
3249 q[579] = 3984;
3250 r[579] = -947;
3251 q[580] = 3794;
3252 r[580] = -1542;
3253 q[581] = -2419;
3254 r[581] = 3304;
3255 q[582] = -3916;
3256 r[582] = 1200;
3257 q[583] = -3886;
3258 r[583] = 1292;
3259 q[584] = -3299;
3260 r[584] = 2426;
3261 q[585] = -437;
3262 r[585] = 4072;
3263 q[586] = 2053;
3264 r[586] = -3544;
3265 q[587] = 3987;
3266 r[587] = 937;
3267 q[588] = -789;
3268 r[588] = -4019;
3269 q[589] = 4055;
3270 r[589] = -575;
3271 q[590] = -3894;
3272 r[590] = 1270;
3273 q[591] = 4003;
3274 r[591] = -864;
3275 q[592] = -3060;
3276 r[592] = 2721;
3277 q[593] = -4009;
3278 r[593] = 836;
3279 q[594] = -1655;
3280 r[594] = -3746;
3281 q[595] = 3954;
3282 r[595] = -1067;
3283 q[596] = -773;
3284 r[596] = 4022;
3285 q[597] = -422;
3286 r[597] = 4074;
3287 q[598] = -3384;
3288 r[598] = 2306;
3289 q[599] = 195;
3290 r[599] = -4091;
3291 q[600] = -298;
3292 r[600] = 4085;
3293 q[601] = -3988;
3294 r[601] = 931;
3295 q[602] = 2014;
3296 r[602] = -3566;
3297 q[603] = 3349;
3298 r[603] = -2357;
3299 q[604] = 3800;
3300 r[604] = 1526;
3301 q[605] = 3858;
3302 r[605] = 1374;
3303 q[606] = 2947;
3304 r[606] = 2844;
3305 q[607] = -1483;
3306 r[607] = -3818;
3307 q[608] = 4056;
3308 r[608] = -565;
3309 q[609] = 2612;
3310 r[609] = -3154;
3311 q[610] = 2326;
3312 r[610] = 3371;
3313 q[611] = -3545;
3314 r[611] = 2051;
3315 q[612] = -1001;
3316 r[612] = -3971;
3317 q[613] = 3211;
3318 r[613] = 2541;
3319 q[614] = -2717;
3320 r[614] = 3065;
3321 q[615] = -3159;
3322 r[615] = -2606;
3323 q[616] = 2869;
3324 r[616] = -2922;
3325 q[617] = -1290;
3326 r[617] = -3887;
3327 q[618] = 2479;
3328 r[618] = 3260;
3329 q[619] = 3420;
3330 r[619] = 2252;
3331 q[620] = 1823;
3332 r[620] = 3667;
3333 q[621] = 3368;
3334 r[621] = 2330;
3335 q[622] = -3819;
3336 r[622] = -1480;
3337 q[623] = 3800;
3338 r[623] = 1528;
3339 q[624] = 3773;
3340 r[624] = 1594;
3341 q[625] = -189;
3342 r[625] = -4091;
3343 q[626] = -4067;
3344 r[626] = -485;
3345 q[627] = 2277;
3346 r[627] = -3404;
3347 q[628] = -4089;
3348 r[628] = -233;
3349 q[629] = -3634;
3350 r[629] = 1889;
3351 q[630] = 3292;
3352 r[630] = 2437;
3353 q[631] = -530;
3354 r[631] = 4061;
3355 q[632] = -3109;
3356 r[632] = 2666;
3357 q[633] = -3741;
3358 r[633] = 1667;
3359 q[634] = -1903;
3360 r[634] = -3626;
3361 q[635] = 3879;
3362 r[635] = -1315;
3363 q[636] = 4083;
3364 r[636] = -315;
3365 q[637] = -1148;
3366 r[637] = 3931;
3367 q[638] = 2630;
3368 r[638] = 3139;
3369 q[639] = -4001;
3370 r[639] = 876;
3371 q[640] = -2295;
3372 r[640] = -3392;
3373 q[641] = 1090;
3374 r[641] = -3948;
3375 q[642] = -3024;
3376 r[642] = 2762;
3377 q[643] = 2728;
3378 r[643] = -3054;
3379 q[644] = -3305;
3380 r[644] = 2419;
3381 q[645] = 60;
3382 r[645] = 4095;
3383 q[646] = 4048;
3384 r[646] = -620;
3385 q[647] = 589;
3386 r[647] = -4053;
3387 q[648] = -3867;
3388 r[648] = 1347;
3389 q[649] = -2944;
3390 r[649] = -2847;
3391 q[650] = -2721;
3392 r[650] = 3060;
3393 q[651] = 2928;
3394 r[651] = 2863;
3395 q[652] = 801;
3396 r[652] = 4016;
3397 q[653] = -3644;
3398 r[653] = 1870;
3399 q[654] = -1648;
3400 r[654] = -3749;
3401 q[655] = 825;
3402 r[655] = -4012;
3403 q[656] = -2036;
3404 r[656] = -3553;
3405 q[657] = -1192;
3406 r[657] = -3918;
3407 q[658] = 2875;
3408 r[658] = 2916;
3409 q[659] = -1831;
3410 r[659] = -3663;
3411 q[660] = -2865;
3412 r[660] = -2926;
3413 q[661] = -575;
3414 r[661] = -4055;
3415 q[662] = -3870;
3416 r[662] = 1340;
3417 q[663] = -4080;
3418 r[663] = -356;
3419 q[664] = -2176;
3420 r[664] = -3469;
3421 q[665] = -2986;
3422 r[665] = -2803;
3423 q[666] = 3978;
3424 r[666] = -972;
3425 q[667] = 2437;
3426 r[667] = 3291;
3427 q[668] = -3528;
3428 r[668] = 2080;
3429 q[669] = -3300;
3430 r[669] = -2425;
3431 q[670] = 3085;
3432 r[670] = 2693;
3433 q[671] = -3700;
3434 r[671] = -1756;
3435 q[672] = 3216;
3436 r[672] = -2535;
3437 q[673] = 4094;
3438 r[673] = -91;
3439 q[674] = 3775;
3440 r[674] = -1589;
3441 q[675] = 1097;
3442 r[675] = -3946;
3443 q[676] = -152;
3444 r[676] = -4093;
3445 q[677] = -3490;
3446 r[677] = 2142;
3447 q[678] = 3747;
3448 r[678] = 1654;
3449 q[679] = -1490;
3450 r[679] = -3815;
3451 q[680] = -3998;
3452 r[680] = -886;
3453 q[681] = 3726;
3454 r[681] = -1700;
3455 q[682] = -1600;
3456 r[682] = 3770;
3457 q[683] = -87;
3458 r[683] = 4095;
3459 q[684] = 2538;
3460 r[684] = -3214;
3461 q[685] = -4095;
3462 r[685] = 52;
3463 q[686] = -3993;
3464 r[686] = -910;
3465 q[687] = 4051;
3466 r[687] = 603;
3467 q[688] = -1242;
3468 r[688] = -3902;
3469 q[689] = 2155;
3470 r[689] = 3482;
3471 q[690] = 1270;
3472 r[690] = 3893;
3473 q[691] = 1919;
3474 r[691] = -3618;
3475 q[692] = -3145;
3476 r[692] = 2623;
3477 q[693] = 2475;
3478 r[693] = 3263;
3479 q[694] = 2226;
3480 r[694] = -3437;
3481 q[695] = -3894;
3482 r[695] = -1269;
3483 q[696] = -429;
3484 r[696] = 4073;
3485 q[697] = -1346;
3486 r[697] = 3868;
3487 q[698] = 1297;
3488 r[698] = 3885;
3489 q[699] = 1699;
3490 r[699] = 3726;
3491 q[700] = -3375;
3492 r[700] = 2319;
3493 q[701] = 1577;
3494 r[701] = -3779;
3495 q[702] = -63;
3496 r[702] = 4095;
3497 q[703] = 1215;
3498 r[703] = -3911;
3499 q[704] = -1492;
3500 r[704] = 3814;
3501 q[705] = -1530;
3502 r[705] = -3799;
3503 q[706] = 3442;
3504 r[706] = 2218;
3505 q[707] = -3867;
3506 r[707] = -1349;
3507 q[708] = -3291;
3508 r[708] = -2437;
3509 q[709] = -2253;
3510 r[709] = -3420;
3511 q[710] = -150;
3512 r[710] = -4093;
3513 q[711] = -2686;
3514 r[711] = -3092;
3515 q[712] = 3470;
3516 r[712] = 2175;
3517 q[713] = -3826;
3518 r[713] = -1461;
3519 q[714] = -3148;
3520 r[714] = 2619;
3521 q[715] = -3858;
3522 r[715] = 1375;
3523 q[716] = -3844;
3524 r[716] = -1412;
3525 q[717] = -3652;
3526 r[717] = 1854;
3527 q[718] = 4018;
3528 r[718] = -791;
3529 q[719] = 179;
3530 r[719] = -4092;
3531 q[720] = 3498;
3532 r[720] = 2129;
3533 q[721] = -1999;
3534 r[721] = -3574;
3535 q[722] = 3531;
3536 r[722] = 2075;
3537 q[723] = 4050;
3538 r[723] = -606;
3539 q[724] = -1639;
3540 r[724] = 3753;
3541 q[725] = -3661;
3542 r[725] = 1835;
3543 q[726] = 4039;
3544 r[726] = 679;
3545 q[727] = 3561;
3546 r[727] = 2023;
3547 q[728] = 528;
3548 r[728] = 4061;
3549 q[729] = -634;
3550 r[729] = -4046;
3551 q[730] = 364;
3552 r[730] = -4079;
3553 q[731] = 2735;
3554 r[731] = 3048;
3555 q[732] = 3978;
3556 r[732] = 973;
3557 q[733] = -4073;
3558 r[733] = -427;
3559 q[734] = -3722;
3560 r[734] = 1708;
3561 q[735] = 2356;
3562 r[735] = -3350;
3563 q[736] = -1125;
3564 r[736] = -3938;
3565 q[737] = 4054;
3566 r[737] = 580;
3567 q[738] = 3328;
3568 r[738] = -2387;
3569 q[739] = 1439;
3570 r[739] = -3834;
3571 q[740] = 1746;
3572 r[740] = 3705;
3573 q[741] = 2507;
3574 r[741] = 3238;
3575 q[742] = 3839;
3576 r[742] = -1427;
3577 q[743] = 488;
3578 r[743] = -4066;
3579 q[744] = 1187;
3580 r[744] = 3920;
3581 q[745] = 2038;
3582 r[745] = -3552;
3583 q[746] = -905;
3584 r[746] = -3994;
3585 q[747] = -236;
3586 r[747] = 4089;
3587 q[748] = 208;
3588 r[748] = -4090;
3589 q[749] = 1660;
3590 r[749] = 3744;
3591 q[750] = -4074;
3592 r[750] = -415;
3593 q[751] = -2304;
3594 r[751] = 3385;
3595 q[752] = -2457;
3596 r[752] = 3276;
3597 q[753] = 3302;
3598 r[753] = 2423;
3599 q[754] = 1778;
3600 r[754] = -3689;
3601 q[755] = 2019;
3602 r[755] = 3563;
3603 q[756] = 4037;
3604 r[756] = 687;
3605 q[757] = -2365;
3606 r[757] = 3343;
3607 q[758] = 5;
3608 r[758] = -4095;
3609 q[759] = 160;
3610 r[759] = -4092;
3611
3612 } /*initRand*/
3613
3614 /**
3615 * initializes the MEL-2_LINEAR LOOKUP TABLE
3616 * @param sig_inObj : sig PU internal object of the sub-object
3617 * @return void
3618 * @remarks translated from matlab code to c-code
3619 * @callgraph
3620 * @callergraph
3621 *
3622 * input
3623 * - bilinTab : base address of bilinTable destination vector
3624 * - alpha : warping factor
3625 * - size : size of the vectors to be generated
3626 * - A,B : base address of array of indexes for lookup table implementation
3627 * - D : base address of delta array for lookup table implementation
3628 *
3629 * output
3630 * - bilinTab, A, B, D : initialized vectors
3631 */
mel_2_lin_init(sig_innerobj_t * sig_inObj)3632 void mel_2_lin_init(sig_innerobj_t *sig_inObj)
3633 {
3634
3635 /*Declare variables tied to I/O PARAMS formerly passed by value or reference*/
3636 picoos_single alpha;
3637 picoos_int32 *D;
3638 picoos_int32 size;
3639 picoos_int16 *A;
3640
3641 /*Link local variables with sig data object*/
3642
3643 alpha = sig_inObj->warp_p;
3644 size = (sig_inObj->hfftsize_p) + 1;
3645 A = sig_inObj->A_p;
3646 D = sig_inObj->d_p;
3647 /*
3648 fixed point interpolation tables
3649 scaling factor: 0x20
3650 corresponding bit shift: 5
3651 */
3652
3653 A[0] = 0;
3654 D[0] = 0;
3655 A[1] = 2;
3656 D[1] = 14;
3657 A[2] = 4;
3658 D[2] = 29;
3659 A[3] = 7;
3660 D[3] = 11;
3661 A[4] = 9;
3662 D[4] = 24;
3663 A[5] = 12;
3664 D[5] = 5;
3665 A[6] = 14;
3666 D[6] = 18;
3667 A[7] = 16;
3668 D[7] = 30;
3669 A[8] = 19;
3670 D[8] = 9;
3671 A[9] = 21;
3672 D[9] = 19;
3673 A[10] = 23;
3674 D[10] = 29;
3675 A[11] = 26;
3676 D[11] = 5;
3677 A[12] = 28;
3678 D[12] = 12;
3679 A[13] = 30;
3680 D[13] = 19;
3681 A[14] = 32;
3682 D[14] = 24;
3683 A[15] = 34;
3684 D[15] = 27;
3685 A[16] = 36;
3686 D[16] = 30;
3687 A[17] = 38;
3688 D[17] = 31;
3689 A[18] = 40;
3690 D[18] = 31;
3691 A[19] = 42;
3692 D[19] = 29;
3693 A[20] = 44;
3694 D[20] = 26;
3695 A[21] = 46;
3696 D[21] = 22;
3697 A[22] = 48;
3698 D[22] = 17;
3699 A[23] = 50;
3700 D[23] = 10;
3701 A[24] = 52;
3702 D[24] = 2;
3703 A[25] = 53;
3704 D[25] = 24;
3705 A[26] = 55;
3706 D[26] = 13;
3707 A[27] = 57;
3708 D[27] = 1;
3709 A[28] = 58;
3710 D[28] = 20;
3711 A[29] = 60;
3712 D[29] = 5;
3713 A[30] = 61;
3714 D[30] = 21;
3715 A[31] = 63;
3716 D[31] = 4;
3717 A[32] = 64;
3718 D[32] = 18;
3719 A[33] = 65;
3720 D[33] = 31;
3721 A[34] = 67;
3722 D[34] = 11;
3723 A[35] = 68;
3724 D[35] = 21;
3725 A[36] = 69;
3726 D[36] = 31;
3727 A[37] = 71;
3728 D[37] = 7;
3729 A[38] = 72;
3730 D[38] = 14;
3731 A[39] = 73;
3732 D[39] = 21;
3733 A[40] = 74;
3734 D[40] = 27;
3735 A[41] = 75;
3736 D[41] = 31;
3737 A[42] = 77;
3738 D[42] = 3;
3739 A[43] = 78;
3740 D[43] = 6;
3741 A[44] = 79;
3742 D[44] = 8;
3743 A[45] = 80;
3744 D[45] = 10;
3745 A[46] = 81;
3746 D[46] = 10;
3747 A[47] = 82;
3748 D[47] = 10;
3749 A[48] = 83;
3750 D[48] = 9;
3751 A[49] = 84;
3752 D[49] = 8;
3753 A[50] = 85;
3754 D[50] = 6;
3755 A[51] = 86;
3756 D[51] = 3;
3757 A[52] = 86;
3758 D[52] = 31;
3759 A[53] = 87;
3760 D[53] = 27;
3761 A[54] = 88;
3762 D[54] = 23;
3763 A[55] = 89;
3764 D[55] = 18;
3765 A[56] = 90;
3766 D[56] = 12;
3767 A[57] = 91;
3768 D[57] = 6;
3769 A[58] = 91;
3770 D[58] = 31;
3771 A[59] = 92;
3772 D[59] = 24;
3773 A[60] = 93;
3774 D[60] = 16;
3775 A[61] = 94;
3776 D[61] = 8;
3777 A[62] = 94;
3778 D[62] = 31;
3779 A[63] = 95;
3780 D[63] = 22;
3781 A[64] = 96;
3782 D[64] = 13;
3783 A[65] = 97;
3784 D[65] = 3;
3785 A[66] = 97;
3786 D[66] = 25;
3787 A[67] = 98;
3788 D[67] = 14;
3789 A[68] = 99;
3790 D[68] = 3;
3791 A[69] = 99;
3792 D[69] = 24;
3793 A[70] = 100;
3794 D[70] = 13;
3795 A[71] = 101;
3796 D[71] = 1;
3797 A[72] = 101;
3798 D[72] = 21;
3799 A[73] = 102;
3800 D[73] = 8;
3801 A[74] = 102;
3802 D[74] = 27;
3803 A[75] = 103;
3804 D[75] = 14;
3805 A[76] = 104;
3806 D[76] = 1;
3807 A[77] = 104;
3808 D[77] = 19;
3809 A[78] = 105;
3810 D[78] = 6;
3811 A[79] = 105;
3812 D[79] = 24;
3813 A[80] = 106;
3814 D[80] = 9;
3815 A[81] = 106;
3816 D[81] = 27;
3817 A[82] = 107;
3818 D[82] = 12;
3819 A[83] = 107;
3820 D[83] = 29;
3821 A[84] = 108;
3822 D[84] = 14;
3823 A[85] = 108;
3824 D[85] = 31;
3825 A[86] = 109;
3826 D[86] = 15;
3827 A[87] = 109;
3828 D[87] = 31;
3829 A[88] = 110;
3830 D[88] = 16;
3831 A[89] = 110;
3832 D[89] = 31;
3833 A[90] = 111;
3834 D[90] = 15;
3835 A[91] = 111;
3836 D[91] = 31;
3837 A[92] = 112;
3838 D[92] = 14;
3839 A[93] = 112;
3840 D[93] = 30;
3841 A[94] = 113;
3842 D[94] = 13;
3843 A[95] = 113;
3844 D[95] = 28;
3845 A[96] = 114;
3846 D[96] = 11;
3847 A[97] = 114;
3848 D[97] = 26;
3849 A[98] = 115;
3850 D[98] = 9;
3851 A[99] = 115;
3852 D[99] = 23;
3853 A[100] = 116;
3854 D[100] = 6;
3855 A[101] = 116;
3856 D[101] = 20;
3857 A[102] = 117;
3858 D[102] = 2;
3859 A[103] = 117;
3860 D[103] = 16;
3861 A[104] = 117;
3862 D[104] = 31;
3863 A[105] = 118;
3864 D[105] = 13;
3865 A[106] = 118;
3866 D[106] = 27;
3867 A[107] = 119;
3868 D[107] = 8;
3869 A[108] = 119;
3870 D[108] = 22;
3871 A[109] = 120;
3872 D[109] = 4;
3873 A[110] = 120;
3874 D[110] = 17;
3875 A[111] = 120;
3876 D[111] = 31;
3877 A[112] = 121;
3878 D[112] = 13;
3879 A[113] = 121;
3880 D[113] = 26;
3881 A[114] = 122;
3882 D[114] = 8;
3883 A[115] = 122;
3884 D[115] = 21;
3885 A[116] = 123;
3886 D[116] = 2;
3887 A[117] = 123;
3888 D[117] = 15;
3889 A[118] = 123;
3890 D[118] = 29;
3891 A[119] = 124;
3892 D[119] = 10;
3893 A[120] = 124;
3894 D[120] = 23;
3895 A[121] = 125;
3896 D[121] = 4;
3897 A[122] = 125;
3898 D[122] = 17;
3899 A[123] = 125;
3900 D[123] = 31;
3901 A[124] = 126;
3902 D[124] = 12;
3903 A[125] = 126;
3904 D[125] = 25;
3905 A[126] = 127;
3906 D[126] = 6;
3907 A[127] = 127;
3908 D[127] = 19;
3909 A[128] = 128;
3910 D[128] = 0;
3911
3912 }/*mel_2_lin_init*/
3913
3914 /**
3915 * function to be documented
3916 * @param ang : ??
3917 * @param table : ??
3918 * @param cs : ??
3919 * @param sn : ??
3920 * @return void
3921 * @callgraph
3922 * @callergraph
3923 */
get_trig(picoos_int32 ang,picoos_int32 * table,picoos_int32 * cs,picoos_int32 * sn)3924 static void get_trig(picoos_int32 ang, picoos_int32 *table, picoos_int32 *cs,
3925 picoos_int32 *sn)
3926 {
3927 picoos_int32 i, j, k;
3928
3929 i = k = ang >> PICODSP_PI_SHIFT; /* * PICODSP_COS_TABLE_LEN2/PICODSP_FIX_SCALE2 */
3930 if (i < 0)
3931 i = -i;
3932 j = 1;
3933 i &= (PICODSP_COS_TABLE_LEN4 - 1);
3934 if (i > PICODSP_COS_TABLE_LEN2)
3935 i = PICODSP_COS_TABLE_LEN4 - i;
3936 if (i > PICODSP_COS_TABLE_LEN) {
3937 j = -1;
3938 i = PICODSP_COS_TABLE_LEN2 - i;
3939 }
3940 if (j == 1)
3941 *cs = table[i];
3942 else
3943 *cs = -table[i];
3944
3945 i = k - PICODSP_COS_TABLE_LEN;
3946 if (i < 0)
3947 i = -i;
3948 j = 1;
3949 i &= (PICODSP_COS_TABLE_LEN4 - 1);
3950 if (i > PICODSP_COS_TABLE_LEN2)
3951 i = PICODSP_COS_TABLE_LEN4 - i;
3952 if (i > PICODSP_COS_TABLE_LEN) {
3953 j = -1;
3954 i = PICODSP_COS_TABLE_LEN2 - i;
3955 }
3956 if (j == 1)
3957 *sn = table[i];
3958 else
3959 *sn = -table[i];
3960 }/*get_trig*/
3961
3962 /**
3963 * function to be documented
3964 * @param sig_inObj : sig PU internal object of the sub-object
3965 * @return void
3966 * @callgraph
3967 * @callergraph
3968 */
save_transition_frame(sig_innerobj_t * sig_inObj)3969 void save_transition_frame(sig_innerobj_t *sig_inObj)
3970 {
3971 picoos_int32 *tmp, *tmp2; /*for loop unrolling*/
3972
3973 if (sig_inObj->voiced_p != sig_inObj->prevVoiced_p) {
3974 sig_inObj->VoicTrans = sig_inObj->prevVoiced_p; /*remember last voicing transition*/
3975 tmp = sig_inObj->ImpResp_p;
3976 tmp2 = sig_inObj->imp_p;
3977 FAST_DEVICE(PICODSP_FFTSIZE,*(tmp++)=*(tmp2++););
3978 if (sig_inObj->voiced_p == 1)
3979 sig_inObj->nV = 0;
3980 else
3981 sig_inObj->nU = 0; /*to avoid problems in case of very short voiced or unvoiced parts (less than 4 frames long)*/
3982 }
3983 }/*save_transition_frame*/
3984
3985 /**
3986 * calculates an unweighted excitation window
3987 * @param sig_inObj : sig PU internal object of the sub-object
3988 * @param nextPeak : position of next peak (excitation position)
3989 * @return PICO_OK
3990 * @callgraph
3991 * @callergraph
3992 * input
3993 * - hop : hop size in samples
3994 * - winlen : excitation window length
3995 * - E : energy
3996 * - F0 : pitch
3997 * - nextPeak : state that remembers next excitation index
3998 * - Fs - sampling frequency
3999 * output
4000 * - LocV, LocU : (MAX_EN size) location of excitation points
4001 * - EnV, EnU : (MAX_EN size) RMS values of excitation (scaled)
4002 * - nV, nU : (integers) number of excitation points
4003 * - nextPeak new position of lastPeak to calculate next frame
4004 */
get_simple_excitation(sig_innerobj_t * sig_inObj,picoos_int16 * nextPeak)4005 static void get_simple_excitation(sig_innerobj_t *sig_inObj,
4006 picoos_int16 *nextPeak)
4007 {
4008 /*Define local variables*/
4009 picoos_int16 nI, nJ, k;
4010 /* picoos_single InvSqrt3=(picoos_single)2/(picoos_single)sqrt(3.0); *//*constant*/
4011 picoos_int32 Ti, sqrtTi;
4012 picoos_int16 hop, winlen, Fs;
4013 picoos_single E, F0;
4014 picoos_int16 voiced;
4015 picoos_single fact; /*normalization factor*/
4016 picoos_single rounding = 0.5f;
4017
4018 /*Link local variables to sig object*/
4019 hop = sig_inObj->hop_p;
4020 winlen = sig_inObj->m2_p;
4021 Fs = sig_inObj->Fs_p;
4022 E = sig_inObj->E_p;
4023 F0 = sig_inObj->F0_p;
4024 voiced = sig_inObj->voiced_p;
4025
4026 E = (E > 5) ? 9 : (E > 1) ? 2 * E - 1 : E;
4027
4028
4029 /* shift previous excitation window by hop samples*/
4030 for (nI = 0; nI < sig_inObj->nV; nI++) {
4031 sig_inObj->LocV[nI] = sig_inObj->LocV[nI] - hop;
4032 }
4033 for (nI = 0; nI < sig_inObj->nU; nI++) {
4034 sig_inObj->LocU[nI] = sig_inObj->LocU[nI] - hop;
4035 }
4036
4037 /*get rid of the voiced points that fall out of the interval*/
4038 nI = 0;
4039 while ((sig_inObj->LocV[nI] < 0) && nI < sig_inObj->nV)
4040 nI++;
4041
4042 for (nJ = nI; nJ < sig_inObj->nV; nJ++) {
4043 sig_inObj->LocV[nJ - nI] = sig_inObj->LocV[nJ];
4044 sig_inObj->EnV[nJ - nI] = sig_inObj->EnV[nJ];
4045 }
4046 sig_inObj->nV -= nI;
4047 /*get rid of the unvoiced points that fall out of the interval */
4048 nI = 0;
4049 while ((sig_inObj->LocU[nI] < 0) && nI < sig_inObj->nU)
4050 nI++;
4051
4052 for (nJ = nI; nJ < sig_inObj->nU; nJ++) {
4053 sig_inObj->LocU[nJ - nI] = sig_inObj->LocU[nJ];
4054 sig_inObj->EnU[nJ - nI] = sig_inObj->EnU[nJ];
4055 }
4056 sig_inObj->nU -= nI;
4057
4058 *nextPeak -= hop;
4059 k = *nextPeak;
4060
4061 fact = 3;
4062 if (voiced == 0) { /*Unvoiced*/
4063
4064 Ti = (picoos_int32) (rounding + (picoos_single) Fs
4065 / (picoos_single) sig_inObj->Fuv_p); /* round Period*/
4066 sqrtTi = (picoos_int32) (E * sqrt((double) Fs
4067 / (hop * sig_inObj->Fuv_p)) * fact * PICODSP_GETEXC_K1);
4068 while (k < winlen) {
4069 if (k < winlen) {
4070 sig_inObj->LocU[sig_inObj->nU] = k;
4071 sig_inObj->EnU[sig_inObj->nU] = sqrtTi;
4072 sig_inObj->nU++;
4073 k += (picoos_int16) Ti;
4074 }
4075 }
4076 } else { /*Voiced*/
4077 Ti
4078 = (picoos_int32) (rounding + (picoos_single) Fs
4079 / (picoos_single) F0); /*Period*/
4080 sqrtTi = (picoos_int32) (E
4081 * sqrt((double) Fs / (hop * sig_inObj->F0_p)) * fact
4082 * PICODSP_GETEXC_K1);
4083 while (k < winlen) {
4084 sig_inObj->LocV[sig_inObj->nV] = k;
4085 sig_inObj->EnV[sig_inObj->nV] = sqrtTi;
4086 sig_inObj->nV++;
4087 k += (picoos_int16) Ti;
4088 }
4089 }
4090 *nextPeak = k;
4091
4092 }/*get_simple_excitation*/
4093
4094 #ifdef __cplusplus
4095 }
4096 #endif
4097
4098 /* end picosig2.c */
4099