This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Real time speech processing

Other Parts Discussed in Thread: TMS320VC5505

Hello,

I'm doing MFFC extraction from a speech signal with TMS320VC5505 eZdsp USB Stick. I managed to get correct MFCCs from a prerecorded 0,25 s speech signal. But now I need to modify my code so that the device records the sound at 16 kHz and extracts MFCCs at the same time. I suppose that that can be done with an interrupt every 1/16000 s which takes the current value of the mic and then returns to calculating the MFCCs, but I have no idea how to do this or which commands to use.

This is my code:

// verzija prilago�ena po formulama Sphinxa

#include "stdio.h"
#include "usbstk5505.h"
#include "aic3204.h"
#include "PLL.h"
#include "stereo.h"
#include "Dsplib.h"
#include "math.h"
#include "hwafft.h"

Int16 left_input;
Int16 right_input;
Int16 left_output;
Int16 right_output;
Int16 mono_input;


#define SAMPLES_PER_SECOND 16000
#define pi 3.1415926535897932385
#define nfilt 40
#define nfft 512
#define ncep 13


#define FLOAT2COS(x) (x)
#define COSMUL(x,y) ((x)*(y))
#define MIN_FIXLOG -2829416
#define FLOAT2FIX(x) FLOAT2FIX_ANY(x,DEFAULT_RADIX)
#define DEFAULT_RADIX 12
#define FLOAT2FIX_ANY(x,radix) \
	(((x)<0.0) ? \
	((long int)((x)*(float)(1<<(radix)) - 0.5)) \
	: ((long int)((x)*(float)(1<<(radix)) + 0.5)))
	
#define FIXMUL(a,b) FIXMUL_ANY(a,b,DEFAULT_RADIX)
#define FIXMUL_ANY(a,b,radix) ((long int)(((long long)(a)*(b))>>(radix)))
#define FIXLN_2		((long int)(0.693147180559945 * (1<<DEFAULT_RADIX)))
#define MIN_FIXLOG2 -4081985 /* log2(1e-300) * (1<<DEFAULT_RADIX) */


static Uint32 logtable[] = {
    (Uint32) (0 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.0223678130284545 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.0443941193584534 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.0660891904577724 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.0874628412503394 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.108524456778169 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.129283016944966 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.149747119504682 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.169925001442312 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.189824558880017 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.20945336562895 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.228818690495881 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.247927513443586 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.266786540694901 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.285402218862248 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.303780748177103 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.321928094887362 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.339850002884625 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.357552004618084 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.375039431346925 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.39231742277876 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.409390936137702 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.426264754702098 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.442943495848728 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.459431618637297 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.475733430966398 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.491853096329675 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.507794640198696 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.523561956057013 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.539158811108031 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.554588851677637 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.569855608330948 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.584962500721156 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.599912842187128 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.614709844115208 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.62935662007961 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.643856189774725 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.658211482751795 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.672425341971496 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.686500527183218 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.700439718141092 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.714245517666123 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.727920454563199 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.741466986401147 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.754887502163469 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.768184324776926 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.78135971352466 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.794415866350106 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.807354922057604 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.820178962415188 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.832890014164742 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.845490050944375 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.857980995127572 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.870364719583405 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.882643049361841 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.894817763307944 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.906890595608518 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.918863237274595 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.930737337562886 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.94251450533924 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.954196310386875 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.965784284662087 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.977279923499917 * (1 << DEFAULT_RADIX)),
    (Uint32) (0.988684686772166 * (1 << DEFAULT_RADIX)),
};

static const unsigned char fe_logadd_table[] = {
177, 177, 176, 176, 175, 175, 174, 174, 173, 173,
172, 172, 172, 171, 171, 170, 170, 169, 169, 168,
168, 167, 167, 166, 166, 165, 165, 164, 164, 163,
163, 162, 162, 161, 161, 161, 160, 160, 159, 159,
158, 158, 157, 157, 156, 156, 155, 155, 155, 154,
154, 153, 153, 152, 152, 151, 151, 151, 150, 150,
149, 149, 148, 148, 147, 147, 147, 146, 146, 145,
145, 144, 144, 144, 143, 143, 142, 142, 141, 141,
141, 140, 140, 139, 139, 138, 138, 138, 137, 137,
136, 136, 136, 135, 135, 134, 134, 134, 133, 133,
132, 132, 131, 131, 131, 130, 130, 129, 129, 129,
128, 128, 128, 127, 127, 126, 126, 126, 125, 125,
124, 124, 124, 123, 123, 123, 122, 122, 121, 121,
121, 120, 120, 119, 119, 119, 118, 118, 118, 117,
117, 117, 116, 116, 115, 115, 115, 114, 114, 114,
113, 113, 113, 112, 112, 112, 111, 111, 110, 110,
110, 109, 109, 109, 108, 108, 108, 107, 107, 107,
106, 106, 106, 105, 105, 105, 104, 104, 104, 103,
103, 103, 102, 102, 102, 101, 101, 101, 100, 100,
100, 99, 99, 99, 98, 98, 98, 97, 97, 97,
96, 96, 96, 96, 95, 95, 95, 94, 94, 94,
93, 93, 93, 92, 92, 92, 92, 91, 91, 91,
90, 90, 90, 89, 89, 89, 89, 88, 88, 88,
87, 87, 87, 87, 86, 86, 86, 85, 85, 85,
85, 84, 84, 84, 83, 83, 83, 83, 82, 82,
82, 82, 81, 81, 81, 80, 80, 80, 80, 79,
79, 79, 79, 78, 78, 78, 78, 77, 77, 77,
77, 76, 76, 76, 75, 75, 75, 75, 74, 74,
74, 74, 73, 73, 73, 73, 72, 72, 72, 72,
71, 71, 71, 71, 71, 70, 70, 70, 70, 69,
69, 69, 69, 68, 68, 68, 68, 67, 67, 67,
67, 67, 66, 66, 66, 66, 65, 65, 65, 65,
64, 64, 64, 64, 64, 63, 63, 63, 63, 63,
62, 62, 62, 62, 61, 61, 61, 61, 61, 60,
60, 60, 60, 60, 59, 59, 59, 59, 59, 58,
58, 58, 58, 58, 57, 57, 57, 57, 57, 56,
56, 56, 56, 56, 55, 55, 55, 55, 55, 54,
54, 54, 54, 54, 53, 53, 53, 53, 53, 52,
52, 52, 52, 52, 52, 51, 51, 51, 51, 51,
50, 50, 50, 50, 50, 50, 49, 49, 49, 49,
49, 49, 48, 48, 48, 48, 48, 48, 47, 47,
47, 47, 47, 47, 46, 46, 46, 46, 46, 46,
45, 45, 45, 45, 45, 45, 44, 44, 44, 44,
44, 44, 43, 43, 43, 43, 43, 43, 43, 42,
42, 42, 42, 42, 42, 41, 41, 41, 41, 41,
41, 41, 40, 40, 40, 40, 40, 40, 40, 39,
39, 39, 39, 39, 39, 39, 38, 38, 38, 38,
38, 38, 38, 37, 37, 37, 37, 37, 37, 37,
37, 36, 36, 36, 36, 36, 36, 36, 35, 35,
35, 35, 35, 35, 35, 35, 34, 34, 34, 34,
34, 34, 34, 34, 33, 33, 33, 33, 33, 33,
33, 33, 32, 32, 32, 32, 32, 32, 32, 32,
32, 31, 31, 31, 31, 31, 31, 31, 31, 31,
30, 30, 30, 30, 30, 30, 30, 30, 30, 29,
29, 29, 29, 29, 29, 29, 29, 29, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 0
};

static const int fe_logadd_table_size = sizeof(fe_logadd_table) / sizeof(fe_logadd_table[0]);

#define skaliranjeFFT 10   /* za skaliranje prevelikih brojeva u snimci,nesmije bit prevelik da ne "unisti" male brojeve.*/
#define FFT_FLAG ( 0 ) /* HWAFFT to perform FFT */
#define IFFT_FLAG ( 1 ) /* HWAFFT to perform IFFT */
#define SCALE_FLAG ( 0 ) /* HWAFFT to scale butterfly output */
#define NOSCALE_FLAG ( 1 ) /* HWAFFT not to scale butterfly output */
#define OUT_SEL_DATA ( 0 ) /* Indicates HWAFFT output located in input data vector */
#define OUT_SEL_SCRATCH ( 1 ) /* Indicates HWAFFT output located in scratch vector */

#pragma DATA_SECTION(data_buf, "data_buf");
//Static Allocation to Section: "data_buf : > DARAM" in Linker CMD File
long int data_buf[nfft];
long int *data = data_buf;

#define ALIGNMENT 2*nfft // ALIGNS data_br_buf to an address with log2(4*nfft) zeros in the
// least significant bits of the byte address
#pragma DATA_SECTION(data_br_buf, "data_br_buf");
// Allocation to Section: "data_br_buf : > DARAM" in Linker CMD File
#pragma DATA_ALIGN (data_br_buf, ALIGNMENT);
long int data_br_buf[nfft];
long int *data_br = data_br_buf;
//long int *data_br;

long int *result;
Uint16 fft_flag;
Uint16 scale_flag;
Uint16 out_sel;

