<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 <carineliang@yahoo.com.sg><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(&bits);<br>enc_state = speex_encoder_init(&speex_nb_mode);<br>speex_encoder_ctl(enc_state, SPEEX_SET_QUALITY, &quality);<br><br><br>In my recording callback function<br>LRESULT RecordSound::OnSoundData(WPARAM wParam, LPARAM lParam)<br>{<br> ....<br> dataPtr = (char *)lpHdr ->lpData;<br> dataSize = (int)lpHdr ->dwBytesRecorded;<br><br> for(int k=0;k<FRAME_SIZE;k++)<br> input[k] = dataPtr[k]; //input is float[FRAME_SIZE]<br> <br> speex_bits_reset(&bits);<br> speex_encode(enc_state, input, &bits);<br> encByte = speex_bits_write(&bits, cbits, 200);<br><br> //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(&bits);<br>
dec_state = speex_decoder_init(&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> speex_bits_read_from(&bits, cbits, retvalue); //retvalue is 38<br> speex_decode(dec_state, &bits, output); //where output is float array<br><br> for(int k=0;k<FRAME_SIZE;k++)<br> out[k] = output[k]; //out is a char array<br> <br> 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>