<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Since your interface is using 16-bit samples, you
will be better off using speex_encode_int and speex_decode_int. Speex uses
16-bit fixed values internally, speex_encode and speex_decode just convert
between float and fixed. What you have implemented has extra conversions,
but that will not break anything.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>You should try swapping your byte order. I
seem to remember others reporting your symptom, and the problem was that the
samples were byte swapped.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>- Jim</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=makrhymer@yahoo.com href="mailto:makrhymer@yahoo.com">Ali Khan</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=speex-dev@xiph.org
href="mailto:speex-dev@xiph.org">speex-dev@xiph.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, September 15, 2006 10:07
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Speex-dev] Constant noise in
the background in realtime data</DIV>
<DIV><BR></DIV><FONT size=2>
<DIV>Hi everyone,</DIV>
<DIV> </DIV>
<DIV>Our team is working on a realtime voice communication
application. We are using openAL 1.1 to capture the samples and then
encode them using speex. On the remote machine we decode the samples and
play them using openAL again. Capture and play formats for the samples is
AL_FORMAT_MONO16 and frequency is 22050. we are using wide band
encoding/decoding. </DIV>
<DIV> </DIV>
<DIV>The encoding sample frame buffer size is returned by speex as 320, on
both ends ( </FONT><FONT face="Courier New"
size=2>speex_encoder_ctl(m_poSpeexState, SPEEX_GET_FRAME_SIZE,
&nFrameSize) ).</FONT></DIV>
<DIV><FONT face="Courier New" size=2> </DIV></FONT><FONT size=2>
<DIV>Coming to the problem, when I play the sound I get a high picthed noise
in the background. I do hear my voice with a decreased quality but the noise
keeps running in the background whether I talk or not.</DIV>
<DIV> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV>Here are the two main encoding/decoding function I am using</DIV>
<DIV> </DIV>
<DIV>//------------------------------------------------------------------------------------------</DIV>
<DIV> </DIV></FONT><FONT color=#0000ff size=2>
<DIV>void</FONT><FONT size=2> OALCapture::Compress(ALchar* pData, </FONT><FONT
color=#0000ff size=2>int</FONT><FONT size=2> *iFrameSize, </FONT><FONT
color=#0000ff size=2>char</FONT><FONT size=2>* cComFrame)</DIV>
<DIV>{</DIV>
<DIV></FONT><FONT color=#008000 size=2>// Reset speex bits before frame
encode</DIV></FONT><FONT size=2>
<DIV>speex_bits_reset(&m_oBits);</DIV>
<DIV> </DIV>
<DIV></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nFrameSize =
0;</FONT></DIV>
<DIV><FONT size=2>speex_encoder_ctl(m_poSpeexCompressState,
SPEEX_GET_FRAME_SIZE, &nFrameSize);</FONT></DIV>
<DIV><FONT size=2> </DIV>
<DIV></FONT><FONT color=#008000 size=2>// Our samples are 2 bytes each so
number of samples is actually</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#008000 size=2>// have the buffer
size</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nBuffSize =
BUFFERSIZE / 2; </FONT></DIV>
<DIV><FONT size=2> </DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#008000 size=2>// Now copy the samples into the float
array that we will encode</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2>(</FONT><FONT
color=#0000ff size=2>int</FONT><FONT size=2> i = 0; i < nBuffSize;
i++)</DIV>
<DIV>input[i] = ( (pData[(i*2) + 1] << 8) | (pData[(i*2)] & 0xff) )
/ 32768.0f;</DIV>
<DIV> </DIV>
<DIV></FONT><FONT color=#008000 size=2>// Provide speex with the float array
pointer to compress</DIV></FONT><FONT size=2>
<DIV>speex_encode(m_poSpeexCompressState, input, &m_oBits);</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV></FONT><FONT color=#008000 size=2>// Write the encoded bytes into our
array</DIV></FONT><FONT size=2>
<DIV>speex_bits_insert_terminator(&m_oBits);</DIV>
<DIV>nbBytes = speex_bits_write(&m_oBits, cbits, BUFFERSIZE);</DIV>
<DIV> </DIV>
<DIV></FONT><FONT color=#008000 size=2>// Set the number of bytes of encoded
message</DIV></FONT><FONT size=2>
<DIV>*iFrameSize = nbBytes;</DIV>
<DIV> </DIV>
<DIV></FONT><FONT color=#008000 size=2>// Copy encoded bytes into return
array</DIV></FONT><FONT size=2>
<DIV>memcpy(cComFrame, cbits, nbBytes);</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>//------------------------------------------------------------------------------------------</DIV>
<DIV> </DIV></FONT><FONT color=#0000ff size=2>
<DIV>int</FONT><FONT size=2> OALCapture::Decompress(ALchar* pDecomData,
</FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> iFrameSize,
</FONT><FONT color=#0000ff size=2>char</FONT><FONT size=2>* cComFrame)</DIV>
<DIV>{</DIV>
<DIV></FONT><FONT color=#008000 size=2>// Set the decompress
bits</DIV></FONT><FONT size=2>
<DIV>speex_bits_read_from(&m_oDecompressBits, cComFrame,
iFrameSize);</DIV>
<DIV> </DIV>
<DIV></DIV>
<DIV></FONT><FONT color=#008000 size=2>// Decode the bits into an output float
array</DIV></FONT><FONT size=2>
<DIV>speex_decode(m_poSpeexDecompressState, &m_oDecompressBits,
output);</DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV></FONT><FONT color=#008000 size=2>// Get the number of samples returned
by the decoder</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> nSamplesDecoded
= 0;</DIV>
<DIV>speex_decoder_ctl(m_poSpeexDecompressState, SPEEX_GET_FRAME_SIZE,
&nSamplesDecoded);</DIV>
<DIV> </DIV>
<DIV></FONT><FONT color=#008000 size=2>//nSamplesDecoded /=
2;</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#008000 size=2>// Now we have to convert the floats
back into our AL sample format</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#008000 size=2>// which takes 2 bytes integer value
for each sample</DIV></FONT><FONT size=2>
<DIV></FONT><FONT color=#0000ff size=2>short</FONT><FONT size=2>* pALBuffer =
(</FONT><FONT color=#0000ff size=2>short</FONT><FONT size=2>*)
pDecomData;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2>(</FONT><FONT
color=#0000ff size=2>int</FONT><FONT size=2> i = 0; i < nSamplesDecoded;
i++)</DIV>
<DIV>{</DIV>
<DIV>pALBuffer[i] = output[i] * 32768.0f;</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>nSamplesDecoded *= 2;</DIV>
<DIV></FONT><FONT color=#0000ff size=2>return</FONT><FONT size=2>
nSamplesDecoded;</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>//------------------------------------------------------------------------------------------</DIV>
<DIV>Here are the issues I can think of</DIV>
<DIV> </DIV>
<DIV>1.</DIV>
<DIV>My buffer size is 640 bytes as each sample is of 2 bytes and the frame
buffer size if 320 samples as required by speex. I have tried changing this
buffer size and the result is a different type of noise, much worse then what
I currently get. </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Speex returns the same frame size for non-compressed and decompressed
data although the quality of decompressed data has reduced.</DIV>
<DIV> </DIV>
<DIV>2. </DIV>
<DIV>Should we get a smaller frame size for low quality decoded data ?</DIV>
<DIV> </DIV>
<DIV>3. </DIV>
<DIV>Is the sound format the same (AL_FORMAT_MONO16, 22050) for both data
?</DIV>
<DIV> </DIV>
<DIV>We are in a critical development period, so any quick response will be
really helpful to me. </DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV> </DIV>
<DIV>Ali Khan.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV></FONT>
<P>
<HR SIZE=1>
Yahoo! Messenger with Voice. <A
href="http://us.rd.yahoo.com/mail_us/taglines/postman1/*http://us.rd.yahoo.com/evt=39663/*http://voice.yahoo.com">Make
PC-to-Phone Calls</A> to the US (and 30+ countries) for 2¢/min or less.
<P>
<HR>
<P></P>_______________________________________________<BR>Speex-dev mailing
list<BR>Speex-dev@xiph.org<BR>http://lists.xiph.org/mailman/listinfo/speex-dev<BR></BLOCKQUOTE></BODY></HTML>