Int16 *za_obradu;
Uint16 i, j, p, whichfilt, freq,sample, S=24;
float hamm, ham1=0.54, ham2=0.46, alpha=0.97;
//float pomocna[nfilt];
float lowerf=133.33334, upperf=6855.4976;
float win_prov[nfft], cccp_prov[nfft/4], sssr_prov[nfft/4];
Int16 wlen=410, spec_start[nfilt], filt_start[nfilt], filt_width[nfilt],win[nfft], cccp[nfft/4], sssr[nfft/4], fxd_alpha,za_obraditi_desni[24][nfft], tmp_old, tmp_new, tmp_old1;
Int16 realni, imaginarni, beta;
float mel_cosine[ncep][nfilt],time=0.25, factor=0.97000003;
long int za_obraditi_pomak[nfft], tmp1, tmp2, filt_coeffs[456],pomocna[nfilt],spektar[24][nfft], pms, mfcc[24][ncep];
int scale[24];
Int16 novi_desni[4090]={-11443 , -6983 , 3299 , 26372 , 32767 , 32482 , 32767 , 32625 , 32767 , 32672 , 32767 , 32681 , 32767 , 32673 , 32767 , 32619 , 32767 , 30341 , 15465 , -1221 , -9228 , -11581 , -13095 , -21935 , -31959 , -32768 , -32767 , -32753 , -32768 , -32700 , -32768 , -29455 , -26943 , -25031 , -14621 , -3720 , 2562 , 6099 , 15792 , 29969 , 32767 , 32601 , 32767 , 32685 , 32767 , 32697 , 32767 , 32690 , 32767 , 32656 , 32767 , 27739 , 22007 , 15862 , 3298 , -9131 , -15952 , -18033 , -21151 , -25208 , -26007 , -25263 , -26023 , -26879 , -25063 , -20447 , -15192 , -9336 , -2513 , 4236 , 10516 , 16120 , 19939 , 21480 , 23046 , 26801 , 30464 , 30915 , 28795 , 26976 , 25199 , 20555 , 13184 , 7126 , 4758 , 3394 , -330 , -5776 , -9874 , -11807 , -13462 , -15912 , -18292 , -19948 , -20595 , -19172 , -16294 , -14363 , -13990 , -12784 , -8810 , -3807 , -130 , 1741 , 2033 , 2343 , 4223 , 6467 , 7552 , 6390 , 3629 , 1932 , 1499 , 18 , -4845 , -11887 , -17455 , -20529 , -22430 , -24679 , -27551 , -31233 , -32768 , -32664 , -32768 , -32698 , -32768 , -32704 , -32768 , -32663 , -32768 , -31088 , -21773 , -16516 , -10567 , 6920 , 25755 , 31818 , 27094 , 25608 , 30695 , 32767 , 32633 , 32767 , 32689 , 32767 , 32706 , 32767 , 32698 , 32767 , 31441 , 20661 , 11716 , 8651 , 4240 , -4399 , -16558 , -26278 , -31831 , -32768 , -32716 , -32768 , -32730 , -32768 , -32539 , -29813 , -24282 , -17968 , -11752 , -4615 , 5772 , 16898 , 26380 , 32258 , 32767 , 32721 , 32767 , 32718 , 32767 , 32702 , 32767 , 32642 , 32767 , 30996 , 23447 , 16627 , 9238 , 1122 , -5644 , -11930 , -18189 , -22543 , -24015 , -25072 , -27348 , -29794 , -29905 , -26958 , -22091 , -16001 , -9599 , -4979 , -1255 , 4147 , 10450 , 15137 , 17671 , 19277 , 20847 , 21358 , 20905 , 21517 , 21550 , 18006 , 12846 , 10125 , 10254 , 9780 , 6227 , 723 , -4160 , -7551 , -9599 , -10565 , -12336 , -14934 , -15383 , -12930 , -9915 , -8945 , -9849 , -9783 , -7709 , -5103 , -3002 , -1479 , -626 , -371 , 499 , 2509 , 3666 , 2749 , 1227 , 576 , 438 , -868 , -3866 , -7897 , -12038 , -14762 , -15681 , -16143 , -17964 , -21042 , -22930 , -22847 , -23143 , -25665 , -30127 , -32768 , -32694 , -32768 , -32684 , -32768 , -31352 , -22641 , -15267 , -11702 , -3780 , 10238 , 20398 , 20147 , 16590 , 17355 , 19778 , 24154 , 31341 , 32767 , 32654 , 32767 , 32669 , 32767 , 32621 , 32767 , 28138 , 20682 , 17947 , 17030 , 14099 , 7111 , -987 , -6712 , -11038 , -16838 , -21891 , -22553 , -21259 , -21500 , -21794 , -20532 , -19966 , -21165 , -20670 , -15873 , -9988 , -6026 , -1795 , 4251 , 10262 , 14127 , 15962 , 17113 , 17982 , 18624 , 19695 , 20620 , 21169 , 22174 , 22494 , 20133 , 15594 , 11661 , 9119 , 6231 , 3068 , 1908 , 2628 , 2105 , -680 , -3959 , -6440 , -8177 , -9644 , -11411 , -13382 , -13960 , -12285 , -10193 , -9751 , -10210 , -9824 , -8495 , -6620 , -3421 , 977 , 4107 , 4695 , 5042 , 7232 , 9841 , 10771 , 10298 , 10341 , 11797 , 13780 , 15455 , 16302 , 15198 , 11983 , 8980 , 8363 , 8474 , 6593 , 2875 , -409 , -1465 , -1123 , -2049 , -5438 , -9716 , -12561 , -13461 , -13639 , -14283 , -15537 , -16696 , -17132 , -16882 , -16217 , -15516 , -15174 , -15043 , -14077 , -11346 , -8056 , -6177 , -5837 , -5667 , -4715 , -3673 , -3589 , -4386 , -5640 , -7677 , -11231 , -16616 , -22516 , -25706 , -24133 , -20613 , -19610 , -19156 , -12717 , -2042 , 2365 , -1449 , -4310 , -3461 , -2843 , 22 , 11157 , 23863 , 27313 , 24609 , 27065 , 32457 , 32738 , 32767 , 30819 , 30590 , 32640 , 32767 , 32442 , 27981 , 21884 , 16029 , 9297 , 2213 , -3504 , -8433 , -14290 , -19116 , -20879 , -22459 , -27236 , -31958 , -32690 , -30993 , -29641 , -27781 , -23820 , -19393 , -15781 , -11626 , -6681 , -2763 , 277 , 4491 , 9419 , 13154 , 16269 , 19669 , 21862 , 21612 , 20945 , 21513 , 21665 , 20341 , 19185 , 19130 , 18020 , 14397 , 9446 , 4850 , 1431 , -1327 , -4556 , -8374 , -11125 , -12039 , -12320 , -12940 , -13699 , -14231 , -14488 , -13985 , -11924 , -8219 , -4180 , -1170 , 1218 , 3901 , 6721 , 9104 , 10653 , 11367 , 11833 , 12890 , 14740 , 16486 , 17357 , 17370 , 16667 , 15093 , 12847 , 10640 , 8649 , 6513 , 4296 , 2284 , 209 , -2577 , -6158 , -9841 , -12913 , -14402 , -14547 , -14622 , -14926 , -14711 , -13705 , -13071 , -13399 , -13451 , -11812 , -8663 , -5371 , -2775 , -902 , 460 , 1565 , 2235 , 2158 , 1406 , 200 , -1100 , -2198 , -3704 , -7320 , -13982 , -21932 , -27745 , -29620 , -29162 , -28925 , -28409 , -25020 , -19035 , -13595 , -10751 , -10291 , -10661 , -9321 , -3959 , 5306 , 14959 , 21802 , 25870 , 29552 , 32561 , 32759 , 32767 , 32633 , 31806 , 32347 , 32767 , 31161 , 26056 , 19759 , 13182 , 6403 , 352 , -4585 , -9074 , -13115 , -15981 , -18586 , -22259 , -26490 , -29486 , -30449 , -29325 , -25729 , -20417 , -15684 , -12653 , -9822 , -6027 , -2680 , -1170 , -309 , 1657 , 4808 , 8533 , 11837 , 13594 , 13406 , 12252 , 11301 , 10755 , 10508 , 10662 , 11116 , 11445 , 11475 , 11095 , 9864 , 7677 , 5242 , 3321 , 2131 , 1842 , 2112 , 2510 , 3055 , 3207 , 2264 , 600 , -385 , -84 , 679 , 721 , 477 , 970 , 1714 , 1937 , 1978 , 3230 , 5656 , 7915 , 9508 , 10761 , 11846 , 12571 , 12515 , 11586 , 10532 , 10027 , 9703 , 9288 , 8724 , 7322 , 5046 , 2437 , -126 , -2530 , -4707 , -6071 , -6317 , -6242 , -6192 , -5675 , -4568 , -3570 , -2849 , -1936 , -900 , 194 , 1352 , 2620 , 4035 , 5378 , 6479 , 7205 , 6985 , 5302 , 2423 , -778 , -3521 , -5891 , -8368 , -11114 , -13870 , -16503 , -19107 , -21232 , -22074 , -21871 , -21943 , -22458 , -22039 , -20425 , -19201 , -18816 , -17756 , -15269 , -12341 , -9366 , -5895 , -2601 , -128 , 2269 , 4749 , 6194 , 6040 , 5636 , 5812 , 5844 , 5744 , 6244 , 6813 , 6184 , 4574 , 3192 , 2739 , 2762 , 2770 , 2697 , 2544 , 2208 , 1684 , 940 , -380 , -2100 , -3490 , -4141 , -4333 , -4101 , -3570 , -3439 , -4128 , -5428 , -7253 , -9193 , -10254 , -9981 , -8597 , -6880 , -5459 , -4439 , -3490 , -2323 , -1349 , -832 , -5 , 2207 , 5386 , 8348 , 10625 , 12110 , 12608 , 12399 , 12476 , 13306 , 14330 , 14582 , 13917 , 13159 , 13053 , 12960 , 11411 , 8624 , 5877 , 3763 , 2512 , 2365 , 2648 , 1961 , 298 , -1200 , -1603 , -1297 , -1057 , -601 , 58 , 901 , 2566 , 4930 , 6618 , 6413 , 5262 , 5200 , 6109 , 6797 , 7136 , 7469 , 7608 , 6995 , 5996 , 5822 , 5982 , 5090 , 3731 , 3050 , 3338 , 3494 , 2994 , 2745 , 2169 , 150 , -1757 , -2547 , -3424 , -4376 , -4944 , -4775 , -4272 , -4235 , -3695 , -3351 , -5408 , -7742 , -7658 , -6653 , -6139 , -5926 , -5184 , -3390 , -2719 , -3264 , -2301 , -1486 , -2132 , -2220 , -1506 , -339 , 73 , -1497 , -3161 , -4405 , -6407 , -7721 , -7927 , -8510 , -8913 , -9662 , -11409 , -12191 , -12315 , -12462 , -12119 , -13407 , -14443 , -12022 , -8872 , -6604 , -5876 , -6730 , -5774 , -3316 , -1600 , 124 , 632 , 49 , 614 , 1389 , 1778 , 1879 , 295 , -1704 , -2727 , -3326 , -2968 , -2935 , -4502 , -5697 , -6031 , -6256 , -6168 , -7205 , -8724 , -8025 , -5996 , -3543 , -1411 , -470 , 1450 , 4000 , 5513 , 7481 , 9681 , 10979 , 12176 , 12730 , 13015 , 14195 , 14549 , 13685 , 12174 , 9940 , 8851 , 8529 , 6770 , 4528 , 2328 , 181 , -1240 , -2936 , -4455 , -4982 , -5409 , -5024 , -3497 , -2393 , -1546 , -104 , 1562 , 3567 , 5318 , 5842 , 6510 , 7972 , 9370 , 11199 , 12668 , 13223 , 13627 , 13372 , 13102 , 12525 , 10568 , 8289 , 6161 , 4104 , 3003 , 2241 , 822 , -851 , -2632 , -3541 , -3824 , -4490 , -5041 , -5633 , -6135 , -6107 , -5774 , -4748 , -3368 , -3098 , -3412 , -2773 , -581 , 2017 , 3778 , 4700 , 5000 , 5097 , 4870 , 4475 , 4003 , 2675 , 1033 , 356 , 412 , 184 , -871 , -3047 , -5918 , -9084 , -12010 , -13409 , -13874 , -14666 , -15031 , -15252 , -14727 , -13318 , -12652 , -11853 , -11582 , -10538 , -7760 , -4433 , -1454 , 243 , 1327 , 3215 , 5880 , 8664 , 10503 , 10800 , 11131 , 11672 , 11987 , 10561 , 8270 , 5909 , 3927 , 2095 , 248 , -1764 , -3728 , -5963 , -9164 , -11206 , -13075 , -14459 , -15920 , -17748 , -18077 , -16608 , -15411 , -13850 , -11823 , -10260 , -7186 , -4411 , -1772 , 1345 , 3453 , 5236 , 7514 , 9196 , 11833 , 14870 , 15735 , 15976 , 15601 , 15315 , 15034 , 13396 , 10789 , 7885 , 5806 , 4054 , 2246 , 54 , -1776 , -3217 , -5777 , -8158 , -9232 , -9125 , -7736 , -6938 , -6670 , -4912 , -4584 , -3429 , -1951 , -1270 , 461 , 1941 , 3617 , 6594 , 9098 , 10756 , 12557 , 11692 , 11196 , 11203 , 11569 , 11323 , 9936 , 8251 , 7134 , 6995 , 5935 , 5551 , 4185 , 1763 , 590 , -332 , -1500 , -1906 , -4413 , -5954 , -6231 , -7893 , -6613 , -5941 , -5918 , -4475 , -3518 , -2567 , -1309 , -408 , 155 , 842 , 1200 , 2665 , 4442 , 5530 , 5288 , 5333 , 4849 , 4509 , 4472 , 2132 , 552 , -418 , -2171 , -3473 , -6158 , -9040 , -10033 , -12119 , -11462 , -10542 , -10145 , -8011 , -7785 , -7629 , -6663 , -4931 , -3152 , -1126 , 863 , 2179 , 4748 , 5233 , 5193 , 6327 , 5411 , 6515 , 8554 , 8519 , 9260 , 8291 , 6725 , 5833 , 3513 , 2008 , 95 , -2689 , -4441 , -4529 , -4066 , -4641 , -6229 , -8007 , -9130 , -8970 , -9025 , -9001 , -8374 , -7493 , -5178 , -3202 , -2003 , -694 , -407 , 78 , 841 , 2410 , 4727 , 6236 , 6870 , 7133 , 7393 , 7036 , 6089 , 4657 , 3993 , 3702 , 4314 , 4759 , 3797 , 2361 , 822 , -953 , -1965 , -2444 , -2869 , -3353 , -3959 , -3847 , -3549 , -2300 , -2635 , -2991 , -3333 , -3046 , -2219 , -1141 , -873 , -17 , 1529 , 1627 , 3223 , 3166 , 3569 , 4516 , 5218 , 5505 , 6236 , 6256 , 6589 , 6237 , 4664 , 4087 , 2905 , 1553 , 273 , -250 , -530 , -927 , -1968 , -3368 , -4500 , -5662 , -6787 , -7403 , -7453 , -7248 , -5677 , -5028 , -4173 , -3361 , -3139 , -2571 , -1919 , -1544 , -594 , 251 , 60 , 1450 , 1796 , 2827 , 3416 , 2486 , 3028 , 3793 , 4146 , 4708 , 3513 , 1957 , 1008 , -170 , -332 , -268 , -374 , -258 , 422 , 238 , -113 , -874 , -1671 , -1405 , -1687 , -1256 , -477 , -1021 , -1427 , -1376 , -1999 , -1189 , -1108 , -740 , 145 , 420 , 1567 , 2596 , 2745 , 2465 , 1717 , 1053 , 1236 , 1210 , 2164 , 2644 , 2430 , 1634 , 2179 , 2237 , 1553 , -147 , -3370 , -4345 , -4078 , -4427 , -5018 , -6469 , -8159 , -7175 , -6301 , -5189 , -3583 , -3629 , -2526 , -771 , 221 , 1807 , 2573 , 1998 , 2614 , 4036 , 5542 , 7588 , 7640 , 6398 , 5779 , 5091 , 4062 , 3486 , 1502 , 5 , -403 , -2014 , -2156 , -2941 , -3962 , -4443 , -5819 , -6900 , -7108 , -6803 , -6862 , -6675 , -7262 , -7164 , -5526 , -4095 , -2502 , -1789 , -1250 , 749 , 2082 , 3353 , 4562 , 4682 , 6152 , 6625 , 6269 , 7167 , 7285 , 6362 , 5428 , 4522 , 4505 , 4068 , 2231 , 71 , -998 , -2324 , -3915 , -5215 , -7387 , -7859 , -8737 , -9901 , -8951 , -8868 , -8200 , -7274 , -7029 , -5091 , -4129 , -3734 , -2271 , -973 , 1053 , 2518 , 3661 , 4647 , 5581 , 6695 , 7140 , 7584 , 6549 , 6439 , 6593 , 6201 , 6404 , 6106 , 6273 , 6336 , 5188 , 4949 , 3703 , 2068 , 863 , -1002 , -1082 , -1536 , -1860 , -2041 , -2842 , -3158 , -3383 , -3402 , -3779 , -3472 , -3124 , -2982 , -2134 , -1396 , -445 , 646 , 13 , -59 , 546 , 629 , 1278 , 622 , -94 , -106 , -851 , -941 , -1285 , -2344 , -2536 , -3384 , -3037 , -2615 , -3096 , -2230 , -2681 , -2589 , -1813 , -1954 , -1240 , -1010 , -672 , 835 , 1578 , 2245 , 3089 , 3288 , 3419 , 3186 , 2913 , 3358 , 4095 , 3753 , 3732 , 4566 , 4682 , 4917 , 3572 , 1029 , 305 , 49 , -304 , -152 , -952 , -2133 , -2265 , -3459 , -4799 , -5013 , -6265 , -6267 , -5865 , -6139 , -4251 , -3743 , -4757 , -4975 , -5487 , -4566 , -2600 , -1897 , -1144 , 310 , 852 , 1847 , 2682 , 2232 , 2384 , 2014 , 1199 , 1551 , 1978 , 2023 , 1115 , -299 , -778 , -651 , 19 , 540 , 382 , 817 , 845 , 795 , 1214 , 629 , 668 , 668 , 517 , 877 , 880 , 968 , 596 , -471 , -817 , -574 , -38 , 172 , 618 , 1331 , 2199 , 3561 , 3635 , 4556 , 5670 , 5599 , 6690 , 7576 , 7715 , 8498 , 7644 , 6491 , 6161 , 5287 , 4489 , 3839 , 2533 , 1282 , 1079 , 168 , -285 , -672 , -2416 , -3475 , -3437 , -3489 , -2752 , -2320 , -3084 , -3324 , -3446 , -3316 , -2101 , -1407 , -1365 , -1101 , -1081 , 315 , 1717 , 1965 , 1377 , 354 , -80 , 180 , 584 , 350 , -427 , -1046 , -1575 , -1532 , -1290 , -1818 , -2612 , -3969 , -4365 , -3714 , -2711 , -1931 , -1811 , -2275 , -2108 , -1724 , -1360 , -573 , -133 , 620 , 1110 , 1657 , 2025 , 2553 , 2745 , 2594 , 2513 , 1808 , 1420 , 1639 , 1749 , 1546 , 833 , -374 , -917 , -1949 , -3087 , -3700 , -4009 , -3445 , -3252 , -3354 , -3259 , -2938 , -2700 , -2740 , -2629 , -2581 , -2113 , -1812 , -1694 , -1080 , -895 , -670 , -498 , -958 , -1019 , -1191 , -1473 , -1262 , -909 , -273 , 268 , 1244 , 2257 , 3174 , 3519 , 2882 , 1987 , 1163 , 807 , 1175 , 1348 , 1015 , 1180 , 1332 , 1177 , 450 , -537 , -594 , 312 , 1015 , 1713 , 2739 , 3794 , 4241 , 3572 , 2551 , 2339 , 2904 , 3467 , 4275 , 4910 , 5752 , 6513 , 6266 , 5206 , 3737 , 1989 , 592 , -43 , 232 , 1152 , 972 , -114 , -994 , -1245 , -1479 , -2490 , -3989 , -4688 , -3932 , -2956 , -2543 , -2660 , -2846 , -2970 , -3035 , -2863 , -2208 , -1394 , -892 , -455 , -461 , -461 , -355 , -916 , -1883 , -2443 , -2306 , -1868 , -1785 , -1700 , -1318 , -1150 , -1218 , -1052 , -587 , -258 , -196 , -263 , -181 , -396 , -654 , -737 , -809 , -1026 , -1705 , -2378 , -2497 , -2260 , -1969 , -1763 , -1675 , -1637 , -1847 , -2003 , -1916 , -1731 , -1491 , -950 , -99 , 420 , 380 , -65 , -732 , -1349 , -1737 , -1651 , -893 , -52 , 336 , 296 , 265 , 79 , -404 , -968 , -1370 , -1381 , -1332 , -956 , -580 , -614 , -851 , -1182 , -1224 , -1048 , -980 , -642 , 119 , 930 , 1622 , 2082 , 2346 , 2301 , 2062 , 1990 , 2532 , 3174 , 3431 , 3443 , 3265 , 3214 , 3126 , 2735 , 2273 , 2149 , 2638 , 3584 , 4443 , 4674 , 4281 , 3501 , 2711 , 2281 , 2026 , 1910 , 1982 , 1948 , 2085 , 2252 , 1805 , 1067 , -94 , -1049 , -1260 , -1233 , -1077 , -976 , -1134 , -1220 , -1489 , -1881 , -1842 , -1640 , -1154 , -509 , 258 , 859 , 1176 , 1099 , 451 , -519 , -1384 , -1890 , -2243 , -2735 , -3396 , -3646 , -3576 , -3747 , -4442 , -5068 , -5173 , -5101 , -5069 , -4979 , -4335 , -3525 , -3170 , -3027 , -2655 , -1737 , -890 , -725 , -422 , 149 , 852 , 1208 , 1116 , 1113 , 1123 , 1080 , 903 , 935 , 787 , -10 , -1229 , -2606 , -3499 , -3686 , -3857 , -3953 , -3879 , -3727 , -3187 , -2837 , -2734 , -2403 , -2187 , -2103 , -1953 , -1439 , -539 , 237 , 469 , 425 , 373 , 152 , -260 , -507 , -636 , -693 , -892 , -1152 , -1014 , -779 , -920 , -1337 , -1442 , -1171 , -1037 , -1154 , -1499 , -1755 , -1750 , -1635 , -1219 , -639 , 17 , 424 , 296 , 324 , 851 , 1356 , 1594 , 1748 , 2507 , 3606 , 4731 , 5488 , 5822 , 5845 , 5689 , 5567 , 5494 , 5499 , 5502 , 5327 , 4837 , 3919 , 3132 , 2544 , 1495 , 354 , -682 , -1128 , -1310 , -1962 , -2591 , -3012 , -3322 , -3482 , -3702 , -3323 , -2425 , -1698 , -1192 , -833 , -23 , 924 , 1735 , 2531 , 2920 , 3394 , 4072 , 4542 , 5242 , 5472 , 5040 , 4169 , 2637 , 1483 , 571 , -552 , -1771 , -3316 , -4286 , -4693 , -5148 , -5891 , -7055 , -7784 , -8113 , -7851 , -6839 , -5856 , -4590 , -3690 , -2861 , -1490 , -413 , 858 , 1511 , 1785 , 2613 , 3348 , 3994 , 3841 , 3339 , 2876 , 1985 , 1893 , 1701 , 1433 , 964 , -733 , -1681 , -2437 , -2829 , -2870 , -3474 , -3230 , -2817 , -2610 , -2351 , -2240 , -1829 , -1686 , -1650 , -877 , 225 , 1117 , 1672 , 2071 , 2435 , 2708 , 2810 , 2749 , 2611 , 2542 , 2511 , 2586 , 2402 , 1927 , 1874 , 1772 , 1479 , 967 , 100 , -84 , 113 , 279 , 526 , 321 , -62 , -867 , -1621 , -1919 , -2027 , -1589 , -908 , 0 , 857 , 1343 , 1650 , 1818 , 2205 , 2943 , 3712 , 4547 , 5167 , 5584 , 5969 , 5967 , 5461 , 4498 , 3489 , 2862 , 2525 , 1957 , 965 , -485 , -2015 , -3089 , -3639 , -3792 , -4188 , -4967 , -5389 , -4926 , -3974 , -3467 , -3641 , -3773 , -3297 , -2283 , -1298 , -690 , -397 , 112 , 1123 , 2259 , 3184 , 3572 , 3625 , 3590 , 3645 , 4011 , 4411 , 4361 , 3491 , 2061 , 1032 , 507 , -112 , -1197 , -2567 , -3612 , -4031 , -4360 , -4848 , -5481 , -6117 , -6400 , -6139 , -5270 , -4368 , -3741 , -3439 , -3176 , -2577 , -1479 , -302 , 479 , 973 , 1449 , 1884 , 1985 , 1701 , 1218 , 773 , 534 , 595 , 855 , 985 , 496 , -421 , -1059 , -1148 , -696 , -224 , -292 , -530 , -559 , -399 , -297 , -627 , -1112 , -1477 , -1502 , -1082 , -288 , 610 , 952 , 829 , 798 , 1081 , 1561 , 1929 , 2016 , 2054 , 2286 , 2768 , 3323 , 3419 , 2804 , 1905 , 1445 , 1633 , 1731 , 1398 , 1009 , 1103 , 1650 , 1941 , 1675 , 1083 , 599 , 291 , 16 , -146 , 57 , 460 , 612 , 669 , 1018 , 1444 , 1652 , 1556 , 1308 , 1264 , 1468 , 1766 , 1727 , 1160 , 709 , 836 , 878 , 290 , -632 , -1230 , -1231 , -1364 , -1857 , -2245 , -2440 , -2746 , -2996 , -2826 , -2357 , -2246 , -2885 , -3537 , -3618 , -3424 , -3415 , -3392 , -2871 , -1762 , -441 , 528 , 1099 , 1400 , 1382 , 1216 , 1224 , 1844 , 2874 , 3555 , 3622 , 3261 , 2763 , 2013 , 1212 , 851 , 827 , 814 , 578 , 258 , 82 , -203 , -1085 , -2515 , -3704 , -3929 , -3478 , -3154 , -3294 , -3616 , -3715 , -3771 , -3985 , -4060 , -3773 , -3205 , -2557 , -1898 , -921 , 246 , 815 , 470 , 2 , 381 , 1482 , 2408 , 2793 , 3147 , 3566 , 3560 , 2971 , 2279 , 1807 , 1487 , 1300 , 1173 , 1068 , 995 , 901 , 662 , 207 , -247 , -366 , -288 , -300 , -235 , 114 , 201 , -310 , -931 , -1141 , -869 , -750 , -989 , -1126 , -836 , -394 , -220 , -235 , -262 , -337 , -335 , -40 , 517 , 921 , 788 , 674 , 1124 , 1658 , 1769 , 1701 , 1837 , 2009 , 2109 , 2501 , 3007 , 2824 , 1863 , 1035 , 967 , 1050 , 560 , -202 , -613 , -545 , -396 , -262 , -204 , -515 , -1075 , -1327 , -896 , -169 , -90 , -624 , -1139 , -1402 , -1501 , -1826 , -2371 , -2858 , -3145 , -3020 , -2586 , -2257 , -2265 , -2574 , -2980 , -3262 , -3081 , -2447 , -1652 , -950 , -511 , -44 , 655 , 1258 , 1531 , 1636 , 1923 , 2630 , 3625 , 4595 , 5163 , 4890 , 3779 , 2502 , 1671 , 1229 , 663 , -98 , -588 , -812 , -1292 , -2255 , -3578 , -4928 , -5910 , -6224 , -5640 , -4471 , -3535 , -3266 , -3163 , -2625 , -1777 , -1158 , -891 , -418 , 500 , 1371 , 1929 , 2342 , 2753 , 2915 , 2690 , 2619 , 3007 , 3225 , 2703 , 1890 , 1542 , 1547 , 1233 , 630 , 242 , -2 , -360 , -522 , -247 , 122 , 115 , -196 , -101 , 575 , 1118 , 1081 , 759 , 528 , 582 , 836 , 1135 , 1346 , 1241 , 1078 , 1172 , 1279 , 1090 , 663 , 178 , -66 , 43 , 258 , 370 , 195 , 14 , 28 , 49 , -47 , -265 , -504 , -782 , -966 , -911 , -698 , -489 , -356 , -172 , 173 , 509 , 546 , 417 , 224 , 212 , 573 , 1111 , 1584 , 1695 , 1554 , 1472 , 1483 , 1372 , 905 , 205 , -367 , -735 , -778 , -796 , -1073 , -1555 , -2173 , -2661 , -3045 , -3600 , -4383 , -5053 , -5211 , -4771 , -4011 , -3215 , -2497 , -1987 , -1481 , -682 , 404 , 1721 , 3000 , 3974 , 4769 , 5479 , 6120 , 6613 , 6893 , 6889 , 6663 , 6245 , 5605 , 4780 , 3671 , 2412 , 1144 , 78 , -541 , -943 , -1529 , -2445 , -3485 , -4134 , -4342 , -4338 , -4319 , -4370 , -4122 , -3563 , -2873 , -2333 , -2123 , -2072 , -1810 , -982 , 294 , 1482 , 2101 , 2230 , 2206 , 2402 , 2789 , 3009 , 2816 , 2335 , 2000 , 2081 , 2343 , 2279 , 1671 , 651 , -302 , -675 , -443 , -89 , -218 , -878 , -1544 , -1747 , -1484 , -1203 , -1207 , -1520 , -1760 , -1476 , -848 , -373 , -351 , -597 , -592 , -126 , 646 , 1375 , 1697 , 1572 , 1073 , 622 , 561 , 669 , 579 , 220 , -111 , -259 , -224 , -262 , -636 , -1236 , -1826 , -2093 , -1917 , -1515 , -1303 , -1274 , -1239 , -1179 , -1055 , -1096 , -1350 , -1532 , -1406 , -878 , -201 , 262 , 561 , 888 , 1280 , 1469 , 1243 , 742 , 288 , 124 , 22 , -275 , -794 , -1344 , -1607 , -1550 , -1296 , -1103 , -1137 , -1522 , -2067 , -2340 , -2328 , -2222 , -2150 , -1836 , -1153 , -402 , 210 , 528 , 679 , 832 , 954 , 1270 , 1989 , 2880 , 3606 , 3810 , 3554 , 3308 , 3175 , 3046 , 2828 , 2531 , 2351 , 2386 , 2545 , 2645 , 2385 , 1617 , 604 , -165 , -447 , -539 , -796 , -1276 , -1736 , -1964 , -2236 , -2723 , -3209 , -3521 , -3497 , -3040 , -2121 , -1082 , -429 , -419 , -671 , -592 , -161 , 425 , 914 , 1461 , 2372 , 3385 , 4116 , 4199 , 3717 , 3084 , 2614 , 2522 , 2674 , 2809 , 2652 , 2083 , 1282 , 380 , -487 , -1146 , -1673 , -2042 , -2327 , -2530 , -2591 , -2602 , -2647 , -2865 , -3182 , -3277 , -2875 , -2275 , -1938 , -2065 , -2424 , -2546 , -2391 , -2131 , -1909 , -1615 , -925 , 45 , 917 , 1364 , 1434 , 1381 , 1313 , 1301 , 1299 , 1187 , 939 , 695 , 385 , -179 , -1052 , -2129 , -3104 , -3745 , -3876 , -3674 , -3630 , -3946 , -4461 , -4699 , -4597 , -4256 , -3784 , -3306 , -2695 , -1867 , -956 , -339 , -62 , 14 , 173 , 544 , 992 , 1555 , 2098 , 2343 , 2173 , 1852 , 1695 , 1722 , 1670 , 1387 , 1015 , 727 , 601 , 468 , 134 , -367 , -808 , -1088 , -1200 , -1141 , -1086 , -1147 , -1278 , -1188 , -583 , 426 , 1394 , 2041 , 2524 , 3109 , 3672 , 4014 , 4054 , 3928 , 3904 , 3875 , 3840 , 3723 , 3403 , 2898 , 2226 , 1492 , 804 , 136 , -503 , -1078 , -1527 , -1877 , -2201 , -2416 , -2713 , -2937 , -2829 , -2481 , -2028 , -1679 , -1403 , -1013 , -474 , 130 , 782 , 1352 , 1730 , 1979 , 2279 , 2615 , 2827 , 2829 , 2558 , 2287 , 2218 , 2426 , 2611 , 2349 , 1647 , 787 , 87 , -385 , -828 , -1444 , -2045 , -2409 , -2465 , -2470 , -2664 , -3025 , -3341 , -3494 , -3442 , -3183 , -2821 , -2385 , -1989 , -1518 , -929 , -332 , 108 , 223 , 171 , 252 , 566 , 947 , 1112 , 965 , 639 , 313 , -13 , -404 , -898 , -1467 , -2014 , -2393 , -2472 , -2391 , -2353 , -2510 , -2688 , -2615 , -2355 , -1958 , -1630 , -1422 , -1265 , -1140 , -928 , -615 , -273 , -100 , -21 , 148 , 548 , 1124 , 1645 , 1918 , 1945 , 1968 , 2095 , 2277 , 2362 , 2287 , 1951 , 1500 , 1145 , 1030 , 1034 , 891 , 652 , 590 , 803 , 1075 , 1229 , 1140 , 1022 , 1074 , 1245 , 1514 , 1752 , 1838 , 1891 , 1966 , 2099 , 2272 , 2307 , 2152 , 1997 , 1850 , 1792 , 1849 , 1766 , 1545 , 1270 , 1101 , 976 , 736 , 454 , 167 , -74 , -239 , -321 , -261 , -253 , -314 , -270 , -150 , 114 , 367 , 503 , 533 , 502 , 603 , 763 , 862 , 909 , 831 , 818 , 1035 , 1219 , 1314 , 1160 , 847 , 535 , 249 , 29 , -359 , -817 , -1152 , -1178 , -949 , -705 , -632 , -853 , -1176 , -1526 , -1822 , -2026 , -2151 , -2056 , -1772 , -1349 , -1001 , -1039 , -1316 , -1624 , -1985 , -2343 , -2533 , -2373 , -2027 , -1763 , -1619 , -1704 , -1959 , -2253 , -2495 , -2586 , -2516 , -2348 , -2207 , -2206 , -2328 , -2493 , -2679 , -2723 , -2575 , -2170 , -1623 , -1156 , -761 , -514 , -376 , -292 , -322 , -424 , -480 , -363 , 30 , 506 , 845 , 1012 , 1033 , 959 , 729 , 464 , 224 , 90 , 143 , 292 , 549 , 723 , 679 , 493 , 283 , 111 , 124 , 343 , 710 , 1153 , 1608 , 1990 , 2190 , 2176 , 2059 , 2061 , 2170 , 2358 , 2452 , 2309 , 2026 , 1630 , 1220 , 891 , 754 , 741 , 791 , 820 , 730 , 595 , 433 , 266 , 59 , -48 , -62 , 14 , 133 , 168 , 180 , 141 , 56 , -140 , -461 , -772 , -864 , -668 , -459 , -295 , -101 , 96 , 220 , 222 , 203 , 255 , 357 , 335 , 276 , 310 , 391 , 423 , 194 , -32 , 74 , 409 , 717 , 939 , 1084 , 1075 , 976 , 791 , 727 , 801 , 933 , 968 , 890 , 946 , 1019 , 976 , 896 , 813 , 796 , 874 , 828 , 721 , 617 , 465 , 210 , -65 , -345 , -664 , -1015 , -1414 , -1750 , -2081 , -2399 , -2796 , -3198 , -3445 , -3517 , -3495 , -3587 , -3649 , -3557 , -3275 , -2947 , -2705 , -2427 , -2086 , -1576 , -902 , -215 , 400 , 890 , 1328 , 1866 , 2457 , 2889 , 3133 , 3219 , 3186 , 3068 , 2793 , 2240 , 1405 , 496 , -220 , -634 , -804 , -885 , -1086 , -1417 , -1885 , -2366 , -2607 , -2717 , -2747 , -2525 , -1967 , -1209 , -407 , 56 , 187 , 207 , 161 , 308 , 636 , 996 , 1430 , 1896 , 2280 , 2465 , 2296 , 1853 , 1415 , 1288 , 1522 , 1902 , 2225 , 2299 , 2114 , 1767 , 1183 , 433 , -365 , -982 , -1260 , -1320 , -1256 , -1168 , -1205 , -1453 , -1833 , -2213 , -2341 , -2114 , -1698 , -1205 , -863 , -689 , -537 , -453 , -333 , -178 , -69 , 92 , 408 , 706 , 773 , 569 , 186 , -178 , -466 , -688 , -858 , -842 , -660 , -520 , -495 , -483 , -486 , -585 , -657 , -507 , -89 , 372 , 746 , 929 , 922 , 842 , 755 , 773 , 862 , 1103 , 1382 , 1529 , 1497 , 1225 , 668 , -73 , -760 , -1225 , -1398 , -1414 , -1480 , -1650 , -1783 , -1939 , -2326 , -2924 , -3440 , -3608 , -3468 , -3122 , -2548 , -1831 , -1090 , -435 , 48 , 448 , 718 , 768 , 890 , 1301 , 1933 , 2586 , 2891 , 2898 , 2792 , 2661 , 2413 , 1975 , 1511 , 1177 , 948 , 621 , 274 , -60 , -473 , -1006 , -1686 , -2156 , -2172 , -1928 , -1596 , -1265 , -967 , -626 , -327 , -133 , 99 , 372 , 774 , 1314 , 1764 , 2183 , 2499 , 2623 , 2583 , 2431 , 2260 , 2067 , 1860 , 1749 , 1830 , 1776 , 1518 , 1020 , 308 , -356 , -1076 , -1747 , -2197 , -2372 , -2331 , -2287 , -2323 , -2364 , -2339 , -2238 , -2060 , -1701 , -1110 , -521 , -21 , 473 , 961 , 1290 , 1411 , 1471 , 1532 , 1684 , 1777 , 1710 , 1534 , 1172 , 673 , 67 , -592 , -1178 , -1542 , -1719 , -1914 , -2167 , -2454 , -2771 , -3035 , -3192 , -3093 , -2694 , -2239 , -1768 , -1360 , -977 , -555 , -159 , 385 , 1120 , 1944 , 2759 , 3377 , 3677 , 3760 , 3641 , 3435 , 3130 , 2821 , 2526 , 2101 , 1595 , 917 , 145 , -628 , -1323 , -1891 , -2284 , -2567 , -2786 , -3002 , -3268 , -3524 , -3797 , -3883 , -3620 , -3078 , -2422 , -1695 , -960 , -318 , 131 , 381 , 581 , 888 , 1351 , 1909 , 2576 , 3210 , 3547 , 3490 , 3201 , 2828 , 2456 , 2021 , 1473 , 893 , 269 , -395 , -912 , -1366 , -1643 , -1695 , -1693 , -1552 , -1351 , -1062 , -774 , -670 , -644 , -603 , -482 , -119 , 337 , 926 , 1554 , 1968 , 2169 , 2132 , 1970 , 1729 , 1524 , 1427 , 1459 , 1572 , 1613 , 1529 , 1172 , 597 , -56 , -619 , -1069 , -1390 , -1396 , -1104 , -791 , -538 , -224 , 317 , 1048 , 1668 , 2163 , 2618 , 2867 , 2579 , 1790 , 642 , -421 , -1083 , -1238 , -919 , -479 , 161 , 838 , 1147 , 789 , 76 , -614 , -1377 , -1938 , -2076 , -1910 , -1711 , -1875 , -2244 , -2359 , -2153 , -1846 , -1673 , -1557 , -1242 , -749 , -378 , -272 , -93 , 359 , 853 , 1024 , 896 , 1051 , 1607 , 2285 , 2857 , 3035 , 2881 , 2710 , 2547 , 2283 , 1791 , 1215 , 712 , 312 , 45 , -142 , -373 , -690 , -940 , -875 , -654 , -698 , -1110 , -1726 , -2249 , -2504 , -2523 , -2419 , -2270 , -2000 , -1503 , -919 , -452 , -310 , -444 , -618 , -643 , -450 , -249 , -51 , 219 , 527 , 817 , 989 , 982 , 767 , 489 , 373 , 319 , 282 , 352 , 588 , 992 , 1250 , 1251 , 1071 , 767 , 440 , 118 , -134 , -385 , -686 , -865 , -846 , -750 , -652 , -583 , -568 , -454 , -339 , -333 , -299 , -350 , -422 , -451 , -425 , -244 , -96 , -12 , 113 , 254 , 351 , 379 , 360 , 335 , 321 , 325 , 478 , 605 , 520 , 322 , 97 , -8 , -94 , -221 , -378 , -660 , -1014 , -1206 , -1237 , -1235 , -1224 , -1205 , -1082 , -893 , -699 , -596 , -568 , -586 , -527 , -405 , -280 , -144 , -106 , -109 , -107 , -53 , 29 , 64 , 2 , 98 , 352 , 477 , 527 , 457 , 158 , -126 , -291 , -351 , -307 , -255 , -157 , -15 , 33 , -42 , -219 , -482 , -655 , -639 , -354 , 44 , 297 , 469 , 594 , 631 , 613 , 680 , 888 , 1162 , 1445 , 1646 , 1662 , 1507 , 1213 , 814 , 461 , 203 , 0 , -145 , -274 , -453 , -674 , -888 , -998 , -916 , -868 , -903 , -783 , -676 , -671 , -791 , -1024 , -1373 , -1816 , -2105 , -2217 , -2230 , -2247 , -2291 , -2173 , -1877 , -1479 , -992 , -519 , -200 , -2 , 172 , 288 , 330 , 238 , 167 , 96 , -6 , -51 , -49 , 46 , 206 , 411 , 619 , 725 , 681 , 636 , 529 , 360 , 239 , 105 , -103 , -398 , -687 , -975 , -1078 , -1103 , -1180 , -1097 , -916 , -709 , -545 , -519 , -615 , -730 , -798 , -825 , -844 , -766 , -596 , -419 , -352 , -435 , -540 , -648 , -786 , -947 , -1030 , -941 , -717 , -512 , -280 , 45 , 234 , 278 , 355 , 501 , 688 , 769 , 903 , 1304 , 1912 , 2553 , 3101 , 3688 , 4357 , 4913 , 5132 , 4960 , 4541 , 3886 , 3060 , 2119 , 1074 , 66 , -802 , -1431 , -1753 , -1814 , -1703 , -1598 , -1525 , -1404 , -1415 , -1448 , -1456 , -1469 , -1353 , -1158 , -1001 , -853 , -671 , -245 , 417 , 1069 , 1766 , 2410 , 3018 , 3569 , 3890 , 3914 , 3627 , 3122 , 2612 , 2067 , 1454 , 715 , -96 , -828 , -1406 , -1803 , -2195 , -2572 , -2914 , -3129 , -3200 , -3371 , -3610 , -3675 , -3562 , -3357 , -2995 , -2502 , -2053 , -1666 , -1304 , -843 , -489 , -437 , -397 , -347 , -226 , 50 , 406 , 676 , 840 , 1014 , 1255 , 1434 , 1391 , 1177 , 992 , 1015 , 1049 , 1043 , 877 , 573 , 254 , -122 , -401 , -554 , -788 , -1026 , -1232 , -1349 , -1352 , -1492 , -1629 , -1678 , -1627 , -1523 , -1394 , -1144 , -899 , -704 , -623 , -506 , -203 , 95 , 342 , 411 , 390 , 444 , 497 , 620 , 755 , 827 , 890 , 1055 , 1181 , 1102 , 971 , 812 , 456 , 99 , -84 , -74 , -3 , 77 , 271 , 457 , 721 , 833 , 747 , 627 , 493 , 505 , 641 , 775 , 820 , 897 , 1076 , 1068 , 997 , 966 , 1019 , 1212 , 1368 , 1522 , 1533 , 1295 , 913 , 485 , 31 , -341 , -656 , -867 , -892 , -772 , -562 , -455 , -512 , -582 , -546 , -443 , -148 , 119 , 323 , 649 , 853 , 1019 , 1170 , 1177 , 1173 , 1183 , 1304 , 1440 , 1507 , 1486 , 1305 , 1030 , 669 , 304 , -174 , -776 , -1233 , -1568 , -1807 , -1858 , -1858 , -1891 , -1968 , -1984 , -1954 , -1840 , -1691 , -1601 , -1347 , -1081 , -740 , -319 , -67 , 118 , 305 , 409 , 527 , 658 , 709 , 864 , 1095 , 1287 , 1451 , 1385 , 1139 , 835 , 458 , 191 , 75 , -87 , -220 , -395 , -580 , -730 , -966 , -1182 , -1430 , -1646 , -1708 , -1601 , -1349 , -1119 , -944 , -838 , -818 , -714 , -606 , -496 , -396 , -329 , -181 , 21 , 196 , 313 , 431 , 537 , 696 , 867 , 906 , 895 , 877 , 779 , 763 , 788 , 759 , 673 , 518 , 452 , 464 , 438 , 430 , 392 , 339 , 451 , 636 , 938 , 1167 , 1370 , 1494 , 1541 , 1681 , 1847 , 2046 , 2193 , 2200 , 2182 , 2105 , 1832 , 1480 , 1050 , 596 , 203 , 46 , 33 , 23 , 8 , -69 , -269 , -636 , -1106 , -1374 , -1489 , -1491 , -1256 , -883 , -453 , -204 , -176 , -213 , -267 , -248 , -100 , 309 , 877 , 1233 , 1323 , 1207 , 821 , 230 , -409 , -919 , -1051 , -1003 , -960 , -923 , -1028 , -1283 , -1706 , -2155 , -2469 , -2651 , -2743 , -2714 , -2542 , -2367 , -2276 , -2310 , -2466 , -2616 , -2624 , -2573 , -2447 , -2183 , -1838 , -1364 , -827 , -407 , -235 , -185 , -225 , -294 , -386 , -343 , -223 , -160 , -184 , -327 , -660 , -1049 , -1306 , -1578 , -1727 , -1674 , -1546 , -1320 , -1125 , -1048 , -1071 , -1263 , -1457 , -1411 , -1246 , -1037 , -850 , -692 , -483 , -410 , -314 , -97 , 86 , 229 , 399 , 546 , 643 };


