<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&nbsp;waveform;
waveform.cbSize&nbsp;=&nbsp;0;
waveform.wFormatTag&nbsp;= WAVE_FORMAT_PCM;
waveform.nChannels&nbsp;= 2;
waveform.wBitsPerSample&nbsp;=&nbsp;8;
waveform.nSamplesPerSec&nbsp;= 48000;
waveform.nBlockAlign&nbsp;=&nbsp;waveform.nChannels&nbsp;*&nbsp;(waveform.wBitsPerSample&nbsp;&gt;&gt;&nbsp;3);
waveform.nAvgBytesPerSec&nbsp;=&nbsp;waveform.nSamplesPerSec&nbsp;*&nbsp;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>&nbsp;MM_WIM_DATA:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WAVEHDR&nbsp;*Hdr&nbsp;=&nbsp;(WAVEHDR&nbsp;*)&nbsp;msg.lParam;
 <span style="color:blue;">               int</span>&nbsp;opusRes;
                m_opusEncoder&nbsp;=&nbsp;opus_encoder_create(48000, 2,&nbsp;OPUS_APPLICATION_AUDIO,&nbsp;&amp;opusRes);
                m_opusDecoder&nbsp;=&nbsp;opus_decoder_create(48000, 2,&nbsp;&amp;opusRes);
&nbsp;
<span style="color:blue;">                unsigned</span>&nbsp;<span style="color:blue;">char</span>&nbsp;data[BUFSIZE];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; opus_int32&nbsp;dataLength&nbsp;=&nbsp;opus_encode(m_opusEncoder,&nbsp;(<span style="color:blue;">short</span>*)Hdr-&gt;lpData,&nbsp;80,&nbsp;data,&nbsp;BUFSIZE);</pre>
    <pre style="font-family:Consolas;font-size:13;color:black;background:white;">                dataLength&nbsp;=&nbsp;opus_decode(m_opusDecoder,&nbsp;(<span style="color:blue;">unsigned</span>&nbsp;<span style="color:blue;">char</span>*)data, dataLength,&nbsp;(<span style="color:blue;">short</span>*)WaveHdrOut.lpData,&nbsp;BUFSIZE,&nbsp;0);
</pre>
    <pre style="font-family:Consolas;font-size:13;color:black;background:white;">                waveOutWrite(hWaveOut,&nbsp;&amp;WaveHdrOut,&nbsp;<span style="color:blue;">sizeof</span>(WAVEHDR));
</pre>
    <pre class="moz-signature" cols="72">-- 
Best regards,

 Stepan Melnichuk
</pre>
  </body>
</html>