Carine Liang
2006-Nov-02 00:22 UTC
[Speex-dev] Integrating speex with VideoNet application: Constantbackground noise
Hi John,
Thanks for your reply.
Yes, my output device is in 8-bit mode, same as my input mode. I'm actually
working in char (8 bit) arrays. Is it necessary to work in signed short integers
only? I changed all the short arrays in the example to char.
Carine
----- Original Message ----
From: John Miles <jmiles@pop.net>
To: carineliang@yahoo.com.sg; speex-dev@xiph.org
Sent: Thursday, 2 November 2006 2:04:39 PM
Subject: RE: [Speex-dev] Integrating speex with VideoNet application:
Constantbackground noise
DIV {
MARGIN:0px;}
At
first glance it looks like you are opening the output device in 8-bit mode
(m_waveFormatEx.wBitsPerSample
=8;). You will need to use 16-bit
mode if you expect to write an array of signed short integers to the audio
buffer. 8-bit PCM is an unsigned mode, no longer used much these
days.
Also,
a good debugging trick is to include something like this in your output sample
processing loop:
static FILE *hack =
fopen("test.raw","wb");
fwrite(output, 2, FRAME_SIZE,
hack);
After your app is closed, there will be a file called "test.raw" in
its working directory, which you can load into Sound Forge or a similar audio
editing package for closer inspection without relying on your output
buffers and playback code to work properly.
--
john
RAD
Game Tools
-----Original Message-----
From: speex-dev-bounces@xiph.org
[mailto:speex-dev-bounces@xiph.org]On Behalf Of Carine
Liang
Sent: Wednesday, November 01, 2006 9:40 PM
To:
speex-dev@xiph.org
Subject: Re: [Speex-dev] Integrating speex with
VideoNet application: Constantbackground noise
Hi,
Can
someone please help me with my problem below. Any suggestions is appreciated.
thanks,
Carine
-----
Original Message ----
From: Carine Liang
<carineliang@yahoo.com.sg>
To: speex-dev@xiph.org;
speex-dev@xiph.org
Sent: Tuesday, 31 October 2006 1:05:49 PM
Subject:
[Speex-dev] Integrating speex with VideoNet application: Constant background
noise
Hi,
I am developing a peer-to-peer video conference application
which uses speex as a codec for the voice.
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.
#define FRAME_SIZE
160
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.
Here's what I did in the initialisation
(called only once).
m_waveFormatEx.wFormatTag
=WAVE_FORMAT_PCM;
m_waveFormatEx.nChannels
=1;
m_waveFormatEx.wBitsPerSample =8;
m_waveFormatEx.cbSize
=0;
m_waveFormatEx.nSamplesPerSec = 8000;
m_waveFormatEx.nBlockAlign
=1;
m_waveFormatEx.nAvgBytesPerSec = 8000;
int quality
=8;
speex_bits_init(&bits);
enc_state =
speex_encoder_init(&speex_nb_mode);
speex_encoder_ctl(enc_state,
SPEEX_SET_QUALITY, &quality);
In my recording callback
function
LRESULT RecordSound::OnSoundData(WPARAM wParam, LPARAM
lParam)
{
....
dataPtr = (char *)lpHdr
->lpData;
dataSize = (int)lpHdr
->dwBytesRecorded;
for(int
k=0;k<FRAME_SIZE;k++)
input[k] =
dataPtr[k]; //input is
float[FRAME_SIZE]
speex_bits_reset(&bits);
speex_encode(enc_state,
input, &bits);
encByte = speex_bits_write(&bits,
cbits, 200);
//send cbits to peer computer via
sockets
}
In the receiver's initialization function, I've
initialized the speex_decoder.
speex_bits_init(&bits);
dec_state =
speex_decoder_init(&speex_nb_mode);
In the receiver's socket
function, it reads from socket and store the data in cbits (char
array).
{
speex_bits_read_from(&bits, cbits,
retvalue); //retvalue is 38
speex_decode(dec_state,
&bits, output); //where output is float array
for(int k=0;k<FRAME_SIZE;k++)
out[k] =
output[k]; //out is a char array
PostThreadMessage( WM_PLAYSOUND_PLAYBLOCK, FRAME_SIZE, (LPARAM)out
);
}
What is the internet to you?
Contribute to the Yahoo! Time Capsule and be a part of internet
history.
_______________________________________________
Speex-dev mailing
list
Speex-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/speex-dev
What is the internet to you?
Contribute to the Yahoo!
Time Capsule and be a part of internet history.
__________________________________
What will the world find in 2020?
Leave a part of your 2006 in the Yahoo! Time Capsule. Contribute now!
http://timecapsule.yahoo.com/capsule.php?intl=sg
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.xiph.org/pipermail/speex-dev/attachments/20061102/5f7cbc03/attachment.html
John Miles
2006-Nov-02 08:42 UTC
[Speex-dev] Integrating speex with VideoNet application: Constantbackground noise
Yes, it's necessary; Speex will encode signed 16-bit PCM data and decode to
the same format. See the examples that come with it.
8-bit audio is not something you would ever want to use.
-- john
RAD Game Tools
-----Original Message-----
From: Carine Liang [mailto:carineliang@yahoo.com.sg]
Sent: Thursday, November 02, 2006 12:18 AM
To: John Miles; speex-dev@xiph.org
Subject: Re: [Speex-dev] Integrating speex with VideoNet application:
Constantbackground noise
Hi John,
Thanks for your reply.
Yes, my output device is in 8-bit mode, same as my input mode. I'm
actually working in char (8 bit) arrays. Is it necessary to work in signed
short integers only? I changed all the short arrays in the example to char.
Carine
----- Original Message ----
From: John Miles <jmiles@pop.net>
To: carineliang@yahoo.com.sg; speex-dev@xiph.org
Sent: Thursday, 2 November 2006 2:04:39 PM
Subject: RE: [Speex-dev] Integrating speex with VideoNet application:
Constantbackground noise
At first glance it looks like you are opening the output device in 8-bit
mode (m_waveFormatEx.wBitsPerSample =8;). You will need to use 16-bit mode
if you expect to write an array of signed short integers to the audio
buffer.. 8-bit PCM is an unsigned mode, no longer used much these days.
Also, a good debugging trick is to include something like this in your
output sample processing loop:
static FILE *hack = fopen("test.raw","wb");
fwrite(output, 2, FRAME_SIZE, hack);
After your app is closed, there will be a file called "test.raw" in
its
working directory, which you can load into Sound Forge or a similar audio
editing package for closer inspection without relying on your output buffers
and playback code to work properly.
-- john
RAD Game Tools
-----Original Message-----
From: speex-dev-bounces@xiph.org [mailto:speex-dev-bounces@xiph.org]On
Behalf Of Carine Liang
Sent: Wednesday, November 01, 2006 9:40 PM
To: speex-dev@xiph.org
Subject: Re: [Speex-dev] Integrating speex with VideoNet application:
Constantbackground noise
Hi,
Can someone please help me with my problem below. Any suggestions is
appreciated.
thanks,
Carine
----- Original Message ----
From: Carine Liang <carineliang@yahoo.com.sg>
To: speex-dev@xiph.org; speex-dev@xiph.org
Sent: Tuesday, 31 October 2006 1:05:49 PM
Subject: [Speex-dev] Integrating speex with VideoNet application:
Constant background noise
Hi,
I am developing a peer-to-peer video conference application which uses
speex as a codec for the voice.
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.
#define FRAME_SIZE 160
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.
Here's what I did in the initialisation (called only once).
m_waveFormatEx.wFormatTag =WAVE_FORMAT_PCM;
m_waveFormatEx.nChannels =1;
m_waveFormatEx.wBitsPerSample =8;
m_waveFormatEx.cbSize =0;
m_waveFormatEx.nSamplesPerSec = 8000;
m_waveFormatEx.nBlockAlign =1;
m_waveFormatEx.nAvgBytesPerSec = 8000;
int quality =8;
speex_bits_init(&bits);
enc_state = speex_encoder_init(&speex_nb_mode);
speex_encoder_ctl(enc_state, SPEEX_SET_QUALITY, &quality);
In my recording callback function
LRESULT RecordSound::OnSoundData(WPARAM wParam, LPARAM lParam)
{
....
dataPtr = (char *)lpHdr ->lpData;
dataSize = (int)lpHdr ->dwBytesRecorded;
for(int k=0;k<FRAME_SIZE;k++)
input[k] = dataPtr[k]; //input is float[FRAME_SIZE]
speex_bits_reset(&bits);
speex_encode(enc_state, input, &bits);
encByte = speex_bits_write(&bits, cbits, 200);
//send cbits to peer computer via sockets
}
In the receiver's initialization function, I've initialized the
speex_decoder.
speex_bits_init(&bits);
dec_state = speex_decoder_init(&speex_nb_mode);
In the receiver's socket function, it reads from socket and store the
data in cbits (char array).
{
speex_bits_read_from(&bits, cbits, retvalue); //retvalue is 38
speex_decode(dec_state, &bits, output); //where output is float
array
for(int k=0;k<FRAME_SIZE;k++)
out[k] = output[k]; //out is a char array
PostThreadMessage( WM_PLAYSOUND_PLAYBLOCK, FRAME_SIZE, (LPARAM)out );
}
----------------------------------------------------------------------------
What is the internet to you?
Contribute to the Yahoo! Time Capsule and be a part of internet history.
_______________________________________________
Speex-dev mailing list
Speex-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/speex-dev
----------------------------------------------------------------------------
What is the internet to you?
Contribute to the Yahoo! Time Capsule and be a part of internet history.
----------------------------------------------------------------------------
--
What will the world find in 2020?
Leave a part of your 2006 in the Yahoo! Time Capsule. Contribute now!
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.xiph.org/pipermail/speex-dev/attachments/20061102/7fc65ea0/attachment.html
Maybe Matching Threads
- Integrating speex with VideoNet application: Constantbackground noise
- Integrating speex with VideoNet application: Constantbackground noise
- Integrating speex with VideoNet application: Constant background noise
- Integrating speex with VideoNet application: Constantbackground noise
- Integrating speex with VideoNet application: Constantbackground noise