blob: c25cbe4d5e8039eb0d1fe26ecb35fa335b5f91ff [file] [log] [blame]
/*
* Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file picosig2.c
*
* Signal Generation PU - Internal functions - Implementation
*
* Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
* All rights reserved.
*
* History:
* - 2009-04-20 -- initial version
*
*/
#include "picoos.h"
#include "picodsp.h"
#include "picosig2.h"
#include "picofftsg.h"
#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#endif
/*---------------------------------------------------------------------------
* INTERNAL FUNCTIONS DECLARATION
*---------------------------------------------------------------------------*/
static void gen_hann2(sig_innerobj_t *sig_inObj);
static void get_simple_excitation(sig_innerobj_t *sig_inObj,
picoos_int16 *nextPeak);
static void enh_wind_init(sig_innerobj_t *sig_inObj);
static void init_rand(sig_innerobj_t *sig_inObj);
static void get_trig(picoos_int32 ang, picoos_int32 *table, picoos_int32 *cs,
picoos_int32 *sn);
/*---------------------------------------------------------------------------
* PICO SYSTEM FUNCTIONS
*---------------------------------------------------------------------------*/
/**
* allocation of DSP memory for SIG PU
* @param mm : memory manager
* @param sig_inObj : sig PU internal object of the sub-object
* @return PICO_OK : allocation successful
* @return PICO_ERR_OTHER : allocation NOT successful
* @callgraph
* @callergraph
*/
pico_status_t sigAllocate(picoos_MemoryManager mm, sig_innerobj_t *sig_inObj)
{
picoos_int16 *data_i;
picoos_int32 *d32;
picoos_int32 nCount;
sig_inObj->int_vec22 =
sig_inObj->int_vec23 =
sig_inObj->int_vec24 =
sig_inObj->int_vec25 =
sig_inObj->int_vec26 =
sig_inObj->int_vec28 =
sig_inObj->int_vec29 =
sig_inObj->int_vec30 =
sig_inObj->int_vec31 =
sig_inObj->int_vec32 =
sig_inObj->int_vec33 =
sig_inObj->int_vec34 =
sig_inObj->int_vec35 =
sig_inObj->int_vec36 =
sig_inObj->int_vec37 =
sig_inObj->int_vec38 =
sig_inObj->int_vec39 =
sig_inObj->int_vec40 = NULL;
sig_inObj->sig_vec1 = NULL;
sig_inObj->idx_vect1 = sig_inObj->idx_vect2 = sig_inObj->idx_vect4 = NULL;
sig_inObj->idx_vect5 = sig_inObj->idx_vect6 = sig_inObj->idx_vect7 =
sig_inObj->idx_vect8 = sig_inObj->idx_vect9 = NULL;
sig_inObj->ivalue17 = sig_inObj->ivalue18 = 0;
/*-----------------------------------------------------------------
* Memory allocations
* NOTE : it would be far better to do a single allocation
* and to do pointer initialization inside this routine
* ------------------------------------------------------------------*/
data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
* PICODSP_FFTSIZE);
if (NULL == data_i) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->idx_vect1 = data_i;
data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
* PICODSP_HFFTSIZE_P1);
if (NULL == data_i) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->idx_vect2 = data_i;
data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
* PICODSP_FFTSIZE);
if (NULL == data_i) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->idx_vect4 = data_i;
data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
* PICODSP_FFTSIZE);
if (NULL == data_i) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->idx_vect5 = data_i;
data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
* PICODSP_FFTSIZE);
if (NULL == data_i) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->idx_vect6 = data_i;
data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
* PICODSP_HFFTSIZE_P1);
if (NULL == data_i) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->idx_vect7 = data_i;
data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
* PICODSP_MAX_EX);
if (NULL == data_i) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->idx_vect8 = data_i;
data_i = (picoos_int16 *) picoos_allocate(mm, sizeof(picoos_int16)
* PICODSP_MAX_EX);
if (data_i == NULL) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->idx_vect9 = data_i;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec22 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec23 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec24 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec25 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE * 2);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec26 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec28 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec29 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec38 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec30 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec31 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec32 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec33 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_N_RAND_TABLE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec34 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_N_RAND_TABLE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec35 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_N_RAND_TABLE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec36 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_N_RAND_TABLE);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec37 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_HFFTSIZE_P1);
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec39 = d32;
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32) * (1
+ PICODSP_COS_TABLE_LEN));
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec40 = d32;
for (nCount = 0; nCount < CEPST_BUFF_SIZE; nCount++) {
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32) * (PICODSP_CEPORDER));
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec41[nCount] = d32;
}
for (nCount = 0; nCount < PHASE_BUFF_SIZE; nCount++) {
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32) * (PICODSP_PHASEORDER));
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->int_vec42[nCount] = d32;
}
d32 = (picoos_int32 *) picoos_allocate(mm, sizeof(picoos_int32)
* PICODSP_FFTSIZE * 2); /* - fixed point */
if (NULL == d32) {
sigDeallocate(mm, sig_inObj);
return PICO_ERR_OTHER;
}
sig_inObj->sig_vec1 = d32;
return PICO_OK;
}/*sigAllocate*/
/**
* frees DSP memory for SIG PU
* @param mm : memory manager
* @param sig_inObj : sig PU internal object of the sub-object
* @return void
* @callgraph
* @callergraph
*/
void sigDeallocate(picoos_MemoryManager mm, sig_innerobj_t *sig_inObj)
{
picoos_int32 nCount;
/*-----------------------------------------------------------------
* Memory de-allocations
* ------------------------------------------------------------------*/
if (NULL != sig_inObj->idx_vect1)
picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect1));
if (NULL != sig_inObj->idx_vect2)
picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect2));
if (NULL != sig_inObj->idx_vect4)
picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect4));
if (NULL != sig_inObj->idx_vect5)
picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect5));
if (NULL != sig_inObj->idx_vect6)
picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect6));
if (NULL != sig_inObj->idx_vect7)
picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect7));
if (NULL != sig_inObj->idx_vect8)
picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect8));
if (NULL != sig_inObj->idx_vect9)
picoos_deallocate(mm, (void *) &(sig_inObj->idx_vect9));
if (NULL != sig_inObj->int_vec22)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec22));
if (NULL != sig_inObj->int_vec23)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec23));
if (NULL != sig_inObj->int_vec24)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec24));
if (NULL != sig_inObj->int_vec25)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec25));
if (NULL != sig_inObj->int_vec26)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec26));
if (NULL != sig_inObj->int_vec28)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec28));
if (NULL != sig_inObj->int_vec29)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec29));
if (NULL != sig_inObj->int_vec38)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec38));
if (NULL != sig_inObj->int_vec30)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec30));
if (NULL != sig_inObj->int_vec31)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec31));
if (NULL != sig_inObj->int_vec32)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec32));
if (NULL != sig_inObj->int_vec33)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec33));
if (NULL != sig_inObj->int_vec34)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec34));
if (NULL != sig_inObj->int_vec35)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec35));
if (NULL != sig_inObj->int_vec36)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec36));
if (NULL != sig_inObj->int_vec37)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec37));
if (NULL != sig_inObj->int_vec39)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec39));
if (NULL != sig_inObj->int_vec40)
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec40));
for (nCount = 0; nCount < CEPST_BUFF_SIZE; nCount++) {
if (NULL != sig_inObj->int_vec41[nCount]) {
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec41[nCount]));
}
}
for (nCount = 0; nCount < PHASE_BUFF_SIZE; nCount++) {
if (NULL != sig_inObj->int_vec42[nCount]) {
picoos_deallocate(mm, (void *) &(sig_inObj->int_vec42[nCount]));
}
}
if (NULL != sig_inObj->sig_vec1) {
picoos_deallocate(mm, (void *) &(sig_inObj->sig_vec1));
}
}/*sigDeAllocate*/
/**
* initializes all memory neededed by DSP at instance creation time
* @param sig_inObj : sig PU internal object of the sub-object
* @return void
* @callgraph
* @callergraph
*/
void sigDspInitialize(sig_innerobj_t *sig_inObj, picoos_int32 resetMode)
{
picoos_int32 i, j;
picoos_int32 *pnt;
if (resetMode == PICO_RESET_SOFT) {
/*minimal initialization when receiving a soft reset */
return;
}
/*-----------------------------------------------------------------
* Initialization
* ------------------------------------------------------------------*/
sig_inObj->warp_p = PICODSP_FREQ_WARP_FACT;
sig_inObj->VCutoff_p = PICODSP_V_CUTOFF_FREQ; /*voicing cut off frequency in Hz (will be modeled in the future)*/
sig_inObj->UVCutoff_p = PICODSP_UV_CUTOFF_FREQ;/*unvoiced frames only (periodize lowest components to mask bad voicing transitions)*/
sig_inObj->Fs_p = PICODSP_SAMP_FREQ; /*Sampling freq*/
sig_inObj->m1_p = PICODSP_CEPORDER;
sig_inObj->m2_p = PICODSP_FFTSIZE; /*also initializes windowLen*/
sig_inObj->framesz_p = PICODSP_DISPLACE; /*1/4th of the frame size = displacement*/
sig_inObj->hfftsize_p = PICODSP_H_FFTSIZE; /*half of the FFT size*/
sig_inObj->voxbnd_p = (picoos_int32) ((picoos_single) sig_inObj->hfftsize_p
/ ((picoos_single) sig_inObj->Fs_p / (picoos_single) 2)
* (picoos_single) sig_inObj->VCutoff_p);
sig_inObj->voxbnd2_p
= (picoos_int32) ((picoos_single) sig_inObj->hfftsize_p
/ ((picoos_single) sig_inObj->Fs_p / (picoos_single) 2)
* (picoos_single) sig_inObj->UVCutoff_p);
sig_inObj->hop_p = sig_inObj->framesz_p;
sig_inObj->nextPeak_p = (((int) (PICODSP_FFTSIZE))
/ ((int) PICODSP_DISPLACE) - 1) * sig_inObj->hop_p;
sig_inObj->phId_p = 0; /*phonetic id*/
sig_inObj->E_p = (picoos_single) 0.0f;
sig_inObj->F0_p = (picoos_single) 0.0f;
sig_inObj->voiced_p = 0;
sig_inObj->nV = sig_inObj->nU = 0;
sig_inObj->sMod_p = (picoos_single) 1.0f;
/*cleanup vectors*/
for (i = 0; i < 2 * PICODSP_FFTSIZE; i++) {
sig_inObj->sig_vec1[i] = 0;
sig_inObj->int_vec26[i] = 0; /*wav buff cleanup */
}
for (i = 0; i < PICODSP_FFTSIZE; i++) {
sig_inObj->idx_vect1[i] = sig_inObj->idx_vect4[i]
= sig_inObj->idx_vect5[i] = sig_inObj->idx_vect6[i] = 0;
sig_inObj->int_vec32[i] = sig_inObj->int_vec33[i] = 0;
}
for (i = 0; i < PICODSP_HFFTSIZE_P1; i++) {
sig_inObj->idx_vect2[i] = (picoos_int16) 0;
}
for (i = 0; i < CEPST_BUFF_SIZE; i++) {
sig_inObj->F0Buff[i]=0;
sig_inObj->PhIdBuff[i]=0;
sig_inObj->VoicingBuff[i]=0;
sig_inObj->FuVBuff[i]=0;
if (NULL != sig_inObj->CepBuff[i]) {
pnt = sig_inObj->CepBuff[i];
for (j = 0; j < PICODSP_CEPORDER; j++) {
pnt[j] = 0;
}
}
}
for (i = 0; i < PHASE_BUFF_SIZE; i++) {
if (NULL != sig_inObj->int_vec42[i]) {
pnt = sig_inObj->int_vec42[i];
for (j = 0; j < PICODSP_PHASEORDER; j++) {
pnt[j] = 0;
}
}
}
sig_inObj->n_available=0;
/*---------------------------------------------
Init formant enhancement window
hanning window,
Post Filter Hermite's interpolator Matrix
Mel-2-Lin lookup tables
---------------------------------------------*/
enh_wind_init(sig_inObj); /*creates the formant enhancement window*/
init_rand(sig_inObj);
gen_hann2(sig_inObj);
mel_2_lin_init(sig_inObj);
}/*sigDspInitialize*/
/*-------------------------------------------------------------------------------
PROCESSING FUNCTIONS : CALLED WITHIN sigStep (cfr. picosig.c)
--------------------------------------------------------------------------------*/
/**
* convert from mel scale to linear scale
* @param sig_inObj : sig PU internal object of the sub-object
* @param scmeanMGC : mean value of the MGC
* @return void
* @callgraph
* @callergraph
* @remarks translated from matlab code to c-code
* Input
* - c1 : input mfcc vector (ceporder=m1, real)
* - m1 : input order
* - A,B,D : lookup tables
* - m2 : output order
* - Xr,Xi (m2=FFT size, real) temporary arrays for FFT
* - WNr,WNi (m2=FFT size, real) cos and sin precalculated tables
* Output
* - Xr (m2=FFT size, real) linear cepstral vector
*/
void mel_2_lin_lookup(sig_innerobj_t *sig_inObj, picoos_uint32 scmeanMGC)
{
/*Local vars*/
picoos_int16 nI, k;
picoos_int32 delta, term1, term2;
/*Local vars to be linked with sig data object*/
picoos_int32 *c1, *XXr;
picoos_single K1;
picoos_int32 *D, K2, shift;
picoos_int16 m1, *A, m2, m4, voiced, i;
/*Link local variables with sig data object*/
c1 = sig_inObj->wcep_pI;
m1 = sig_inObj->m1_p;
m2 = PICODSP_FFTSIZE;
m4 = m2 >> 1;
A = sig_inObj->A_p;
D = sig_inObj->d_p;
XXr = sig_inObj->wcep_pI;
voiced = sig_inObj->voiced_p;
shift = 27 - scmeanMGC;
K2 = 1 << shift;
K1 = (picoos_single) PICODSP_START_FLOAT_NORM * K2;
XXr[0] = (picoos_int32) ((picoos_single) c1[0] * K1);
for (nI = 1; nI < m1; nI++) {
XXr[nI] = c1[nI] << shift;
}
i = sizeof(picoos_int32) * (PICODSP_FFTSIZE - m1);
picoos_mem_set(XXr + m1, 0, i);
dfct_nmf(m4, XXr); /* DFCT directly in fixed point */
/* *****************************************************************************************
Linear frequency scale envelope through interpolation.
Two additions and one multiplication per entry.
Optimization of linear interpolation algorithm
- Start from 1 and stop at PICODSP_H_FFTSIZE-1 because 0 and PICODSP_H_FFTSIZE are invariant points
- B[k]=A[k]+1 except for 0 and PICODSP_H_FFTSIZE
- get rid of extra -1 operation by adapting the table A[]
*******************************************************************************************/
for (nI = 1; nI < PICODSP_H_FFTSIZE; nI++) {
k = A[nI];
term2 = XXr[k];
term1 = XXr[k + 1];
delta = term1 - term2;
XXr[nI] = term2 + ((D[nI] * delta) >> 5); /* ok because nI<=A[nI] <=B[nI] */
}
}/*mel_2_lin_lookup*/
/**
* calculate phase
* @remarks voiced phase taken from phase codebook and smoothed,
* @remarks unvoiced phase - random
* @param sig_inObj : sig PU internal object of the sub-object
* @return void
* @callgraph
* @callergraph
*/
void phase_spec2(sig_innerobj_t *sig_inObj)
{
picoos_int16 nI, iRand, firstUV;
picoos_int32 *tmp1, *tmp2;
picoos_int16 VOXBND_M1;
picoos_int32 *spect, *ang;
picoos_int16 voiced, m2;
picoos_int32 *co, *so, *c, *s, voxbnd, voxbnd2;
picoos_int16 i,j, k, n_comp;
picoos_int16 *Pvoxbnd;
picoos_int32 *phs_p2, *phs_p1, *phs_n1, *phs_n2;
picoos_int32 *phs;
/*Link local variables to sig data object*/
spect = sig_inObj->wcep_pI; /* spect_p;*/
/* current spect scale : times PICODSP_FIX_SCALE1 */
ang = sig_inObj->ang_p;
voxbnd = (picoos_int32) (sig_inObj->voxbnd_p * sig_inObj->voicing);
voxbnd2 = sig_inObj->voxbnd2_p;
voiced = sig_inObj->voiced_p;
m2 = sig_inObj->m2_p;
VOXBND_M1 = voxbnd - 1;
firstUV = 1;
/*code starts here*/
if (voiced == 1) {
firstUV = voxbnd;
Pvoxbnd = sig_inObj->VoxBndBuff;
n_comp = Pvoxbnd[2];
phs_p2 = sig_inObj->PhsBuff[0];
phs_p1 = sig_inObj->PhsBuff[1];
phs = sig_inObj->PhsBuff[2];
phs_n1 = sig_inObj->PhsBuff[3];
phs_n2 = sig_inObj->PhsBuff[4];
/* find and smooth components which have full context */
j = n_comp;
for (i=0; i<5; i++) {
if (Pvoxbnd[i]<j) j = Pvoxbnd[i];
}
for (i=0; i<j; i++) {
ang[i] = -(((phs_p2[i]+phs_p1[i]+phs[i]+phs_n1[i]+phs_n2[i])<<6) / 5);
}
/* find and smooth components which at least one component on each side */
k = n_comp;
if (Pvoxbnd[2]<k) k = Pvoxbnd[2];
if (Pvoxbnd[4]<k) k = Pvoxbnd[4];
for (i=j; i<k; i++) { /* smooth using only two surrounding neighbours */
ang[i] = -(((phs_p1[i]+phs[i]+phs_n1[i])<<6) / 3);
}
/* handle rest of components - at least one side does not exist */
for (i=k; i<n_comp; i++) {
ang[i] = -(phs[i]<<6); /* - simple copy without smoothing */
}
/*Phase unwrap - cumsum */
tmp1 = &(ang[1]);
tmp2 = &(ang[0]);
/* current ang scale : PICODSP_M_PI = PICODSP_FIX_SCALE2 */
FAST_DEVICE(VOXBND_M1,*(tmp1++)+=*(tmp2)-PICODSP_FIX_SCALE2;*(tmp2)=(*tmp2>=0)?(*tmp2)>>PICODSP_SHIFT_FACT4:-((-(*tmp2))>>PICODSP_SHIFT_FACT4);tmp2++);
*tmp2 = (*tmp2 >= 0) ? (*tmp2) >> PICODSP_SHIFT_FACT4 : -((-(*tmp2))
>> PICODSP_SHIFT_FACT4); /*ang[voxbnd-1]/=2;*/
}
/* now for the unvoiced part */
iRand = sig_inObj->iRand;
c = sig_inObj->randCosTbl + iRand;
s = sig_inObj->randSinTbl + iRand;
co = sig_inObj->outCosTbl + firstUV;
so = sig_inObj->outSinTbl + firstUV;
for (nI = firstUV; nI < PICODSP_HFFTSIZE_P1 - 1; nI++) {
*co++ = *c++;
*so++ = *s++;
}
*co = 1;
*so = 0;
sig_inObj->iRand += (PICODSP_HFFTSIZE_P1 - firstUV);
if (sig_inObj->iRand > PICODSP_N_RAND_TABLE - PICODSP_HFFTSIZE_P1)
sig_inObj->iRand = 1 + sig_inObj->iRand + PICODSP_HFFTSIZE_P1
- PICODSP_N_RAND_TABLE;
}/*phase_spec2*/
/**
* Prepare Envelope spectrum for inverse FFT
* @param sig_inObj : sig PU internal object of the sub-object
* @return void
* @remarks make phase bilateral -->> angh (FFT size, real)
* @remarks combine in complex input vector for IFFT F = e**(spet/2+j*ang)
* @remarks Compute energy -->> E (scalar, real)
* @callgraph
* @callergraph
* Input
* - spect (FFT size, real)
* - ang (half FFT size -1, real)
* - m2 fftsize
* - WNr,WNi (FFT size, real) the tabulated sine and cosine values
* - brev (FFT size, real) the tabulated bit reversal indexes
* Output
* - Fr, Fi (FFT size, complex) the envelope spectrum
* - E (scalar, real) the energy
*/
void env_spec(sig_innerobj_t *sig_inObj)
{
picoos_int16 nI;
picoos_int32 fcX, fsX, fExp, voxbnd;
picoos_int32 *spect, *ang, *ctbl;
picoos_int16 voiced, prev_voiced;
picoos_int32 *co, *so;
picoos_int32 *Fr, *Fi;
picoos_single mult;
/*Link local variables to sig object*/
spect = sig_inObj->wcep_pI; /*spect_p*/
/* current spect scale : times PICODSP_FIX_SCALE1 */
ang = sig_inObj->ang_p;
/* current spect scale : PICODSP_M_PI = PICODSP_FIX_SCALE2 */
Fr = sig_inObj->F2r_p;
Fi = sig_inObj->F2i_p;
voiced = sig_inObj->voiced_p;
prev_voiced = sig_inObj->prevVoiced_p;
voxbnd = (picoos_int32) (sig_inObj->voxbnd_p * sig_inObj->voicing);
ctbl = sig_inObj->cos_table;
/* ctbl scale : times 4096 */
mult = PICODSP_ENVSPEC_K1 / PICODSP_FIX_SCALE1;
/*remove dc from real part*/
if (sig_inObj->F0_p > 120) {
spect[0] = spect[1] = 0;
spect[2] /= PICODSP_ENVSPEC_K2;
} else {
spect[0] = 0;
}
/* if using rand table, use sin and cos tables as well */
if (voiced || (prev_voiced)) {
/*Envelope becomes a complex exponential : F=exp(.5*spect + j*angh);*/
for (nI = 0; nI < voxbnd; nI++) {
get_trig(ang[nI], ctbl, &fcX, &fsX);
fExp = (picoos_int32) EXP((double)spect[nI]*mult);
Fr[nI] = fExp * fcX;
Fi[nI] = fExp * fsX;
}
/* ao=sig_inObj->ang_p+(picoos_int32)voxbnd; */
co = sig_inObj->outCosTbl + voxbnd;
so = sig_inObj->outSinTbl + voxbnd;
for (nI = voxbnd; nI < PICODSP_HFFTSIZE_P1; nI++) {
fcX = *co++;
fsX = *so++;
fExp = (picoos_int32) EXP((double)spect[nI]*mult);
Fr[nI] = fExp * fcX;
Fi[nI] = fExp * fsX;
}
} else {
/*ao=sig_inObj->ang_p+1;*/
co = sig_inObj->outCosTbl + 1;
so = sig_inObj->outSinTbl + 1;
for (nI = 1; nI < PICODSP_HFFTSIZE_P1; nI++) {
fcX = *co++;
fsX = *so++;
fExp = (picoos_int32) EXP((double)spect[nI]*mult);
Fr[nI] = fExp * fcX;
Fi[nI] = fExp * fsX;
}
}
}/*env_spec*/
/**
* Calculates the impulse response of the comlpex spectrum through inverse rFFT
* @param sig_inObj : sig PU internal object of the sub-object
* @return void
* @remarks Imp corresponds with the real part of the FFT
* @callgraph
* @callergraph
* Input
* - Fr, Fi (FFT size, real & imaginary) the complex envelope spectrum (only first half of spectrum)
* Output
* - Imp: impulse response (length: m2)
* - E (scalar, real) RMS value
*/
void impulse_response(sig_innerobj_t *sig_inObj)
{
/*Define local variables*/
picoos_single f;
picoos_int16 nI, nn, m2, m4, voiced;
picoos_single *E;
picoos_int32 *norm_window; /* - fixed point */
picoos_int32 *fr, *Fr, *Fi, *t1, ff; /* - fixed point */
/*Link local variables with sig object*/
m2 = sig_inObj->m2_p;
m4 = m2 >> 1;
Fr = sig_inObj->F2r_p;
Fi = sig_inObj->F2i_p;
norm_window = sig_inObj->norm_window_p;
E = &(sig_inObj->E_p); /*as pointer: value will be modified*/
voiced = sig_inObj->voiced_p;
fr = sig_inObj->imp_p;
/*Inverse FFT*/
for (nI = 0, nn = 0; nI < m4; nI++, nn += 2) {
fr[nn] = Fr[nI]; /* - fixed point */
}
fr[1] = (picoos_int32) (Fr[m4]);
for (nI = 1, nn = 3; nI < m4; nI++, nn += 2) {
fr[nn] = -Fi[nI]; /* - fixed point */
}
rdft(m2, -1, fr);
/*window, normalize and differentiate*/
*E = norm_result(m2, fr, norm_window);
if (*E > 0) {
f = *E * PICODSP_FIXRESP_NORM;
} else {
f = 20; /*PICODSP_FIXRESP_NORM*/
}
ff = (picoos_int32) f;
if (ff < 1)
ff = 1;
/*normalize impulse response*/
t1 = fr;FAST_DEVICE(PICODSP_FFTSIZE,*(t1++) /= ff;); /* - fixed point */
} /* impulse_response */
/**
* time domain pitch synchronous overlap add over two frames (when no voicing transition)
* @param sig_inObj : sig PU internal object of the sub-object
* @return void
* @remarks Special treatment at voicing boundaries
* @remarks Introduced to get rid of time-domain aliasing (and additional speed up)
* @callgraph
* @callergraph
*/
void td_psola2(sig_innerobj_t *sig_inObj)
{
picoos_int16 nI;
picoos_int16 hop, m2, *nextPeak, voiced;
picoos_int32 *t1, *t2;
picoos_int16 cnt;
picoos_int32 *fr, *v1, ff, f;
picoos_int16 a, i;
picoos_int32 *window;
picoos_int16 s = (picoos_int16) 1;
window = sig_inObj->window_p;
/*Link local variables with sig object*/
hop = sig_inObj->hop_p;
m2 = sig_inObj->m2_p;
nextPeak = &(sig_inObj->nextPeak_p);
voiced = sig_inObj->voiced_p;
fr = sig_inObj->imp_p;
/*toggle the pointers and initialize signal vector */
v1 = sig_inObj->sig_vec1;
t1 = v1;
FAST_DEVICE(PICODSP_FFTSIZE-PICODSP_DISPLACE,*(t1++)=0;);
t1 = &(v1[PICODSP_FFTSIZE - PICODSP_DISPLACE]);
t2 = &(v1[PICODSP_FFTSIZE]);
FAST_DEVICE(PICODSP_FFTSIZE, *(t1++)=*(t2++););
t1 = &(v1[2 * PICODSP_FFTSIZE - PICODSP_DISPLACE]);FAST_DEVICE(PICODSP_DISPLACE,*(t1++)=0;);
/*calculate excitation points*/
get_simple_excitation(sig_inObj, nextPeak);
/*TD-PSOLA based on excitation vector */
if ((sig_inObj->nU == 0) && (sig_inObj->voiced_p == 1)) {
/* purely voiced */
for (nI = 0; nI < sig_inObj->nV; nI++) {
f = sig_inObj->EnV[nI];
a = 0;
cnt = PICODSP_FFTSIZE;
ff = (f * window[sig_inObj->LocV[nI]]) >> PICODSP_SHIFT_FACT1;
t1 = &(v1[a + sig_inObj->LocV[nI]]);
t2 = &(fr[a]);
if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff;);
}
} else if ((sig_inObj->nV == 0) && (sig_inObj->voiced_p == 0)) {
/* PURELY UNVOICED*/
for (nI = 0; nI < sig_inObj->nU; nI++) {
f = sig_inObj->EnU[nI];
s = -s; /*reverse order to reduce the periodicity effect*/
if (s == 1) {
a = 0;
cnt = PICODSP_FFTSIZE;
ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
t1 = &(v1[a + sig_inObj->LocU[nI]]);
t2 = &(fr[a]);
if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff; );
} else { /*s==-1*/
a = 0;
cnt = PICODSP_FFTSIZE;
ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
t1 = &(v1[(m2 - 1 - a) + sig_inObj->LocU[nI]]);
t2 = &(fr[a]);
if (cnt > 0)FAST_DEVICE(cnt,*(t1--)+=*(t2++)*ff; );
}
}
} else if (sig_inObj->VoicTrans == 0) {
/*voicing transition from unvoiced to voiced*/
for (nI = 0; nI < sig_inObj->nV; nI++) {
f = sig_inObj->EnV[nI];
a = 0;
cnt = PICODSP_FFTSIZE;
ff = (f * window[sig_inObj->LocV[nI]]) >> PICODSP_SHIFT_FACT1;
t1 = &(v1[a + sig_inObj->LocV[nI]]);
t2 = &(fr[a]);
if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff;);
}
/*add remaining stuff from unvoiced part*/
for (nI = 0; nI < sig_inObj->nU; nI++) {
f = sig_inObj->EnU[nI];
s = -s; /*reverse order to reduce the periodicity effect*/
if (s == 1) {
a = 0;
cnt = PICODSP_FFTSIZE;
ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
t1 = &(v1[a + sig_inObj->LocU[nI]]);
t2 = &(sig_inObj->ImpResp_p[a]); /*saved impulse response*/
if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff; );
} else {
a = 0;
cnt = PICODSP_FFTSIZE;
ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
t1 = &(v1[(m2 - 1 - a) + sig_inObj->LocU[nI]]);
t2 = &(sig_inObj->ImpResp_p[a]);
if (cnt > 0)FAST_DEVICE(cnt,*(t1--)+=*(t2++)*ff; );
}
}
} else {
/*voiced to unvoiced*/
for (nI = 0; nI < sig_inObj->nU; nI++) {
f = sig_inObj->EnU[nI];
s = -s; /*reverse order to reduce the periodicity effect*/
if (s > 0) {
a = 0;
cnt = PICODSP_FFTSIZE;
ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
t1 = &(v1[a + sig_inObj->LocU[nI]]);
t2 = &(fr[a]);
if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff; );
} else {
a = 0;
cnt = PICODSP_FFTSIZE;
ff = (f * window[sig_inObj->LocU[nI]]) >> PICODSP_SHIFT_FACT1;
t1 = &(v1[(m2 - 1 - a) + sig_inObj->LocU[nI]]);
t2 = &(fr[a]);
if (cnt > 0)FAST_DEVICE(cnt,*(t1--)+=*(t2++)*ff; );
}
}
/*add remaining stuff from voiced part*/
for (nI = 0; nI < sig_inObj->nV; nI++) {
f = sig_inObj->EnV[nI];
a = 0;
cnt = PICODSP_FFTSIZE;
ff = (f * window[sig_inObj->LocV[nI]]) >> PICODSP_SHIFT_FACT1;
t1 = &(v1[a + sig_inObj->LocV[nI]]);
t2 = &(sig_inObj->ImpResp_p[a]);
if (cnt > 0)FAST_DEVICE(cnt,*(t1++)+=*(t2++)*ff;);
}
}
t1 = sig_inObj->sig_vec1;
for (i = 0; i < PICODSP_FFTSIZE; i++, t1++) {
if (*t1 >= 0)
*t1 >>= PICODSP_SHIFT_FACT5;
else
*t1 = -((-*t1) >> PICODSP_SHIFT_FACT5);
}
}/*td_psola2*/
/**
* overlap + add summing of impulse responses on the final destination sample buffer
* @param sig_inObj : sig PU internal object of the sub-object
* @return void
* @remarks Special treatment at voicing boundaries
* @remarks Introduced to get rid of time-domain aliasing (and additional speed up)
* Input
* - wlet : the generic impulse response (FFT size, real)
* - window : the windowing funcion (FFT size, real) fixed
* - WavBuff : the destination buffer with past samples (FFT size*2, short)
* - m2 : fftsize
* Output
* - WavBuff : the destination buffer with updated samples (FFT size*2, short)
* @callgraph
* @callergraph
*/
void overlap_add(sig_innerobj_t *sig_inObj)
{
/*Local variables*/
picoos_int32 *w, *v;
/*Link local variables with sig object*/
w = sig_inObj->WavBuff_p;
v = sig_inObj->sig_vec1;
FAST_DEVICE(PICODSP_FFTSIZE, *(w++)+=*(v++)<<PICODSP_SHIFT_FACT6;);
}/*overlap_add*/
/*-------------------------------------------------------------------------------
INITIALIZATION AND INTERNAL FUNCTIONS
--------------------------------------------------------------------------------*/
/**
* Hanning window initialization
* @param sig_inObj : sig PU internal object of the sub-object
* @return PICO_OK
* @callgraph
* @callergraph
*/
static void gen_hann2(sig_innerobj_t *sig_inObj)
{
picoos_int32 *hann;
picoos_int32 *norm;
/*link local variables with sig object*/
hann = sig_inObj->window_p;
norm = sig_inObj->norm_window_p;
norm[0] = 80224;
norm[1] = 320832;
norm[2] = 721696;
norm[3] = 1282560;
norm[4] = 2003104;
norm[5] = 2882880;
norm[6] = 3921376;
norm[7] = 5117984;
norm[8] = 6471952;
norm[9] = 7982496;
norm[10] = 9648720;
norm[11] = 11469616;
norm[12] = 13444080;
norm[13] = 15570960;
norm[14] = 17848976;
norm[15] = 20276752;
norm[16] = 22852864;
norm[17] = 25575744;
norm[18] = 28443776;
norm[19] = 31455264;
norm[20] = 34608368;
norm[21] = 37901248;
norm[22] = 41331904;
norm[23] = 44898304;
norm[24] = 48598304;
norm[25] = 52429696;
norm[26] = 56390192;
norm[27] = 60477408;
norm[28] = 64688944;
norm[29] = 69022240;
norm[30] = 73474720;
norm[31] = 78043744;
norm[32] = 82726544;
norm[33] = 87520352;
norm[34] = 92422272;
norm[35] = 97429408;
norm[36] = 102538752;
norm[37] = 107747248;
norm[38] = 113051776;
norm[39] = 118449184;
norm[40] = 123936224;
norm[41] = 129509648;
norm[42] = 135166080;
norm[43] = 140902192;
norm[44] = 146714528;
norm[45] = 152599584;
norm[46] = 158553904;
norm[47] = 164573888;
norm[48] = 170655936;
norm[49] = 176796448;
norm[50] = 182991712;
norm[51] = 189238064;
norm[52] = 195531744;
norm[53] = 201868992;
norm[54] = 208246016;
norm[55] = 214659040;
norm[56] = 221104176;
norm[57] = 227577616;
norm[58] = 234075488;
norm[59] = 240593872;
norm[60] = 247128912;
norm[61] = 253676688;
norm[62] = 260233280;
norm[63] = 266794768;
norm[64] = 273357248;
norm[65] = 279916768;
norm[66] = 286469440;
norm[67] = 293011360;
norm[68] = 299538560;
norm[69] = 306047168;
norm[70] = 312533312;
norm[71] = 318993088;
norm[72] = 325422656;
norm[73] = 331818144;
norm[74] = 338175744;
norm[75] = 344491680;
norm[76] = 350762176;
norm[77] = 356983424;
norm[78] = 363151808;
norm[79] = 369263520;
norm[80] = 375315008;
norm[81] = 381302592;
norm[82] = 387222720;
norm[83] = 393071872;
norm[84] = 398846528;
norm[85] = 404543232;
norm[86] = 410158560;
norm[87] = 415689216;
norm[88] = 421131840;
norm[89] = 426483200;
norm[90] = 431740096;
norm[91] = 436899392;
norm[92] = 441958016;
norm[93] = 446912928;
norm[94] = 451761152;
norm[95] = 456499840;
norm[96] = 461126080;
norm[97] = 465637152;
norm[98] = 470030400;
norm[99] = 474303104;
norm[100] = 478452800;
norm[101] = 482476960;
norm[102] = 486373184;
norm[103] = 490139200;
norm[104] = 493772640;
norm[105] = 497271424;
norm[106] = 500633440;
norm[107] = 503856704;
norm[108] = 506939200;
norm[109] = 509879168;
norm[110] = 512674880;
norm[111] = 515324544;
norm[112] = 517826688;
norm[113] = 520179776;
norm[114] = 522382368;
norm[115] = 524433184;
norm[116] = 526331008;
norm[117] = 528074688;
norm[118] = 529663200;
norm[119] = 531095552;
norm[120] = 532370944;
norm[121] = 533488576;
norm[122] = 534447808;
norm[123] = 535248000;
norm[124] = 535888768;
norm[125] = 536369664;
norm[126] = 536690432;
norm[127] = 536850880;
norm[128] = 536850880;
norm[129] = 536690432;
norm[130] = 536369664;
norm[131] = 535888768;
norm[132] = 535248000;
norm[133] = 534447808;
norm[134] = 533488576;
norm[135] = 532370944;
norm[136] = 531095552;
norm[137] = 529663200;
norm[138] = 528074688;
norm[139] = 526331008;
norm[140] = 524433216;
norm[141] = 522382368;
norm[142] = 520179776;
norm[143] = 517826688;
norm[144] = 515324544;
norm[145] = 512674880;
norm[146] = 509879168;
norm[147] = 506939200;
norm[148] = 503856704;
norm[149] = 500633472;
norm[150] = 497271424;
norm[151] = 493772672;
norm[152] = 490139200;
norm[153] = 486373184;
norm[154] = 482476992;
norm[155] = 478452800;
norm[156] = 474303104;
norm[157] = 470030400;
norm[158] = 465637184;
norm[159] = 461126080;
norm[160] = 456499840;
norm[161] = 451761152;
norm[162] = 446912960;
norm[163] = 441958016;
norm[164] = 436899424;
norm[165] = 431740096;
norm[166] = 426483200;
norm[167] = 421131840;
norm[168] = 415689216;
norm[169] = 410158560;
norm[170] = 404543232;
norm[171] = 398846528;
norm[172] = 393071872;
norm[173] = 387222720;
norm[174] = 381302592;
norm[175] = 375315008;
norm[176] = 369263552;
norm[177] = 363151808;
norm[178] = 356983456;
norm[179] = 350762176;
norm[180] = 344491712;
norm[181] = 338175776;
norm[182] = 331818144;
norm[183] = 325422656;
norm[184] = 318993088;
norm[185] = 312533312;
norm[186] = 306047168;
norm[187] = 299538560;
norm[188] = 293011360;
norm[189] = 286469472;
norm[190] = 279916800;
norm[191] = 273357248;
norm[192] = 266794784;
norm[193] = 260233280;
norm[194] = 253676688;
norm[195] = 247128928;
norm[196] = 240593888;
norm[197] = 234075488;
norm[198] = 227577632;
norm[199] = 221104192;
norm[200] = 214659040;
norm[201] = 208246032;
norm[202] = 201868992;
norm[203] = 195531744;
norm[204] = 189238080;
norm[205] = 182991728;
norm[206] = 176796448;
norm[207] = 170655952;
norm[208] = 164573888;
norm[209] = 158553920;
norm[210] = 152599600;
norm[211] = 146714528;
norm[212] = 140902208;
norm[213] = 135166096;
norm[214] = 129509648;
norm[215] = 123936240;
norm[216] = 118449184;
norm[217] = 113051776;
norm[218] = 107747248;
norm[219] = 102538752;
norm[220] = 97429424;
norm[221] = 92422288;
norm[222] = 87520352;
norm[223] = 82726544;
norm[224] = 78043744;
norm[225] = 73474736;
norm[226] = 69022240;
norm[227] = 64688944;
norm[228] = 60477424;
norm[229] = 56390192;
norm[230] = 52429696;
norm[231] = 48598304;
norm[232] = 44898304;
norm[233] = 41331904;
norm[234] = 37901248;
norm[235] = 34608384;
norm[236] = 31455264;
norm[237] = 28443792;
norm[238] = 25575744;
norm[239] = 22852864;
norm[240] = 20276752;
norm[241] = 17848976;
norm[242] = 15570960;
norm[243] = 13444080;
norm[244] = 11469616;
norm[245] = 9648720;
norm[246] = 7982512;
norm[247] = 6471952;
norm[248] = 5117984;
norm[249] = 3921376;
norm[250] = 2882880;
norm[251] = 2003104;
norm[252] = 1282560;
norm[253] = 721696;
norm[254] = 320832;
norm[255] = 80224;
hann[0] = 0;
hann[1] = 0;
hann[2] = 1;
hann[3] = 2;
hann[4] = 3;
hann[5] = 5;
hann[6] = 7;
hann[7] = 9;
hann[8] = 12;
hann[9] = 15;
hann[10] = 18;
hann[11] = 21;
hann[12] = 25;
hann[13] = 29;
hann[14] = 34;
hann[15] = 38;
hann[16] = 43;
hann[17] = 48;
hann[18] = 54;
hann[19] = 59;
hann[20] = 66;
hann[21] = 72;
hann[22] = 78;
hann[23] = 85;
hann[24] = 92;
hann[25] = 100;
hann[26] = 107;
hann[27] = 115;
hann[28] = 123;
hann[29] = 131;
hann[30] = 140;
hann[31] = 148;
hann[32] = 157;
hann[33] = 166;
hann[34] = 176;
hann[35] = 185;
hann[36] = 195;
hann[37] = 205;
hann[38] = 215;
hann[39] = 225;
hann[40] = 236;
hann[41] = 247;
hann[42] = 257;
hann[43] = 268;
hann[44] = 279;
hann[45] = 291;
hann[46] = 302;
hann[47] = 313;
hann[48] = 325;
hann[49] = 337;
hann[50] = 349;
hann[51] = 360;
hann[52] = 372;
hann[53] = 385;
hann[54] = 397;
hann[55] = 409;
hann[56] = 421;
hann[57] = 434;
hann[58] = 446;
hann[59] = 458;
hann[60] = 471;
hann[61] = 483;
hann[62] = 496;
hann[63] = 508;
hann[64] = 521;
hann[65] = 533;
hann[66] = 546;
hann[67] = 558;
hann[68] = 571;
hann[69] = 583;
hann[70] = 596;
hann[71] = 608;
hann[72] = 620;
hann[73] = 632;
hann[74] = 645;
hann[75] = 657;
hann[76] = 669;
hann[77] = 680;
hann[78] = 692;
hann[79] = 704;
hann[80] = 715;
hann[81] = 727;
hann[82] = 738;
hann[83] = 749;
hann[84] = 760;
hann[85] = 771;
hann[86] = 782;
hann[87] = 792;
hann[88] = 803;
hann[89] = 813;
hann[90] = 823;
hann[91] = 833;
hann[92] = 842;
hann[93] = 852;
hann[94] = 861;
hann[95] = 870;
hann[96] = 879;
hann[97] = 888;
hann[98] = 896;
hann[99] = 904;
hann[100] = 912;
hann[101] = 920;
hann[102] = 927;
hann[103] = 934;
hann[104] = 941;
hann[105] = 948;
hann[106] = 954;
hann[107] = 961;
hann[108] = 966;
hann[109] = 972;
hann[110] = 977;
hann[111] = 982;
hann[112] = 987;
hann[113] = 992;
hann[114] = 996;
hann[115] = 1000;
hann[116] = 1003;
hann[117] = 1007;
hann[118] = 1010;
hann[119] = 1012;
hann[120] = 1015;
hann[121] = 1017;
hann[122] = 1019;
hann[123] = 1020;
hann[124] = 1022;
hann[125] = 1023;
hann[126] = 1023;
hann[127] = 1023;
hann[128] = 1023;
hann[129] = 1023;
hann[130] = 1023;
hann[131] = 1022;
hann[132] = 1020;
hann[133] = 1019;
hann[134] = 1017;
hann[135] = 1015;
hann[136] = 1012;
hann[137] = 1010;
hann[138] = 1007;
hann[139] = 1003;
hann[140] = 1000;
hann[141] = 996;
hann[142] = 992;
hann[143] = 987;
hann[144] = 982;
hann[145] = 977;
hann[146] = 972;
hann[147] = 966;
hann[148] = 961;
hann[149] = 954;
hann[150] = 948;
hann[151] = 941;
hann[152] = 934;
hann[153] = 927;
hann[154] = 920;
hann[155] = 912;
hann[156] = 904;
hann[157] = 896;
hann[158] = 888;
hann[159] = 879;
hann[160] = 870;
hann[161] = 861;
hann[162] = 852;
hann[163] = 842;
hann[164] = 833;
hann[165] = 823;
hann[166] = 813;
hann[167] = 803;
hann[168] = 792;
hann[169] = 782;
hann[170] = 771;
hann[171] = 760;
hann[172] = 749;
hann[173] = 738;
hann[174] = 727;
hann[175] = 715;
hann[176] = 704;
hann[177] = 692;
hann[178] = 680;
hann[179] = 669;
hann[180] = 657;
hann[181] = 645;
hann[182] = 632;
hann[183] = 620;
hann[184] = 608;
hann[185] = 596;
hann[186] = 583;
hann[187] = 571;
hann[188] = 558;
hann[189] = 546;
hann[190] = 533;
hann[191] = 521;
hann[192] = 508;
hann[193] = 496;
hann[194] = 483;
hann[195] = 471;
hann[196] = 458;
hann[197] = 446;
hann[198] = 434;
hann[199] = 421;
hann[200] = 409;
hann[201] = 397;
hann[202] = 385;
hann[203] = 372;
hann[204] = 360;
hann[205] = 349;
hann[206] = 337;
hann[207] = 325;
hann[208] = 313;
hann[209] = 302;
hann[210] = 291;
hann[211] = 279;
hann[212] = 268;
hann[213] = 257;
hann[214] = 247;
hann[215] = 236;
hann[216] = 225;
hann[217] = 215;
hann[218] = 205;
hann[219] = 195;
hann[220] = 185;
hann[221] = 176;
hann[222] = 166;
hann[223] = 157;
hann[224] = 148;
hann[225] = 140;
hann[226] = 131;
hann[227] = 123;
hann[228] = 115;
hann[229] = 107;
hann[230] = 100;
hann[231] = 92;
hann[232] = 85;
hann[233] = 78;
hann[234] = 72;
hann[235] = 66;
hann[236] = 59;
hann[237] = 54;
hann[238] = 48;
hann[239] = 43;
hann[240] = 38;
hann[241] = 34;
hann[242] = 29;
hann[243] = 25;
hann[244] = 21;
hann[245] = 18;
hann[246] = 15;
hann[247] = 12;
hann[248] = 9;
hann[249] = 7;
hann[250] = 5;
hann[251] = 3;
hann[252] = 2;
hann[253] = 1;
hann[254] = 0;
hann[255] = 0;
} /* gen_hann2 */
/**
* Creates the non uniform enhancement window (bilinearly mapped hannning window)
* in order to reduce the formant enhancement in the high spectrum
* @param mm : memory manager
* @param sig_inObj : sig PU internal object of the sub-object
* @return void
* @callgraph
* @callergraph
* @remarks the outgput is based on the matlab script below\n
matlab script
-------------
function makeEnhWind(alpha)
N=129; % =HFFTSIZEE_P1
s=(bilinmap(alpha,N));
h=[hann(N)'];
x=(1:N)/N;
W=interp1(x,h,s); W(1)=0;
fid=fopen('enhwind.txt','wt');
fprintf(fid,'picoos_int16 enh_wind_init(sig_innerobj_t *sig_inObj) {\n');
for i=1:N,
fprintf(fid,[' sig_inObj->enhwind[' int2str(i) '] = (picoos_single)' num2str(W(i),'%0.7g') ';\n']);
end;
fprintf(fid,' return PICO_OK;\n');
fprintf(fid,' }; \n');
fclose(fid);
%figure(1); plot(x*8,W);
*/
static void enh_wind_init(sig_innerobj_t *sig_inObj)
{
/* picoos_int16 i; */
picoos_int32 *c;
c = sig_inObj->cos_table;
c[0] = 4096;
c[1] = 4095;
c[2] = 4095;
c[3] = 4095;
c[4] = 4095;
c[5] = 4095;
c[6] = 4095;
c[7] = 4095;
c[8] = 4094;
c[9] = 4094;
c[10] = 4094;
c[11] = 4093;
c[12] = 4093;
c[13] = 4092;
c[14] = 4092;
c[15] = 4091;
c[16] = 4091;
c[17] = 4090;
c[18] = 4089;
c[19] = 4089;
c[20] = 4088;
c[21] = 4087;
c[22] = 4086;
c[23] = 4085;
c[24] = 4084;
c[25] = 4083;
c[26] = 4082;
c[27] = 4081;
c[28] = 4080;
c[29] = 4079;
c[30] = 4078;
c[31] = 4077;
c[32] = 4076;
c[33] = 4075;
c[34] = 4073;
c[35] = 4072;
c[36] = 4071;
c[37] = 4069;
c[38] = 4068;
c[39] = 4066;
c[40] = 4065;
c[41] = 4063;
c[42] = 4062;
c[43] = 4060;
c[44] = 4058;
c[45] = 4057;
c[46] = 4055;
c[47] = 4053;
c[48] = 4051;
c[49] = 4049;
c[50] = 4047;
c[51] = 4045;
c[52] = 4043;
c[53] = 4041;
c[54] = 4039;
c[55] = 4037;
c[56] = 4035;
c[57] = 4033;
c[58] = 4031;
c[59] = 4029;
c[60] = 4026;
c[61] = 4024;
c[62] = 4022;
c[63] = 4019;
c[64] = 4017;
c[65] = 4014;
c[66] = 4012;
c[67] = 4009;
c[68] = 4007;
c[69] = 4004;
c[70] = 4001;
c[71] = 3999;
c[72] = 3996;
c[73] = 3993;
c[74] = 3990;
c[75] = 3988;
c[76] = 3985;
c[77] = 3982;
c[78] = 3979;
c[79] = 3976;
c[80] = 3973;
c[81] = 3970;
c[82] = 3967;
c[83] = 3963;
c[84] = 3960;
c[85] = 3957;
c[86] = 3954;
c[87] = 3950;
c[88] = 3947;
c[89] = 3944;
c[90] = 3940;
c[91] = 3937;
c[92] = 3933;
c[93] = 3930;
c[94] = 3926;
c[95] = 3923;
c[96] = 3919;
c[97] = 3915;
c[98] = 3912;
c[99] = 3908;
c[100] = 3904;
c[101] = 3900;
c[102] = 3897;
c[103] = 3893;
c[104] = 3889;
c[105] = 3885;
c[106] = 3881;
c[107] = 3877;
c[108] = 3873;
c[109] = 3869;
c[110] = 3864;
c[111] = 3860;
c[112] = 3856;
c[113] = 3852;
c[114] = 3848;
c[115] = 3843;
c[116] = 3839;
c[117] = 3834;
c[118] = 3830;
c[119] = 3826;
c[120] = 3821;
c[121] = 3816;
c[122] = 3812;
c[123] = 3807;
c[124] = 3803;
c[125] = 3798;
c[126] = 3793;
c[127] = 3789;
c[128] = 3784;
c[129] = 3779;
c[130] = 3774;
c[131] = 3769;
c[132] = 3764;
c[133] = 3759;
c[134] = 3754;
c[135] = 3749;
c[136] = 3744;
c[137] = 3739;
c[138] = 3734;
c[139] = 3729;
c[140] = 3723;
c[141] = 3718;
c[142] = 3713;
c[143] = 3708;
c[144] = 3702;
c[145] = 3697;
c[146] = 3691;
c[147] = 3686;
c[148] = 3680;
c[149] = 3675;
c[150] = 3669;
c[151] = 3664;
c[152] = 3658;
c[153] = 3652;
c[154] = 3647;
c[155] = 3641;
c[156] = 3635;
c[157] = 3629;
c[158] = 3624;
c[159] = 3618;
c[160] = 3612;
c[161] = 3606;
c[162] = 3600;
c[163] = 3594;
c[164] = 3588;
c[165] = 3582;
c[166] = 3576;
c[167] = 3570;
c[168] = 3563;
c[169] = 3557;
c[170] = 3551;
c[171] = 3545;
c[172] = 3538;
c[173] = 3532;
c[174] = 3526;
c[175] = 3519;
c[176] = 3513;
c[177] = 3506;
c[178] = 3500;
c[179] = 3493;
c[180] = 3487;
c[181] = 3480;
c[182] = 3473;
c[183] = 3467;
c[184] = 3460;
c[185] = 3453;
c[186] = 3447;
c[187] = 3440;
c[188] = 3433;
c[189] = 3426;
c[190] = 3419;
c[191] = 3412;
c[192] = 3405;
c[193] = 3398;
c[194] = 3391;
c[195] = 3384;
c[196] = 3377;
c[197] = 3370;
c[198] = 3363;
c[199] = 3356;
c[200] = 3348;
c[201] = 3341;
c[202] = 3334;
c[203] = 3326;
c[204] = 3319;
c[205] = 3312;
c[206] = 3304;
c[207] = 3297;
c[208] = 3289;
c[209] = 3282;
c[210] = 3274;
c[211] = 3267;
c[212] = 3259;
c[213] = 3252;
c[214] = 3244;
c[215] = 3236;
c[216] = 3229;
c[217] = 3221;
c[218] = 3213;
c[219] = 3205;
c[220] = 3197;
c[221] = 3190;
c[222] = 3182;
c[223] = 3174;
c[224] = 3166;
c[225] = 3158;
c[226] = 3150;
c[227] = 3142;
c[228] = 3134;
c[229] = 3126;
c[230] = 3117;
c[231] = 3109;
c[232] = 3101;
c[233] = 3093;
c[234] = 3085;
c[235] = 3076;
c[236] = 3068;
c[237] = 3060;
c[238] = 3051;
c[239] = 3043;
c[240] = 3034;
c[241] = 3026;
c[242] = 3018;
c[243] = 3009;
c[244] = 3000;
c[245] = 2992;
c[246] = 2983;
c[247] = 2975;
c[248] = 2966;
c[249] = 2957;
c[250] = 2949;
c[251] = 2940;
c[252] = 2931;
c[253] = 2922;
c[254] = 2914;
c[255] = 2905;
c[256] = 2896;
c[257] = 2887;
c[258] = 2878;
c[259] = 2869;
c[260] = 2860;
c[261] = 2851;
c[262] = 2842;
c[263] = 2833;
c[264] = 2824;
c[265] = 2815;
c[266] = 2806;
c[267] = 2796;
c[268] = 2787;
c[269] = 2778;
c[270] = 2769;
c[271] = 2760;
c[272] = 2750;
c[273] = 2741;
c[274] = 2732;
c[275] = 2722;
c[276] = 2713;
c[277] = 2703;
c[278] = 2694;
c[279] = 2684;
c[280] = 2675;
c[281] = 2665;
c[282] = 2656;
c[283] = 2646;
c[284] = 2637;
c[285] = 2627;
c[286] = 2617;
c[287] = 2608;
c[288] = 2598;
c[289] = 2588;
c[290] = 2578;
c[291] = 2569;
c[292] = 2559;
c[293] = 2549;
c[294] = 2539;
c[295] = 2529;
c[296] = 2519;
c[297] = 2510;
c[298] = 2500;
c[299] = 2490;
c[300] = 2480;
c[301] = 2470;
c[302] = 2460;
c[303] = 2450;
c[304] = 2439;
c[305] = 2429;
c[306] = 2419;
c[307] = 2409;
c[308] = 2399;
c[309] = 2389;
c[310] = 2379;
c[311] = 2368;
c[312] = 2358;
c[313] = 2348;
c[314] = 2337;
c[315] = 2327;
c[316] = 2317;
c[317] = 2306;
c[318] = 2296;
c[319] = 2286;
c[320] = 2275;
c[321] = 2265;
c[322] = 2254;
c[323] = 2244;
c[324] = 2233;
c[325] = 2223;
c[326] = 2212;
c[327] = 2201;
c[328] = 2191;
c[329] = 2180;
c[330] = 2170;
c[331] = 2159;
c[332] = 2148;
c[333] = 2138;
c[334] = 2127;
c[335] = 2116;
c[336] = 2105;
c[337] = 2094;
c[338] = 2084;
c[339] = 2073;
c[340] = 2062;
c[341] = 2051;
c[342] = 2040;
c[343] = 2029;
c[344] = 2018;
c[345] = 2007;
c[346] = 1997;
c[347] = 1986;
c[348] = 1975;
c[349] = 1964;
c[350] = 1952;
c[351] = 1941;
c[352] = 1930;
c[353] = 1919;
c[354] = 1908;
c[355] = 1897;
c[356] = 1886;
c[357] = 1875;
c[358] = 1864;
c[359] = 1852;
c[360] = 1841;
c[361] = 1830;
c[362] = 1819;
c[363] = 1807;
c[364] = 1796;
c[365] = 1785;
c[366] = 1773;
c[367] = 1762;
c[368] = 1751;
c[369] = 1739;
c[370] = 1728;
c[371] = 1717;
c[372] = 1705;
c[373] = 1694;
c[374] = 1682;
c[375] = 1671;
c[376] = 1659;
c[377] = 1648;
c[378] = 1636;
c[379] = 1625;
c[380] = 1613;
c[381] = 1602;
c[382] = 1590;
c[383] = 1579;
c[384] = 1567;
c[385] = 1555;
c[386] = 1544;
c[387] = 1532;
c[388] = 1520;
c[389] = 1509;
c[390] = 1497;
c[391] = 1485;
c[392] = 1474;
c[393] = 1462;
c[394] = 1450;
c[395] = 1438;
c[396] = 1427;
c[397] = 1415;
c[398] = 1403;
c[399] = 1391;
c[400] = 1379;
c[401] = 1368;
c[402] = 1356;
c[403] = 1344;
c[404] = 1332;
c[405] = 1320;
c[406] = 1308;
c[407] = 1296;
c[408] = 1284;
c[409] = 1272;
c[410] = 1260;
c[411] = 1248;
c[412] = 1237;
c[413] = 1225;
c[414] = 1213;
c[415] = 1201;
c[416] = 1189;
c[417] = 1176;
c[418] = 1164;
c[419] = 1152;
c[420] = 1140;
c[421] = 1128;
c[422] = 1116;
c[423] = 1104;
c[424] = 1092;
c[425] = 1080;
c[426] = 1068;
c[427] = 1056;
c[428] = 1043;
c[429] = 1031;
c[430] = 1019;
c[431] = 1007;
c[432] = 995;
c[433] = 983;
c[434] = 970;
c[435] = 958;
c[436] = 946;
c[437] = 934;
c[438] = 921;
c[439] = 909;
c[440] = 897;
c[441] = 885;
c[442] = 872;
c[443] = 860;
c[444] = 848;
c[445] = 836;
c[446] = 823;
c[447] = 811;
c[448] = 799;
c[449] = 786;
c[450] = 774;
c[451] = 762;
c[452] = 749;
c[453] = 737;
c[454] = 725;
c[455] = 712;
c[456] = 700;
c[457] = 687;
c[458] = 675;
c[459] = 663;
c[460] = 650;
c[461] = 638;
c[462] = 625;
c[463] = 613;
c[464] = 601;
c[465] = 588;
c[466] = 576;
c[467] = 563;
c[468] = 551;
c[469] = 538;
c[470] = 526;
c[471] = 513;
c[472] = 501;
c[473] = 488;
c[474] = 476;
c[475] = 463;
c[476] = 451;
c[477] = 438;
c[478] = 426;
c[479] = 413;
c[480] = 401;
c[481] = 388;
c[482] = 376;
c[483] = 363;
c[484] = 351;
c[485] = 338;
c[486] = 326;
c[487] = 313;
c[488] = 301;
c[489] = 288;
c[490] = 276;
c[491] = 263;
c[492] = 251;
c[493] = 238;
c[494] = 226;
c[495] = 213;
c[496] = 200;
c[497] = 188;
c[498] = 175;
c[499] = 163;
c[500] = 150;
c[501] = 138;
c[502] = 125;
c[503] = 113;
c[504] = 100;
c[505] = 87;
c[506] = 75;
c[507] = 62;
c[508] = 50;
c[509] = 37;
c[510] = 25;
c[511] = 12;
c[512] = 0;
} /*enh_wind_init*/
/**
* Initializes a useful large array of random numbers
* @param sig_inObj : sig PU internal object of the sub-object
* @return void
* @callgraph
* @callergraph
*/
static void init_rand(sig_innerobj_t *sig_inObj)
{
picoos_int32 *q = sig_inObj->int_vec34;
picoos_int32 *r = sig_inObj->int_vec35;
sig_inObj->iRand = 0;
q[0] = -2198;
r[0] = 3455;
q[1] = 3226;
r[1] = -2522;
q[2] = -845;
r[2] = 4007;
q[3] = -1227;
r[3] = 3907;
q[4] = -3480;
r[4] = 2158;
q[5] = -1325;
r[5] = -3875;
q[6] = 2089;
r[6] = -3522;
q[7] = -468;
r[7] = 4069;
q[8] = 711;
r[8] = -4033;
q[9] = 3862;
r[9] = 1362;
q[10] = 4054;
r[10] = -579;
q[11] = 2825;
r[11] = 2965;
q[12] = 2704;
r[12] = -3076;
q[13] = 4081;
r[13] = 344;
q[14] = -3912;
r[14] = 1211;
q[15] = -3541;
r[15] = 2058;
q[16] = 2694;
r[16] = 3084;
q[17] = 835;
r[17] = 4009;
q[18] = -2578;
r[18] = -3182;
q[19] = 3205;
r[19] = 2550;
q[20] = -4074;
r[20] = -418;
q[21] = -183;
r[21] = -4091;
q[22] = -2665;
r[22] = -3110;
q[23] = -1367;
r[23] = 3860;
q[24] = -2266;
r[24] = -3411;
q[25] = 3327;
r[25] = -2387;
q[26] = -2807;
r[26] = -2982;
q[27] = -3175;
r[27] = -2587;
q[28] = -4095;
r[28] = 27;
q[29] = -811;
r[29] = -4014;
q[30] = 4082;
r[30] = 332;
q[31] = -2175;
r[31] = 3470;
q[32] = 3112;
r[32] = 2662;
q[33] = 1168;
r[33] = -3925;
q[34] = 2659;
r[34] = 3115;
q[35] = 4048;
r[35] = 622;
q[36] = 4092;
r[36] = -165;
q[37] = -4036;
r[37] = 697;
q[38] = 1081;
r[38] = -3950;
q[39] = -548;
r[39] = 4059;
q[40] = 4038;
r[40] = 685;
q[41] = -511;
r[41] = 4063;
q[42] = 3317;
r[42] = -2402;
q[43] = -3180;
r[43] = 2580;
q[44] = 851;
r[44] = -4006;
q[45] = 2458;
r[45] = -3276;
q[46] = -1453;
r[46] = 3829;
q[47] = -3577;
r[47] = 1995;
q[48] = -3708;
r[48] = -1738;
q[49] = -3890;
r[49] = 1282;
q[50] = 4041;
r[50] = 666;
q[51] = -3511;
r[51] = -2108;
q[52] = -1454;
r[52] = -3828;
q[53] = 2124;
r[53] = 3502;
q[54] = -3159;
r[54] = 2606;
q[55] = 2384;
r[55] = -3330;
q[56] = -3767;
r[56] = -1607;
q[57] = -4063;
r[57] = -513;
q[58] = 3952;
r[58] = -1075;
q[59] = -3778;
r[59] = -1581;
q[60] = -301;
r[60] = -4084;
q[61] = -4026;
r[61] = 751;
q[62] = -3346;
r[62] = 2361;
q[63] = -2426;
r[63] = 3299;
q[64] = 428;
r[64] = -4073;
q[65] = 3968;
r[65] = 1012;
q[66] = 2900;
r[66] = -2892;
q[67] = -263;
r[67] = 4087;
q[68] = 4083;
r[68] = 322;
q[69] = 2024;
r[69] = 3560;
q[70] = 4015;
r[70] = 808;
q[71] = -3971;
r[71] = -1000;
q[72] = 3785;
r[72] = -1564;
q[73] = -3726;
r[73] = 1701;
q[74] = -3714;
r[74] = 1725;
q[75] = 743;
r[75] = 4027;
q[76] = 875;
r[76] = -4001;
q[77] = 294;
r[77] = 4085;
q[78] = 2611;
r[78] = 3155;
q[79] = 2491;
r[79] = -3251;
q[80] = 1558;
r[80] = 3787;
q[81] = -2063;
r[81] = -3538;
q[82] = 3809;
r[82] = -1505;
q[83] = -2987;
r[83] = 2802;
q[84] = -1955;
r[84] = 3599;
q[85] = 1980;
r[85] = -3585;
q[86] = -539;
r[86] = -4060;
q[87] = -3210;
r[87] = 2543;
q[88] = 2415;
r[88] = -3308;
q[89] = 1587;
r[89] = 3775;
q[90] = -3943;
r[90] = 1106;
q[91] = 3476;
r[91] = 2165;
q[92] = 2253;
r[92] = 3420;
q[93] = -2584;
r[93] = 3177;
q[94] = 3804;
r[94] = -1518;
q[95] = -3637;
r[95] = 1883;
q[96] = 3289;
r[96] = -2440;
q[97] = -1621;
r[97] = 3761;
q[98] = 1645;
r[98] = 3751;
q[99] = -3471;
r[99] = 2173;
q[100] = 4071;
r[100] = -449;
q[101] = -872;
r[101] = -4001;
q[102] = -3897;
r[102] = 1259;
q[103] = -3590;
r[103] = 1970;
q[104] = -2456;
r[104] = -3277;
q[105] = -3004;
r[105] = 2783;
q[106] = 2589;
r[106] = 3173;
q[107] = 3727;
r[107] = -1698;
q[108] = 2992;
r[108] = 2796;
q[109] = 794;
r[109] = -4018;
q[110] = -918;
r[110] = 3991;
q[111] = 1446;
r[111] = -3831;
q[112] = 3871;
r[112] = -1338;
q[113] = -612;
r[113] = -4049;
q[114] = -1566;
r[114] = -3784;
q[115] = 672;
r[115] = -4040;
q[116] = 3841;
r[116] = 1422;
q[117] = 3545;
r[117] = -2051;
q[118] = -1982;
r[118] = -3584;
q[119] = -3413;
r[119] = 2263;
q[120] = -3265;
r[120] = -2473;
q[121] = -2876;
r[121] = -2915;
q[122] = 4094;
r[122] = -117;
q[123] = -269;
r[123] = 4087;
q[124] = -4077;
r[124] = 391;
q[125] = -3759;
r[125] = 1626;
q[126] = 1639;
r[126] = 3753;
q[127] = 3041;
r[127] = -2743;
q[128] = 5