static float
fe_mel(float x)		// pretvorba iz frekv u mel skalu
{
    return (float) (2595.0 * log10(1.0 + x/ 700.0));
}

static float
fe_melinv(float x)    // pretvorba iz mel u frekv skalu
{
    return (float) (700.0 * (pow(10.0, x/ 2595.0) - 1.0));
}

void
compute_melcosine()
{
    float freqstep;

    freqstep = pi/nfilt;
    /* NOTE: The first row vector is actually unnecessary but we leave
     * it in to avoid confusion. */
    for (i = 0; i < ncep; i++) {
        for (j = 0; j < nfilt; j++) {
            float cosine;


            cosine = cos(freqstep * i * (j + 0.5));
            mel_cosine[i][j] = FLOAT2COS(cosine);
        }
    }
}

long int
fe_log(float x)
{
    if (x <= 0) {
        return MIN_FIXLOG;
    }
    else {
        return FLOAT2FIX(log(x));
    }
}


long int
fixlog2(Uint32 x)
{
    Uint32 y;

    if (x == 0)
        return MIN_FIXLOG2;

    /* Get the exponent. */
#if defined(__GNUC__) && defined(__i386__) 
  __asm__("bsrl %1, %0\n": "=r"(y): "g"(x):"cc");
    x <<= (31 - y);
#elif defined(__ppc__)
  __asm__("cntlzw %0, %1\n": "=r"(y):"r"(x));
    x <<= y;
    y = 31 - y;
#elif ((defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
        defined(__ARM_ARCH_5TE__)) && !defined(__thumb__))
  __asm__("clz %0, %1\n": "=r"(y):"r"(x));
    x <<= y;
    y = 31 - y;
