[Speex-dev] Speex Windows from 1.1.6 source
Jean-Marc Valin
Jean-Marc.Valin at USherbrooke.ca
Thu Jul 21 10:03:15 PDT 2005
Same answer as anyone else: start from the sampleenc/sampledec examples
in the manual.
Jean-Marc
Le mercredi 20 juillet 2005 à 15:41 -0500, Palani Selvam a écrit :
> 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.
>
> _______________________________________________
> Speex-dev mailing list
> Speex-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev
--
Jean-Marc Valin <Jean-Marc.Valin at USherbrooke.ca>
Université de Sherbrooke
More information about the Speex-dev
mailing list