Changing from using floats to shorts did fix the high pitched tone problem. I'm having other problems but I'll look into it more first. SteveK wrote:> > 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
In order to save bandwidth, is it possible to detect that there is no data waiting, or only background noise, and not send if that is the case? Does Speex have this built-in or should I just check to see if all input values are near 0? Kevin Jenkins wrote:> Changing from using floats to shorts did fix the high pitched tone > problem. I'm having other problems but I'll look into it more first. > > SteveK wrote: >> >> 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 > _______________________________________________ > Speex-dev mailing list > Speex-dev@xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev > >
This is a simple question I hope someone can help with. speex_encode_int takes a short - which is two bytes. Suppose I want to record my data as 8 bit input. Can I pass a char to speex instead, and if so will this halve my bandwidth usage? If I do pass a char, is there any special data formatting I need to do so speex will understand it? Thanks!
----- Original Message ----- From: "Kevin Jenkins" <gameprogrammer@rakkar.org> To: <speex-dev@xiph.org> Sent: Sunday, May 21, 2006 11:17 PM Subject: [Speex-dev] Question on speex_encode_int> This is a simple question I hope someone can help with. > > speex_encode_int takes a short - which is two bytes. Suppose I want to > record my data as 8 bit input. Can I pass a char to speex instead, and if > so will this halve my bandwidth usage? If I do pass a char, is there any > special data formatting I need to do so speex will understand it?The Speex bandwidth usage depends on the sample rate (among other things), but not on the sample precision. If you pass Speex samples in the range -127 to 127, you will get noisier results than if you pass samples in the range -32767 to 32767, but the Speex encoder will produce the same number of bits. By the way, in the telephone world, where 8-bit samples are used, these are actually 13 or 14-bit samples encoded with the u-Law or a-Law algorithm. You would expand these samples back to the original 13 or 14-bit range before feeding them to Speex. - Jim