#else
    for (y = 31; y >= 0; --y) {
        if (x & 0x80000000)
            break;
        x <<= 1;
    }
#endif
    y <<= DEFAULT_RADIX;
    /* Do a table lookup for the MSB of the mantissa. */
    x = (x >> 25) & 0x3f;
    return y + logtable[x];
}

long int
fixlog(Uint32 x)
{
    long int y;

    if (x == 0)
        return MIN_FIXLOG;

    y = fixlog2(x);
    return FIXMUL(y, FIXLN_2);
}

long int
fe_log_add(long int x, long int y)
{
    long int d, r;

    if (x > y) {
        d = (x - y) >> (DEFAULT_RADIX - 8);
        r = x;
    }
    else {
        d = (y - x) >> (DEFAULT_RADIX - 8);
        r = y;
    }
    if (d > fe_logadd_table_size)
        return r;
    else {
        r += ((long int)fe_logadd_table[d] << (DEFAULT_RADIX - 8));
/*
        printf("%d + %d = %d | %f + %f = %f | %f + %f = %f\n",
               x, y, r, FIX2FLOAT(x), FIX2FLOAT(y), FIX2FLOAT(r),
               exp(FIX2FLOAT(x)), exp(FIX2FLOAT(y)), exp(FIX2FLOAT(r)));
*/
        return r;
    }
}
void
build_melfilters()		//SPHINX
{
    float melmax, melmin, melbw, fftfreq;
    int n_coeffs;

    /* First calculate the widths of each filter. */
	
    /* Minimum and maximum frequencies in mel scale. */
    melmin = fe_mel(lowerf);
    melmax = fe_mel(upperf);

    /* Width of filters in mel scale */
    melbw = (melmax - melmin) / (nfilt + 1);

    /* DFT point spacing */
    fftfreq = SAMPLES_PER_SECOND / (float)nfft;

    /* Count and place filter coefficients. */
    n_coeffs = 0;
    for (i = 0; i < nfilt; ++i) {
        float freqs[3];

        /* Left, center, right frequencies in Hertz */
        for (j = 0; j < 3; ++j) {
            freqs[j] = fe_melinv((i + j) * melbw + melmin);
            /* Round them to DFT points if requested */
            //if (mel_fb->round_filters)
                freqs[j] = ((int)(freqs[j] / fftfreq + 0.5)) * fftfreq;
        }

        /* spec_start is the start of this filter in the power spectrum. */
        spec_start[i] = -1;
        /* There must be a better way... */
        for (j = 0; j < nfft/2+1; ++j) {
            float hz = j * fftfreq;
            if (hz < freqs[0])
                continue;
            else if (hz > freqs[2] || j == nfft/2) {
                /* filt_width is the width in DFT points of this filter. */
                filt_width[i] = j - spec_start[i];
                /* filt_start is the start of this filter in the filt_coeffs array. */
                filt_start[i] = n_coeffs;
                n_coeffs += filt_width[i];
                break;
            }
            if (spec_start[i] == -1)
                spec_start[i] = j;
        }
    }

    /* And now generate the coefficients. */
    n_coeffs = 0;
    for (i = 0; i < nfilt; ++i) {
        float freqs[3];
        /* Left, center, right frequencies in Hertz */
        for (j = 0; j < 3; ++j) {
                freqs[j] = fe_melinv((i + j) * melbw + melmin);
            /* Round them to DFT points if requested */
            //if (mel_fb->round_filters)
                freqs[j] = ((int)(freqs[j] / fftfreq + 0.5)) * fftfreq;
        }

        for (j = 0; j < filt_width[i]; ++j) {
            float hz, loslope, hislope;

            hz = (spec_start[i] + j) * fftfreq;
             // if (hz < freqs[0] || hz > freqs[2]) {
                // E_FATAL("WTF, %f < %f > %f\n", freqs[0], hz, freqs[2]);
            // } 
            loslope = (hz - freqs[0]) / (freqs[1] - freqs[0]);
            hislope = (freqs[2] - hz) / (freqs[2] - freqs[1]);
            //if (mel_fb->unit_area) {
                loslope *= 2 / (freqs[2] - freqs[0]);
                hislope *= 2 / (freqs[2] - freqs[0]);
            //}
            if (loslope < hislope) {
               filt_coeffs[n_coeffs] = fe_log(loslope);
               //filt_coeffs[n_coeffs] = loslope;
            }
            else {
                filt_coeffs[n_coeffs] = fe_log(hislope);
                //filt_coeffs[n_coeffs] = hislope;
            }
            ++n_coeffs;
        }
    }
    
}

