#include #include #include /*The frame size in hardcoded for this sample code but it doesn’t have to be*/ #define FRAME_SIZE 160 int main(int argc, char **argv) { char *inFile; char *outFile; FILE *fin; FILE *fout; short in[FRAME_SIZE]; short input[FRAME_SIZE]; char cbits[200]; int nbBytes; /*Holds the state of the encoder*/ void *state; /*Holds bits so they can be read and written to by the Speex routines*/ SpeexBits bits; int i, tmp; int rate=8000; /*Create a new encoder state in narrowband mode*/ state = speex_encoder_init(&speex_nb_mode); /*Set the quality to 8 (15 kbps)*/ tmp=8; speex_encoder_ctl(state, SPEEX_SET_QUALITY, &tmp); rate=8000; speex_encoder_ctl(state, SPEEX_SET_SAMPLING_RATE, &rate); inFile = argv[1]; outFile = argv[2]; fin = fopen(inFile, "r"); fout = fopen(outFile, "w"); /*Initialization of the structure that holds the bits*/ speex_bits_init(&bits); /******THIRU : SKIP THE WAV HEADER FORMAT******/ fseek(fin,64,SEEK_SET); while (1) { /*Read a 16 bits/sample audio frame*/ fread(in, sizeof(short), FRAME_SIZE, fin); if (feof(fin)) break; /*Copy the 16 bits values to float so Speex can work on them*/ for (i=0;i