<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hello,<br>
<br>
I have an p2p voice chat application using WAVE PCM (winmm). Now i
am trying to add opus encoding to it to send it over the TCP/IP and
then decoding it back to play - but without success (without opus it
works ok)<br>
<br>
Here is an example of my code. I get message from input device then
encode with opus then decode it back to output wave header and play.
Doing it i hear only noise in my headphones. So how can i use Opus
in this way? Thanks in advance<br>
<br>
<pre style="font-family:Consolas;font-size:13;color:black;background:white;">WAVEFORMATEX waveform;
waveform.cbSize = 0;
waveform.wFormatTag = WAVE_FORMAT_PCM;
waveform.nChannels = 2;
waveform.wBitsPerSample = 8;
waveform.nSamplesPerSec = 48000;
waveform.nBlockAlign = waveform.nChannels * (waveform.wBitsPerSample >> 3);
waveform.nAvgBytesPerSec = waveform.nSamplesPerSec * waveform.nBlockAlign;
#define BUFSIZE 512
</pre>
...<br>
<br>
<pre style="font-family:Consolas;font-size:13;color:black;background:white;"><span style="color:blue;">case</span> MM_WIM_DATA:
{
WAVEHDR *Hdr = (WAVEHDR *) msg.lParam;
<span style="color:blue;"> int</span> opusRes;
m_opusEncoder = opus_encoder_create(48000, 2, OPUS_APPLICATION_AUDIO, &opusRes);
m_opusDecoder = opus_decoder_create(48000, 2, &opusRes);
<span style="color:blue;"> unsigned</span> <span style="color:blue;">char</span> data[BUFSIZE];
opus_int32 dataLength = opus_encode(m_opusEncoder, (<span style="color:blue;">short</span>*)Hdr->lpData, 80, data, BUFSIZE);</pre>
<pre style="font-family:Consolas;font-size:13;color:black;background:white;"> dataLength = opus_decode(m_opusDecoder, (<span style="color:blue;">unsigned</span> <span style="color:blue;">char</span>*)data, dataLength, (<span style="color:blue;">short</span>*)WaveHdrOut.lpData, BUFSIZE, 0);
</pre>
<pre style="font-family:Consolas;font-size:13;color:black;background:white;"> waveOutWrite(hWaveOut, &WaveHdrOut, <span style="color:blue;">sizeof</span>(WAVEHDR));
</pre>
<pre class="moz-signature" cols="72">--
Best regards,
Stepan Melnichuk
</pre>
</body>
</html>