///*
// Create arrays of twiddle factors. - SPHINX
// */
void
create_twiddle()
{
    int i;
    for (i = 0; i < nfft / 4; ++i) {
        float a = 2 * pi * i / nfft;
//        cccp[i] = cos(a);
//        sssr[i] = sin(a);
          //FIXED16
          cccp[i]=(Int16)(cos(a)*0x08000);//cccp i sssr sam promijenio
          sssr[i]=(Int16)(sin(a)*0x08000);//iz float u Int16
    }
}


int
fft_real(Int16 *o)
{
	
	int i, j, k, m, n, lz;
	Int16 x[nfft], xt, max;
	for(i=0; i<nfft;i++){
	x[i]=(Int16)o[i];//provjeriti da li je (Int16) uop�e potreban
	}
    m = 9;
    n = nfft;
    


    /* Bit-reverse the input. */
    j = 0;
    for (i = 0; i < n - 1; ++i) {
        if (i < j) {
            xt = x[j];
            x[j] = x[i];
            x[i] = xt;
        }
        k = n / 2;
        while (k <= j) {
            j -= k;
            k /= 2;
        }
        j += k;
    }
    /* Determine how many bits of dynamic range are in the input. */
    max = 0;
    for (i = 0; i < n; ++i)
        if (abs(x[i]) > max)
            max = abs(x[i]);
    /* The FFT has a gain of M bits, so we need to attenuate the input
     * by M bits minus the number of leading zeroes in the input's
     * range in order to avoid overflows.  */
    for (lz = 0; lz < m; ++lz)
        if (max & (1 << (15-lz)))
            break;

    /* Basic butterflies (2-point FFT, real twiddle factors):
     * x[i]   = x[i] +  1 * x[i+1]
     * x[i+1] = x[i] + -1 * x[i+1]
     */
    /* The quantization error introduced by attenuating the input at
     * any given stage of the FFT has a cascading effect, so we hold
     * off on it until it's absolutely necessary. */
    for (i = 0; i < n; i += 2) {
        int atten = (lz == 0);
        xt = x[i] >> atten;
        x[i]     = xt + (x[i + 1] >> atten);
        x[i + 1] = xt - (x[i + 1] >> atten);
    }

    /* The rest of the butterflies, in stages from 1..m */
    for (k = 1; k < m; ++k) {
        int n1, n2, n4;
        /* Start attenuating once we hit the number of leading zeros. */
        int atten = (k >= lz);

        n4 = k - 1;
        n2 = k;
        n1 = k + 1;
        /* Stride over each (1 << (k+1)) points */
        for (i = 0; i < n; i += (1 << n1)) {
            /* Basic butterfly with real twiddle factors:
             * x[i]          = x[i] +  1 * x[i + (1<<k)]
             * x[i + (1<<k)] = x[i] + -1 * x[i + (1<<k)]
             */
            xt = x[i] >> atten;
            x[i]             = xt + (x[i + (1 << n2)] >> atten);
            x[i + (1 << n2)] = xt - (x[i + (1 << n2)] >> atten);

            /* The other ones with real twiddle factors:
             * x[i + (1<<k) + (1<<(k-1))]
             *   = 0 * x[i + (1<<k-1)] + -1 * x[i + (1<<k) + (1<<k-1)]
             * x[i + (1<<(k-1))]
             *   = 1 * x[i + (1<<k-1)] +  0 * x[i + (1<<k) + (1<<k-1)]
             */
            x[i + (1 << n2) + (1 << n4)] = -x[i + (1 << n2) + (1 << n4)] >> atten;
            x[i + (1 << n4)]             =  x[i + (1 << n4)] >> atten;
            
            /* Butterflies with complex twiddle factors.
             * There are (1<<k-1) of them.
             */
            for (j = 1; j < (1 << n4); ++j) {
                Int16 cc, ss, t1, t2;
                int i1, i2, i3, i4;

                i1 = i + j;
                i2 = i + (1 << n2) - j;
                i3 = i + (1 << n2) + j;
                i4 = i + (1 << n2) + (1 << n2) - j;

                /*
                 * cc = real(W[j * n / (1<<(k+1))])
                 * ss = imag(W[j * n / (1<<(k+1))])
                 */
                cc = cccp[j << (m - n1)];
                ss = sssr[j << (m - n1)];

                /* There are some symmetry properties which allow us
                 * to get away with only four multiplications here. */
                {
                    long int tmp1, tmp2;
                    tmp1 = (long int)x[i3] * cc + (long int)x[i4] * ss;
                    tmp2 = (long int)x[i3] * ss - (long int)x[i4] * cc;
                    t1 = (Int16)(tmp1 >> 15) >> atten;
                    t2 = (Int16)(tmp2 >> 15) >> atten;
                }

                x[i4] = (x[i2] >> atten) - t2;
                x[i3] = (-x[i2] >> atten) - t2;
                x[i2] = (x[i1] >> atten) - t1;
                x[i1] = (x[i1] >> atten) + t1;
            }
        }
    }

    for(i=0; i<nfft;i++){
		o[i]=(Int16)x[i];//provjeriti da li je (Int16) oup�e potrebno
    }
    return lz;
}
/* ------------------------------------------------------------------------ *
 *                                                                          *
 *  main( )                                                                 *
 *                                                                          *
 * ------------------------------------------------------------------------ */
