[Speex-dev] WaveIn/WaveOut and Speex
Evgueni Tsygankov
eugenet at rusmex.com
Sun Nov 4 18:50:29 PST 2007
Hello,
I know my question has been asked before because I spent the last week
searching the web for how to use Speex in combination with
WaveIn/WaveOut and I ran into a few posts, but none of them answer the
question. There is still a lot of confusion how to use WaveIn/WaveOut
and Speex by junior developers such as myself. Even after examining code
for SpeexDec and SpeexEnc, I cannot get clear sound when I try to
Get PCM Char buffer from the microphone
Encode Char buffer using Speex
Decode Speex Char buffer into PCM char buffer
Play PCM char buffer using WaveOut
The end-result is very distorted sound.
I use the following PCM format:
waveFormat.nChannels = 1;
waveFormat.nSamplesPerSec = 8000;
waveFormat.wBitsPerSample = 8;
Once sound is aquired by the mic, I send it to Speex in a Char buffer.
It looks something like this:
Encode(char* inBuffer, DWORD bufferLength)
...
float* input = new float[frameSize];
ZeroMemory(input, frameSize);
...
for( )
{
input[..] = inBuffer[..];
}
...
speex_encode(enc_state, input, &bits);
int bytesWritten = speex_bits_nbytes(&bits);
speex_bits_write(&bits, encBuffer, bytesWritten);
Then, my decoding routine accepts the char buffer that was encoded with
Speex:
Decode(char* encBuffer, DWORD bufferLength)
...
float* output = new float[frameSize];
...
speex_bits_read_from(&bits, encBuffer + offset, bytesToRead);
speex_decode(dec_state, &bits, output);
char* outBuffer=...
for(UINT i = 0; i < frameSize; i++)
{
outBuffer[retValIndex] = output[i];
retValIndex++;
}
When I try to play outBuffer with waveOut, I can hear the voice
"somewhere far", but there is a lot of distortion noise. Any help would
be greatly appreciated!!!
Thank you,
Evgueni Tsygankov
www.sqlanswers.com <http://www.sqlanswers.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20071104/e0d5ff78/attachment.html
More information about the Speex-dev
mailing list