[Speex-dev] Re: High pitched whine with Speex

SteveK stevek at stevek.com
Sun May 21 15:53:48 PDT 2006


On May 21, 2006, at 6:33 PM, Kevin Jenkins wrote:

> When I just copy the microphone input buffer to the output buffer  
> the sound plays OK.  But if I encode and decode the buffer through  
> Speex I get a high pitched constant tone in the background.  I  
> actually do hear my voice speaking when I talk, but it's faint and  
> much quieter than the tone.
>
> Here's what my data looks like:
> Input is the first 5 floats of each input buffer.
> Output is after Speex runs on it.
>
> Input: 0.000 0.000 0.000 0.000 -0.000
> Out: -0.029 -0.008 0.020 0.018 -0.001
> Input: 0.000 0.000 0.000 0.000 0.000
> Out: -0.029 -0.008 0.020 0.018 -0.001
> Input: -0.000 0.000 0.000 0.000 -0.000
> Out: -0.029 -0.008 0.020 0.018 -0.001
> Input: -0.000 -0.000 -0.000 -0.000 0.000
> Out: -0.029 -0.008 0.020 0.018 -0.001
>
> My samples are 4 byte floats.
>
> My sample rate is 8000
>
> Here's pretty much all my speex code:
> ENCODING INIT:
> channel->enc_state=speex_encoder_init(&speex_nb_mode);
> speex_encoder_ctl(channel->enc_state, SPEEX_GET_FRAME_SIZE,  
> &channel->speexOutgoingFrameSampleCount);
>
> DECODING INIT:
> channel->dec_state=speex_decoder_init(&speex_nb_mode);
> speex_decoder_ctl(channel->dec_state, SPEEX_GET_FRAME_SIZE,  
> &channel->speexIncomingFrameSampleCount);
>
> ENCODING:
> speex_encode(channel->enc_state, (float *) inputBuffer, &speexBits);
> bytesWritten = speex_bits_write(&speexBits, tempOutput+1, 2048-1);
>
> DECODING:
> speex_bits_read_from(&speexBits, (char*)(packet->data+1), packet- 
> >length-1);
> speex_decode(channel->dec_state, &speexBits, (float*)tempOutput);
>
> That's pretty much the extent of the Speex code.  For the output, I  
> write all 0.0 to the buffer first, then add the equivalent inputs  
> from speex.
>
> When I copy bytes of input data, I use that  
> speexOutgoingFrameSampleCount * sizeof(float) to determine how many  
> bytes to consider read and written.

>
> Any idea?

It seems like your samples may all be in the range -1.0 .. 1.0.  For  
speex, they should be +-32767 or so.

-SteveK




More information about the Speex-dev mailing list