void main( void ) 
{

    /* Initialize BSL */
    USBSTK5505_init( );
	
	/* Initialize PLL */
	pll_frequency_setup(100);

    /* Initialise hardware interface and I2C for code */
    aic3204_hardware_init();
    
    /* Initialise the AIC3204 codec */
	aic3204_init(); 

    /* izvodenje*/
    printf("izvodenje je pocelo \n");
    
	
	/* Setup sampling frequency and 0dB gain for microphone */
    set_sampling_frequency_and_gain(SAMPLES_PER_SECOND, 0);	
  
    
   //Postavljanje elemenata matrica na 0
	for ( sample = 0 ; sample < nfft ; sample++ ){
        //pomocna[sample]=0;
        win[sample]=0;
    }

   
    // izgradnje mel filtara
	build_melfilters();
   
   
    //Izgradnja Hammingovog prozora - SPHINX
    for (i=0 ; i < wlen/2 ; i++){
   		hamm=ham1-ham2*cos(2*pi*(i)/(wlen-1)); 
   		//FIXED16
   		win[i]=(Int16)(hamm*0x08000);//njemu je win Int16 pa sam i ja promijenio
    }
   

	compute_melcosine();

	//Snimanje i spremanje u matricu
	//for(i=0 ; i < 5 ; i++)
	
	create_twiddle();
	
	while(1)
	{
		for ( sample = 0 ; sample < nfft ; sample++ ){
			for ( i = 0 ; i < S ; i++ ){
				za_obraditi_desni[i][sample]=0;
			}
		}
			//Snima se 0.5 sekunda -> 0.5L
    	// for ( i = 0  ; i < SAMPLES_PER_SECOND * time  ;i++ )
 		// {

     	// aic3204_codec_read(&left_input, &right_input); // Configured for one interrupt per two channels.
   
     	// mono_input = stereo_to_mono(left_input, right_input);
     	
     	// novi_desni[i]= mono_input;
 		// }
				

        S=0; //brojac dijelova audio signala
   		for (j=0; j+wlen < 4091 ; j=j+160)
    	{
    		for(i=0; i<wlen ; i++){
    			za_obraditi_desni[S][i]=novi_desni[j+i];
    		}
        	S++;
        }
		//S--;
		za_obradu = &za_obraditi_desni[0][0];
		
		
		// pre-emphisis - SPHINX3 FIXED16
		tmp_old=0;
		fxd_alpha = (Int16)(factor * 0x8000);
		for(j=0; j < S; j++){
			if(j!=0){
				tmp_old=tmp_old1;
			}
			if(j==23){
				wlen=320;
			}
			for (i = 0; i < wlen; i++){
				tmp_new=za_obraditi_desni[j][i];
				tmp1 = (long int)za_obraditi_desni[j][i]<<15;
				tmp2 = (long int)tmp_old*fxd_alpha;
				za_obraditi_desni[j][i] = (Int16)((tmp1-tmp2)>>15);
				//za_obraditi_desni[j][i] = za_obraditi_desni[j][i] - tmp_old * alpha;//za float
				tmp_old=tmp_new;
				if(i == 160-1){
					tmp_old1=tmp_new;
				}
			}
		}


		wlen=410;
        //Mno�enje uzoraka sa Hammingovim prozorom FIXED16
		for (i = 0 ; i < S ; i++){
           	for (j = 0 ; j < wlen/2 ; j++){
           		
           		tmp1=(long int)za_obraditi_desni[i][j]*win[j];
           		tmp2=(long int)za_obraditi_desni[i][wlen-1-j]*win[j];
           		za_obraditi_desni[i][j]=(Int16)(tmp1>>15);
           		za_obraditi_desni[i][wlen-1-j]=(Int16)(tmp2>>15);

           	}
        }
		
// 		// HWAFFT
//		// data = &za_obraditi_pomak[0];
//		 fft_flag = FFT_FLAG;
//		 scale_flag = NOSCALE_FLAG;
//		 for(i = 0 ; i < S ; i++){
//			 for (j = 0 ; j < nfft ; j++){
//           		// za_obraditi_desni[i][j]=za_obraditi_desni[i][j]/skaliranjeFFT;
//           		 data_buf[j]=(long int)za_obraditi_desni[i][j] << 16;
//           	 }
//			 /* Bit-Reverse 1024-point data, Store into data_br, data_br aligned to
//			 12-least significant binary zeros*/
//			 hwafft_br((Int32*)data, (Int32*)data_br, nfft); 
//			 /* bit-reverse input data,Destination buffer aligned */
//			 /* Compute 1024-point FFT, scaling enabled. */
//			 out_sel = hwafft_512pts((Int32*)data_br, (Int32*)data, fft_flag, scale_flag);
//			 if (out_sel == OUT_SEL_DATA) {
//				 result = data_br;
//			 }else {
//				 result = data;
//			 }
//			
//			//apsolutna vrijednost i kvadrat svakog elementa matrice
//			 for(p=0; p < nfft; p++){
//				 realni=((Int16*)result)[p*2];
//				 imaginarni=((Int16*)result)[p*2+1];
//				 za_obraditi_desni[i][p]= (float)powi((double)realni,(double)2)+powi((double)imaginarni,(double)2);
//			 }
//		 }
		
		// Software FFT - SPHINX FIXED16
		for(p=0; p < S; p++){
			za_obradu=&za_obraditi_desni[p][0];
			scale[p]=fft_real(za_obradu);
		}
		
		//spektar snage FIXED16
		
		for(p=0; p < S; p++){
			scale[p] = 9 - scale[p];
			spektar[p][0]= fixlog(abs(za_obraditi_desni[p][0])<<scale[p])*2;
			//testni[0]= fixlog(abs(za_obraditi_desni[p][0])<<scale[p])*2;
			for(j=1; j < nfft/2; j++){
				long int rr, ii;
        		rr = fixlog((long int)abs(za_obraditi_desni[p][j]) << scale[p]) * 2;
        		ii = fixlog((long int)abs(za_obraditi_desni[p][nfft-j]) << scale[p]) * 2;
        		spektar[p][j] = fe_log_add(rr, ii);
			}
		}
		
	
		
		/* Mno�enje sa mel fitrima - SPHINX FIXED_POINT*/
		for(j=0; j < S; j++){
			for (whichfilt = 0; whichfilt < nfilt; whichfilt++) {
				int spec_start1, filt_start1, i;

				spec_start1 = spec_start[whichfilt];
				filt_start1 = filt_start[whichfilt];

	    		pomocna[whichfilt] = spektar[j][spec_start1] + filt_coeffs[filt_start1];
        		for (i = 1; i < filt_width[whichfilt]; i++) {
            		pomocna[whichfilt] = fe_log_add(pomocna[whichfilt],spektar[j][spec_start1 + i] + filt_coeffs[filt_start1 + i]);	
				
				}

			}
			for(p=0; p < nfilt; p++){
				spektar[j][p]= pomocna[p];
			}
		}
		

		// Diskretna kosinusna transformacija DCT - FIXED_POINT
		for(i=0; i < S; i++){
			for(j=0; j < ncep; j++){
				mfcc[i][j] = 0;
			}
		}


		for(p=0; p < S; p++){
			/* Compute C0 separately (its basis vector is 1) to avoid
			 * costly multiplications. */
			mfcc[p][0] = spektar[p][0] / 2; /* beta = 0.5 */
			for (j = 1; j < nfilt; j++){
			mfcc[p][0] += spektar[p][j]; /* beta = 1.0 */   // dobivanje snage bloka
			}
			mfcc[p][0] /= (Int16) nfilt;  //dijeljenje dobivene snage sa brojem filtara

			for (i = 1; i < ncep; ++i) {
				mfcc[p][i] = 0;
				for (j = 0; j < nfilt; j++) {
					if (j == 0)
						beta = 1;       /* 0.5 */
					else
						beta = 2;       /* 1.0 */
					mfcc[p][i] += COSMUL(spektar[p][j],mel_cosine[i][j]) * beta;
				}
			/* Note that this actually normalizes by num_filters, like the
			 * original Sphinx front-end, due to the doubled 'beta' factor
			 * above.  */
				mfcc[p][i] /= (Int16) nfilt * 2;
			}
		}
	}
	
}

