[Speex-dev] Speex Windows from 1.1.6 source
Palani Selvam
pselvam at sta.samsung.com
Wed Jul 20 13:41:59 PDT 2005
Hi All,
I am using Speex for encoding/decoding the audio stream for
my streaming application. I have used almost the same code
In the sampleenc.c and sampledec.c, except that I have used
The buffers from the mic as input for encoder and encoded audio
As input for decoder, instead of files input.
My Problem is the audio played on the receiving side after decoding
Is only a "hush" or it is pure noise.
Below is my code, that I have used for encoding and decoding.
/************** Encode ******************/
speex_bits_reset(&Encbits);
psInput = (short *)InputBuf;
iIndex = 80;
memset(OutputBuf,0,(200 * sizeof(float)));
/*Copy the 16 bits values to float so Speex can work on them*/
for (i=0;i<iIndex;i++){
/* float */pfEncBuf[i]=/* short */psInput[i];
}
/*Encode the frame*/
speex_encode(encState,pfEncBuf, &Encbits);
memset(OutputBuf,0,outputSize);
/*Copy the bits to an array of char that can be written*/
iEncBytes = speex_bits_write(&Encbits, OutputBuf, outputSize);
return iEncBytes;
/**************** Decode ******************/
/* Flush all the bits in the struct so we can code a new frame */
speex_bits_reset(&Decbits);
/* Copy the data into the bit-stream struct */
speex_bits_read_from(&Decbits, InputBuf, InputSize);
/* Get the Size of the Decoded Frame */
speex_decoder_ctl(decState, SPEEX_GET_FRAME_SIZE, &iDecBytes);
if(iIndex > outputSize)
return -1;
iIndex = iDecBytes/sizeof(short);
/* Allocate the Decode Frame */
memset(pfDecBuf,0,sizeof(200 * sizeof(float)));
/* Decode the data */
speex_decode(decState, &Decbits, pfDecBuf);
memset(OutputBuf,0,outputSize);
psOutput = (short *)OutputBuf;
/* Copy from float to short (16 bits) for output */
for (i=0;i<iIndex;i++)
psOutput[i]=(short) pfDecBuf[i];
return iDecBytes;
I tried encoding, decoding and playing on the
Same , the results are the same. I am not sure
If I am missing something here.Any Light on this is
much appreciated.
Thanx,
Palani.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20050720/22472a5c/attachment.html
More information about the Speex-dev
mailing list