hy,<br><br>recording and playback is working perfectly without speex.<br><br>i have try to set samplerat from 6000 to 441000 and quality from 1 to 10 sam with complexy, but the best i can get is with 16000 samplerate, 5quality and 3complexy .. but still, the voice that came out is annoying, artificial, robot ,... <br>
<br clear="all">Lp, Tim<br>+--------------------------+<br>| email: <a href="mailto:rico@gama.us">rico@gama.us</a> |<br>| www: <a href="http://gama.us">http://gama.us</a> |<br>|--------------------------|<br>| tel: 00386 31 457 627 |<br>
+--------------------------+<br><br>
<br><br><div class="gmail_quote">2009/9/3 <span dir="ltr"><<a href="mailto:speex-dev-request@xiph.org">speex-dev-request@xiph.org</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Send Speex-dev mailing list submissions to<br>
<a href="mailto:speex-dev@xiph.org">speex-dev@xiph.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.xiph.org/mailman/listinfo/speex-dev" target="_blank">http://lists.xiph.org/mailman/listinfo/speex-dev</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:speex-dev-request@xiph.org">speex-dev-request@xiph.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:speex-dev-owner@xiph.org">speex-dev-owner@xiph.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Speex-dev digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: voice sound like robot voice :) (Greger Burman)<br>
2. Re: voice sound like robot voice :) (Tim Rijavec)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 3 Sep 2009 10:21:49 +0200<br>
From: Greger Burman <<a href="mailto:greger@mobile-robotics.com">greger@mobile-robotics.com</a>><br>
Subject: Re: [Speex-dev] voice sound like robot voice :)<br>
To: <a href="mailto:speex-dev@xiph.org">speex-dev@xiph.org</a><br>
Message-ID:<br>
<<a href="mailto:18b67100909030121w2ef10d34j2c44b81f716924d6@mail.gmail.com">18b67100909030121w2ef10d34j2c44b81f716924d6@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hi Tim!<br>
<br>
I haven't looked at your code. I would first make sure that recording and<br>
playback of audio is working perfectly without the encoder. Bugs in the<br>
handling of recording or playback can result in strange noises.<br>
<br>
cheers<br>
Greger<br>
<br>
<br>
2009/9/2 Tim Rijavec <<a href="mailto:rico@gama.us">rico@gama.us</a>><br>
<br>
> hy,<br>
><br>
> here is my speex encoder/decoder .. the sampleRate i use is 16000 and<br>
> quality,complexity are at 5.<br>
><br>
> can someone take a look in to the code and see if there is something that<br>
> is making that robot voice<br>
><br>
> here is a link to colored and numbered code, same as below<br>
> <a href="http://barvanjekode.gama.us/temp/1257361243.html" target="_blank">http://barvanjekode.gama.us/temp/1257361243.html</a><br>
><br>
> thanx.<br>
><br>
> code<br>
> -----------------------<br>
> #include "codec.h"<br>
><br>
> /////////////////////////////////////////////////////////////////<br>
> // Constants<br>
> /////////////////////////////////////////////////////////////////<br>
> #define Cvoicecodecrawbuffersize 16 * Ckilobyte<br>
><br>
> /////////////////////////////////////////////////////////////////<br>
> //<br>
> // TVoiceCodec<br>
> //<br>
> /////////////////////////////////////////////////////////////////<br>
> TVoiceCodec::TVoiceCodec() :<br>
> pMode( NULL ),<br>
> pPreprocessorState( NULL ),<br>
> pCodecEncoderState( NULL ),<br>
> encoderQuality( 5 ),<br>
> encoderComplexity( 3 ),<br>
> encoderFrameSize( 0 ),<br>
> encodedFrameBytes( 0 ),<br>
> pCodecDecoderState( NULL ),<br>
> sampleRate( VOICE_SAMPLE_RATE ),<br>
> decoderFrameSize( 0 )<br>
> {<br>
> /////////////////////////////////////////////////////////////////<br>
> // Prepare buffers<br>
> /////////////////////////////////////////////////////////////////<br>
> uint voicememsize = Cvoicecodecrawbuffersize + CODEC_MAX_BUFFER_SIZE;<br>
> byte *voicemem = (byte*)pMemoryMng->Alloc(voicememsize);<br>
> memset( voicemem, 0, voicememsize );<br>
><br>
> // raw voice input buffer<br>
> pCodecRawBuffer = voicemem;<br>
> pCodecRawBufferCur = pCodecRawBuffer;<br>
> //<br>
> voicemem += Cvoicecodecrawbuffersize;<br>
><br>
> // input/output voice buffer<br>
> pCodecBuffer = voicemem;<br>
> }<br>
><br>
><br>
> TVoiceCodec::~TVoiceCodec()<br>
> {<br>
> if ( pCodecEncoderState )<br>
> {<br>
> speex_preprocess_state_destroy( pPreprocessorState );<br>
> speex_encoder_destroy( pCodecEncoderState );<br>
> speex_bits_destroy( &codecBits );<br>
> pCodecEncoderState = NULL;<br>
> }<br>
><br>
> if ( pCodecDecoderState )<br>
> {<br>
> speex_decoder_destroy( pCodecDecoderState );<br>
> speex_bits_destroy( &codecBits );<br>
> pCodecDecoderState = NULL;<br>
> }<br>
> }<br>
><br>
><br>
> void TVoiceCodec::setSampleRate( int samplerate )<br>
> {<br>
> sampleRate = samplerate;<br>
><br>
> // determine the mode<br>
> int modeID = -1;<br>
><br>
> // speex has limits [6000 - 48000]<br>
> if ( sampleRate > 48000 )<br>
> return;<br>
><br>
> if ( sampleRate > 25000 )<br>
> modeID = SPEEX_MODEID_UWB;<br>
> else if ( sampleRate > 12500 )<br>
> modeID = SPEEX_MODEID_WB;<br>
> else if ( sampleRate >= 6000 )<br>
> modeID = SPEEX_MODEID_NB;<br>
> else<br>
> return;<br>
><br>
> // set up mode<br>
> pMode = speex_lib_get_mode( modeID );<br>
> }<br>
><br>
> void TVoiceCodec::setupEncoder( uint quality, uint complexity )<br>
> {<br>
> encoderQuality = quality;<br>
> encoderComplexity = complexity;<br>
><br>
> // catch invalid sample rates resulting in invalid mode<br>
> if ( !pMode )<br>
> return;<br>
> //<br>
> assert( ( pCodecEncoderState == NULL ) && "encoder already initialized"<br>
> );<br>
> //<br>
> int enabled = 1;<br>
> int disabled = 0;<br>
> //<br>
> float highpass = 80;<br>
><br>
> // setup encoder<br>
> pCodecEncoderState = speex_encoder_init( pMode );<br>
> //<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_SAMPLING_RATE,<br>
> &sampleRate );<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_COMPLEXITY,<br>
> &encoderComplexity );<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_QUALITY,<br>
> &encoderQuality );<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_VBR,<br>
> &disabled );<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_DTX,<br>
> &disabled );<br>
><br>
> // init encoder<br>
> speex_bits_init( &codecBits );<br>
> speex_bits_reset( &codecBits );<br>
><br>
> // determine encoded bytes per frame with spx_int16_t type, speex can<br>
> work with float;s, but not in this engine<br>
> speex_encode_int( pCodecEncoderState, (spx_int16_t*)pCodecBuffer,<br>
> &codecBits );<br>
> encodedFrameBytes = (uint)speex_bits_nbytes( &codecBits );<br>
><br>
> // setup preprocessor<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_GET_FRAME_SIZE,<br>
> &encoderFrameSize );<br>
> //<br>
> pPreprocessorState = speex_preprocess_state_init( encoderFrameSize,<br>
> sampleRate );<br>
> //<br>
> speex_preprocess_ctl( pPreprocessorState, SPEEX_PREPROCESS_SET_DENOISE,<br>
> &enabled );<br>
> speex_preprocess_ctl( pPreprocessorState, SPEEX_PREPROCESS_SET_VAD,<br>
> &disabled );<br>
> }<br>
><br>
> void TVoiceCodec::setupDecoder()<br>
> {<br>
> // catch invalid sample rates resulting in invalid mode<br>
> if ( !pMode )<br>
> return;<br>
> //<br>
> assert( ( pCodecDecoderState == NULL ) && "decoder already initialized"<br>
> );<br>
> //<br>
> int enabled = 1;<br>
> //<br>
> pCodecDecoderState = speex_decoder_init( pMode );<br>
> speex_decoder_ctl( pCodecDecoderState, SPEEX_SET_SAMPLING_RATE,<br>
> &sampleRate );<br>
> speex_decoder_ctl( pCodecDecoderState, SPEEX_GET_FRAME_SIZE,<br>
> &decoderFrameSize );<br>
> speex_decoder_ctl( pCodecDecoderState, SPEEX_SET_ENH,<br>
> &enabled );<br>
> //<br>
> speex_bits_init( &codecBits );<br>
> }<br>
><br>
> uint TVoiceCodec::encode( byte *rawsoundbuffer, uint length, char<br>
> *bitbuffer, float gain )<br>
> {<br>
> if( !pCodecEncoderState )<br>
> return 1;<br>
><br>
> // copy raw voice data to temporary codec raw voice data buffer<br>
> memcpy( pCodecRawBufferCur, rawsoundbuffer, length );<br>
> pCodecRawBufferCur += length;<br>
><br>
> // determine the size of data<br>
> uint buffersize = (int)( pCodecRawBufferCur - pCodecRawBuffer );<br>
><br>
> // do we have enough data for encoding?<br>
> if ( buffersize < encoderFrameSize )<br>
> {<br>
> //pLog->Add("codec: encoder: return: buffersize: %d: needtoencode<br>
> %d", buffersize, encoderFrameSize);<br>
> return 0;<br>
> }<br>
><br>
> int encodedbytes = 0;<br>
> int pos = 0;<br>
> // while we have enough data<br>
> while( (uint)( pCodecRawBufferCur - pCodecRawBuffer ) >=<br>
> encoderFrameSize )<br>
> {<br>
> // copy data from temporary buffer to codec buffer<br>
> memcpy( pCodecBuffer, pCodecRawBuffer, encoderFrameSize );<br>
><br>
> // move memory of temporary buffer<br>
> memmove( pCodecRawBuffer, pCodecRawBuffer + encoderFrameSize,<br>
> buffersize - ( pos + encoderFrameSize ) );<br>
> pCodecRawBufferCur -= encoderFrameSize;<br>
><br>
> // increase current pos<br>
> pos += encoderFrameSize;<br>
><br>
> //encode<br>
> speex_bits_reset( &codecBits );<br>
> //<br>
> speex_encode_int( pCodecEncoderState, (spx_int16_t*)pCodecBuffer,<br>
> &codecBits );<br>
> //<br>
> int nb = speex_bits_nbytes( &codecBits );<br>
> encodedbytes += speex_bits_write( &codecBits,<br>
> &bitbuffer[encodedbytes], nb );<br>
> }<br>
><br>
> //pLog->Add("buffersize: %d: total left: %d enc buffersize: %d", length,<br>
> inputBufferArray.Count(), encodedbytes );<br>
> return encodedbytes;<br>
> }<br>
><br>
> uint TVoiceCodec::decode( char *bitbuffer, uint length, byte *samplearray,<br>
> float gain )<br>
> {<br>
> // return if decoder is not initialized<br>
> if( !pCodecDecoderState )<br>
> return 0;<br>
><br>
> // return if there is not enough data to decode<br>
> if ( length < encodedFrameBytes )<br>
> return 0;<br>
><br>
> int buffersize = length;<br>
> uint decodedbytes = 0;<br>
> int pos = 0;<br>
> //<br>
> while( (int)buffersize - (int)encodedFrameBytes >= 0 )<br>
> {<br>
> speex_bits_reset( &codecBits );<br>
> speex_bits_read_from( &codecBits, bitbuffer + pos, encodedFrameBytes<br>
> );<br>
> //<br>
> if( speex_decode_int( pCodecDecoderState, &codecBits,<br>
> (spx_int16_t*)pCodecBuffer ) == 0 )<br>
> {<br>
> memcpy( &samplearray[decodedbytes], pCodecBuffer, decoderFrameSize<br>
> );<br>
> decodedbytes += decoderFrameSize;<br>
> }<br>
> //<br>
> pos += encodedFrameBytes;<br>
> buffersize -= encodedFrameBytes;<br>
> }<br>
><br>
> return decodedbytes;<br>
> }<br>
><br>
> -----------------------<br>
> code<br>
><br>
> Lp, Tim<br>
> +--------------------------+<br>
> | email: <a href="mailto:rico@gama.us">rico@gama.us</a> |<br>
> | www: <a href="http://gama.us" target="_blank">http://gama.us</a> |<br>
> |--------------------------|<br>
> | tel: 00386 31 457 627 |<br>
> +--------------------------+<br>
><br>
><br>
> _______________________________________________<br>
> Speex-dev mailing list<br>
> <a href="mailto:Speex-dev@xiph.org">Speex-dev@xiph.org</a><br>
> <a href="http://lists.xiph.org/mailman/listinfo/speex-dev" target="_blank">http://lists.xiph.org/mailman/listinfo/speex-dev</a><br>
><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.xiph.org/pipermail/speex-dev/attachments/20090903/86415e92/attachment-0001.htm" target="_blank">http://lists.xiph.org/pipermail/speex-dev/attachments/20090903/86415e92/attachment-0001.htm</a><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Thu, 3 Sep 2009 14:20:38 +0200<br>
From: Tim Rijavec <<a href="mailto:rico@gama.us">rico@gama.us</a>><br>
Subject: Re: [Speex-dev] voice sound like robot voice :)<br>
To: <a href="mailto:speex-dev@xiph.org">speex-dev@xiph.org</a><br>
Message-ID:<br>
<<a href="mailto:55bb9c6f0909030520x6f9f500tfdc1e6211d5b8003@mail.gmail.com">55bb9c6f0909030520x6f9f500tfdc1e6211d5b8003@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
hy,<br>
recording and playback without speex is working perfectly<br>
<br>
<br>
Lp, Tim<br>
+--------------------------+<br>
| email: <a href="mailto:rico@gama.us">rico@gama.us</a> |<br>
| www: <a href="http://gama.us" target="_blank">http://gama.us</a> |<br>
|--------------------------|<br>
| tel: 00386 31 457 627 |<br>
+--------------------------+<br>
<br>
<br>
<br>
2009/9/2 Tim Rijavec <<a href="mailto:rico@gama.us">rico@gama.us</a>><br>
<br>
> hy,<br>
><br>
> here is my speex encoder/decoder .. the sampleRate i use is 16000 and<br>
> quality,complexity are at 5.<br>
><br>
> can someone take a look in to the code and see if there is something that<br>
> is making that robot voice<br>
><br>
> here is a link to colored and numbered code, same as below<br>
> <a href="http://barvanjekode.gama.us/temp/1257361243.html" target="_blank">http://barvanjekode.gama.us/temp/1257361243.html</a><br>
><br>
> thanx.<br>
><br>
> code<br>
> -----------------------<br>
> #include "codec.h"<br>
><br>
> /////////////////////////////////////////////////////////////////<br>
> // Constants<br>
> /////////////////////////////////////////////////////////////////<br>
> #define Cvoicecodecrawbuffersize 16 * Ckilobyte<br>
><br>
> /////////////////////////////////////////////////////////////////<br>
> //<br>
> // TVoiceCodec<br>
> //<br>
> /////////////////////////////////////////////////////////////////<br>
> TVoiceCodec::TVoiceCodec() :<br>
> pMode( NULL ),<br>
> pPreprocessorState( NULL ),<br>
> pCodecEncoderState( NULL ),<br>
> encoderQuality( 5 ),<br>
> encoderComplexity( 3 ),<br>
> encoderFrameSize( 0 ),<br>
> encodedFrameBytes( 0 ),<br>
> pCodecDecoderState( NULL ),<br>
> sampleRate( VOICE_SAMPLE_RATE ),<br>
> decoderFrameSize( 0 )<br>
> {<br>
> /////////////////////////////////////////////////////////////////<br>
> // Prepare buffers<br>
> /////////////////////////////////////////////////////////////////<br>
> uint voicememsize = Cvoicecodecrawbuffersize + CODEC_MAX_BUFFER_SIZE;<br>
> byte *voicemem = (byte*)pMemoryMng->Alloc(voicememsize);<br>
> memset( voicemem, 0, voicememsize );<br>
><br>
> // raw voice input buffer<br>
> pCodecRawBuffer = voicemem;<br>
> pCodecRawBufferCur = pCodecRawBuffer;<br>
> //<br>
> voicemem += Cvoicecodecrawbuffersize;<br>
><br>
> // input/output voice buffer<br>
> pCodecBuffer = voicemem;<br>
> }<br>
><br>
><br>
> TVoiceCodec::~TVoiceCodec()<br>
> {<br>
> if ( pCodecEncoderState )<br>
> {<br>
> speex_preprocess_state_destroy( pPreprocessorState );<br>
> speex_encoder_destroy( pCodecEncoderState );<br>
> speex_bits_destroy( &codecBits );<br>
> pCodecEncoderState = NULL;<br>
> }<br>
><br>
> if ( pCodecDecoderState )<br>
> {<br>
> speex_decoder_destroy( pCodecDecoderState );<br>
> speex_bits_destroy( &codecBits );<br>
> pCodecDecoderState = NULL;<br>
> }<br>
> }<br>
><br>
><br>
> void TVoiceCodec::setSampleRate( int samplerate )<br>
> {<br>
> sampleRate = samplerate;<br>
><br>
> // determine the mode<br>
> int modeID = -1;<br>
><br>
> // speex has limits [6000 - 48000]<br>
> if ( sampleRate > 48000 )<br>
> return;<br>
><br>
> if ( sampleRate > 25000 )<br>
> modeID = SPEEX_MODEID_UWB;<br>
> else if ( sampleRate > 12500 )<br>
> modeID = SPEEX_MODEID_WB;<br>
> else if ( sampleRate >= 6000 )<br>
> modeID = SPEEX_MODEID_NB;<br>
> else<br>
> return;<br>
><br>
> // set up mode<br>
> pMode = speex_lib_get_mode( modeID );<br>
> }<br>
><br>
> void TVoiceCodec::setupEncoder( uint quality, uint complexity )<br>
> {<br>
> encoderQuality = quality;<br>
> encoderComplexity = complexity;<br>
><br>
> // catch invalid sample rates resulting in invalid mode<br>
> if ( !pMode )<br>
> return;<br>
> //<br>
> assert( ( pCodecEncoderState == NULL ) && "encoder already initialized"<br>
> );<br>
> //<br>
> int enabled = 1;<br>
> int disabled = 0;<br>
> //<br>
> float highpass = 80;<br>
><br>
> // setup encoder<br>
> pCodecEncoderState = speex_encoder_init( pMode );<br>
> //<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_SAMPLING_RATE,<br>
> &sampleRate );<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_COMPLEXITY,<br>
> &encoderComplexity );<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_QUALITY,<br>
> &encoderQuality );<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_VBR,<br>
> &disabled );<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_SET_DTX,<br>
> &disabled );<br>
><br>
> // init encoder<br>
> speex_bits_init( &codecBits );<br>
> speex_bits_reset( &codecBits );<br>
><br>
> // determine encoded bytes per frame with spx_int16_t type, speex can<br>
> work with float;s, but not in this engine<br>
> speex_encode_int( pCodecEncoderState, (spx_int16_t*)pCodecBuffer,<br>
> &codecBits );<br>
> encodedFrameBytes = (uint)speex_bits_nbytes( &codecBits );<br>
><br>
> // setup preprocessor<br>
> speex_encoder_ctl( pCodecEncoderState, SPEEX_GET_FRAME_SIZE,<br>
> &encoderFrameSize );<br>
> //<br>
> pPreprocessorState = speex_preprocess_state_init( encoderFrameSize,<br>
> sampleRate );<br>
> //<br>
> speex_preprocess_ctl( pPreprocessorState, SPEEX_PREPROCESS_SET_DENOISE,<br>
> &enabled );<br>
> speex_preprocess_ctl( pPreprocessorState, SPEEX_PREPROCESS_SET_VAD,<br>
> &disabled );<br>
> }<br>
><br>
> void TVoiceCodec::setupDecoder()<br>
> {<br>
> // catch invalid sample rates resulting in invalid mode<br>
> if ( !pMode )<br>
> return;<br>
> //<br>
> assert( ( pCodecDecoderState == NULL ) && "decoder already initialized"<br>
> );<br>
> //<br>
> int enabled = 1;<br>
> //<br>
> pCodecDecoderState = speex_decoder_init( pMode );<br>
> speex_decoder_ctl( pCodecDecoderState, SPEEX_SET_SAMPLING_RATE,<br>
> &sampleRate );<br>
> speex_decoder_ctl( pCodecDecoderState, SPEEX_GET_FRAME_SIZE,<br>
> &decoderFrameSize );<br>
> speex_decoder_ctl( pCodecDecoderState, SPEEX_SET_ENH,<br>
> &enabled );<br>
> //<br>
> speex_bits_init( &codecBits );<br>
> }<br>
><br>
> uint TVoiceCodec::encode( byte *rawsoundbuffer, uint length, char<br>
> *bitbuffer, float gain )<br>
> {<br>
> if( !pCodecEncoderState )<br>
> return 1;<br>
><br>
> // copy raw voice data to temporary codec raw voice data buffer<br>
> memcpy( pCodecRawBufferCur, rawsoundbuffer, length );<br>
> pCodecRawBufferCur += length;<br>
><br>
> // determine the size of data<br>
> uint buffersize = (int)( pCodecRawBufferCur - pCodecRawBuffer );<br>
><br>
> // do we have enough data for encoding?<br>
> if ( buffersize < encoderFrameSize )<br>
> {<br>
> //pLog->Add("codec: encoder: return: buffersize: %d: needtoencode<br>
> %d", buffersize, encoderFrameSize);<br>
> return 0;<br>
> }<br>
><br>
> int encodedbytes = 0;<br>
> int pos = 0;<br>
> // while we have enough data<br>
> while( (uint)( pCodecRawBufferCur - pCodecRawBuffer ) >=<br>
> encoderFrameSize )<br>
> {<br>
> // copy data from temporary buffer to codec buffer<br>
> memcpy( pCodecBuffer, pCodecRawBuffer, encoderFrameSize );<br>
><br>
> // move memory of temporary buffer<br>
> memmove( pCodecRawBuffer, pCodecRawBuffer + encoderFrameSize,<br>
> buffersize - ( pos + encoderFrameSize ) );<br>
> pCodecRawBufferCur -= encoderFrameSize;<br>
><br>
> // increase current pos<br>
> pos += encoderFrameSize;<br>
><br>
> //encode<br>
> speex_bits_reset( &codecBits );<br>
> //<br>
> speex_encode_int( pCodecEncoderState, (spx_int16_t*)pCodecBuffer,<br>
> &codecBits );<br>
> //<br>
> int nb = speex_bits_nbytes( &codecBits );<br>
> encodedbytes += speex_bits_write( &codecBits,<br>
> &bitbuffer[encodedbytes], nb );<br>
> }<br>
><br>
> //pLog->Add("buffersize: %d: total left: %d enc buffersize: %d", length,<br>
> inputBufferArray.Count(), encodedbytes );<br>
> return encodedbytes;<br>
> }<br>
><br>
> uint TVoiceCodec::decode( char *bitbuffer, uint length, byte *samplearray,<br>
> float gain )<br>
> {<br>
> // return if decoder is not initialized<br>
> if( !pCodecDecoderState )<br>
> return 0;<br>
><br>
> // return if there is not enough data to decode<br>
> if ( length < encodedFrameBytes )<br>
> return 0;<br>
><br>
> int buffersize = length;<br>
> uint decodedbytes = 0;<br>
> int pos = 0;<br>
> //<br>
> while( (int)buffersize - (int)encodedFrameBytes >= 0 )<br>
> {<br>
> speex_bits_reset( &codecBits );<br>
> speex_bits_read_from( &codecBits, bitbuffer + pos, encodedFrameBytes<br>
> );<br>
> //<br>
> if( speex_decode_int( pCodecDecoderState, &codecBits,<br>
> (spx_int16_t*)pCodecBuffer ) == 0 )<br>
> {<br>
> memcpy( &samplearray[decodedbytes], pCodecBuffer, decoderFrameSize<br>
> );<br>
> decodedbytes += decoderFrameSize;<br>
> }<br>
> //<br>
> pos += encodedFrameBytes;<br>
> buffersize -= encodedFrameBytes;<br>
> }<br>
><br>
> return decodedbytes;<br>
> }<br>
><br>
> -----------------------<br>
> code<br>
><br>
> Lp, Tim<br>
> +--------------------------+<br>
> | email: <a href="mailto:rico@gama.us">rico@gama.us</a> |<br>
> | www: <a href="http://gama.us" target="_blank">http://gama.us</a> |<br>
> |--------------------------|<br>
> | tel: 00386 31 457 627 |<br>
> +--------------------------+<br>
><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.xiph.org/pipermail/speex-dev/attachments/20090903/5a8cf708/attachment.htm" target="_blank">http://lists.xiph.org/pipermail/speex-dev/attachments/20090903/5a8cf708/attachment.htm</a><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Speex-dev mailing list<br>
<a href="mailto:Speex-dev@xiph.org">Speex-dev@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/speex-dev" target="_blank">http://lists.xiph.org/mailman/listinfo/speex-dev</a><br>
<br>
<br>
End of Speex-dev Digest, Vol 64, Issue 2<br>
****************************************<br>
</blockquote></div><br>