<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Hi,<br><br>Can someone please help me with my problem below. Any suggestions is appreciated. <br><br>thanks,<br>Carine<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Carine Liang &lt;carineliang@yahoo.com.sg&gt;<br>To: speex-dev@xiph.org; speex-dev@xiph.org<br>Sent: Tuesday, 31 October 2006 1:05:49 PM<br>Subject: [Speex-dev] Integrating speex with VideoNet application: Constant background noise<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Hi,<br><br>I am developing a peer-to-peer video conference application which uses speex as a codec for the voice. <br><br>I am new to speex, so please bear with me if I asked
 the obvious. After I added the encode and decode function to my MFC app, I heard a constant background noise, even when no one is speaking into the microphone. <br><br>#define FRAME_SIZE 160<br><br>The application is coded in MFC C++. The record buffer is set to be the same as the FRAME_SIZE such that my callback function is called everytime 160 bytes of data is recorded.<br><br>Here's what I did in the initialisation (called only once).<br>m_waveFormatEx.wFormatTag =WAVE_FORMAT_PCM;<br>m_waveFormatEx.nChannels =1;<br>m_waveFormatEx.wBitsPerSample =8;<br>m_waveFormatEx.cbSize =0;<br>m_waveFormatEx.nSamplesPerSec =
 8000;<br>m_waveFormatEx.nBlockAlign =1;<br>m_waveFormatEx.nAvgBytesPerSec = 8000;<br><br>int quality =8;<br>speex_bits_init(&amp;bits);<br>enc_state = speex_encoder_init(&amp;speex_nb_mode);<br>speex_encoder_ctl(enc_state, SPEEX_SET_QUALITY, &amp;quality);<br><br><br>In my recording callback function<br>LRESULT RecordSound::OnSoundData(WPARAM wParam, LPARAM lParam)<br>{<br>&nbsp;....<br>&nbsp;&nbsp;&nbsp; dataPtr = (char *)lpHdr -&gt;lpData;<br>&nbsp;&nbsp;&nbsp; dataSize = (int)lpHdr -&gt;dwBytesRecorded;<br><br>&nbsp;&nbsp;&nbsp; for(int k=0;k&lt;FRAME_SIZE;k++)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  input[k] = dataPtr[k]; &nbsp;&nbsp;&nbsp; //input is float[FRAME_SIZE]<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; speex_bits_reset(&amp;bits);<br>&nbsp;&nbsp;&nbsp; speex_encode(enc_state, input, &amp;bits);<br>&nbsp;&nbsp;&nbsp; encByte = speex_bits_write(&amp;bits, cbits, 200);<br><br>&nbsp;&nbsp;&nbsp; //send cbits to peer computer via sockets<br>}<br><br><br>In the
 receiver's initialization function, I've initialized the speex_decoder.<br>speex_bits_init(&amp;bits);<br>
dec_state = speex_decoder_init(&amp;speex_nb_mode);<br><br>In the receiver's socket function, it reads from socket and store the data in cbits (char array).<br>{<br>&nbsp;&nbsp;&nbsp; speex_bits_read_from(&amp;bits, cbits, retvalue); //retvalue is 38<br>&nbsp;&nbsp;&nbsp; speex_decode(dec_state, &amp;bits, output); //where output is float array<br><br>&nbsp;&nbsp;&nbsp; for(int k=0;k&lt;FRAME_SIZE;k++)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;  out[k] = output[k];&nbsp; //out is a char array<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp; PostThreadMessage( WM_PLAYSOUND_PLAYBLOCK, FRAME_SIZE, (LPARAM)out );<br>}<br><br><br><br></div></div><br>
                <hr size="1"> 
What is the internet to you?<br> 
Contribute to the <a rel="nofollow" target="_blank" href="http://sg.rd.yahoo.com/mail/sg/footer/def/*http://timecapsule.yahoo.com/capsule.php?intl=sg">Yahoo! Time Capsule</a> and be a part of internet history.<div>_______________________________________________<br>Speex-dev mailing list<br>Speex-dev@xiph.org<br><a target="_blank" href="http://lists.xiph.org/mailman/listinfo/speex-dev">http://lists.xiph.org/mailman/listinfo/speex-dev</a><br></div></div><br></div></div><br>
                <hr size=1> 
What is the internet to you?<br> 
Contribute to the <a href="http://sg.rd.yahoo.com/mail/sg/footer/def/*http://timecapsule.yahoo.com/capsule.php?intl=sg">Yahoo! Time Capsule</a> and be a part of internet history.</body></html>