/* ------------------------------------------------------------------------ *
 *                                                                          *
 *  End of main.c                                                           *
 *                                                                          *
 * ------------------------------------------------------------------------ */

 

Thank you in advance.

  • Hi,

     

    There is an I2S interrupt example available in CSL 2.5 release CSLv2.5\c55xx_csl\ccs_v4.0_examples\i2s\CSL_I2S_INTCExample  from http://processors.wiki.ti.com/index.php/C5000_Chip_Support_Library.

    Regards,

    Hyun

  • I downloaded the examples and tried the one you told me to, but when i run the example, at the end i get the message:

    CSL I2S INTERRUPT MODE TEST!

    I2S Module Instance Open Successful
    I2S Module Configuration Successful
    I2S Write Successful
    I2S Read Successful
    I2S Reset Successful
    I2S Close Successful
    I2S Read & Write Buffers doesn't Match!!!

    CSL I2S INTERRUPT MODE TEST FAILED!!

    I tried to follow the instructions in the CLS API Reference Gudie http://www.ti.com/litv/pdf/spru433j, but it seems out of date and I still couldn't make it work.

    I also tried to include the headers (#include "csl_intc.h") and library files from CSL into my project, but when i compile my project, I get errors:

    **** Build of configuration Debug for project MFCC ****

    C:\Program Files\Texas Instruments\ccsv4\utils\gmake\gmake -k all
    'Building file: ../main.c'
    'Invoking: Compiler'
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/bin/cl55" -v5505 -g --include_path="C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include" --include_path="C:/Program Files/C55 Low Power Chip Support Library v2.50.00/c55xx_csl/inc" --include_path="C:/Program Files/C55 Low Power Chip Support Library v2.50.00/c55xx_csl/src" --include_path="C:/Program Files/C55 Low Power Chip Support Library v2.50.00/c55xx_csl/ccs_v4.0_examples/cslVC5505" --include_path="C:/Program Files/C55 Low Power Chip Support Library v2.50.00/c55xx_csl/ccs_v4.0_examples/cslVC5505/Debug" --diag_warning=225 --ptrdiff_size=32 --memory_model=huge --preproc_with_compile --preproc_dependency="main.pp"  "../main.c"
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 36: error: duplicate specifier in declaration
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 36: warning: declaration requires a typedef name

    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 37: error: duplicate specifier in declaration
    >> Compilation failure
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 37: error: duplicate specifier in declaration
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 37: warning: declaration requires a typedef name
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 38: error: duplicate specifier in declaration
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 38: error: invalid combination of type specifiers
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 41: warning: declaration requires a typedef name
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 42: error: duplicate specifier in declaration
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 42: warning: declaration requires a typedef name
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include/tistdtypes.h", line 43: error: invalid combination of type specifiers
    "../main.c", line 323: warning: function declared implicitly
    "../main.c", line 393: warning: pointless comparison of unsigned integer with zero
    7 errors detected in the compilation of "../main.c".
    gmake: *** [main.obj] Error 1
    gmake: Target `all' not remade because of errors.
    Build complete for project MFCC

    Also, the reference guide says that the header for the interrupt controller is cls_irq.h. I couldn'r find that file so I included csl_intc.h instead. I also included the library to thesearch path.

    Since this example wasn't useful to me, i was wondering if it would be possible tojust modify this solution for my needs: http://e2e.ti.com/support/dsp/tms320c5000_power-efficient_dsps/f/109/p/103370/367126.aspx

    By replacing

    DMA_start(hDmaXmt);

    with my commands for sound sampling and changing the timer setting, could this be used for real-time sound processing?