<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div>I have read the speex manual, looked at the example code, but for some reason the first encoded byte does not have the wideband bit set and the mode bits are also wrong even though I am encoding in wideband mode.</div><div><br>I am sure that I am doing something wrong, but I can't figure out what it is.<br><br>I have included my code below....<br></div><div>I would expect that the MSB of the first encoded byte is 1 (wideband) and that the next 4 bits would be 8 (because I requested mode 8)...but this is the mapping I see</div><div><br>here is my code</div><div>&nbsp;</div><div>&nbsp;</div><div><strong>Init Encoder:<br></strong>speex_bits_init(&amp;thisEncoder-&gt;bits);<br>thisEncoder-&gt;speexEncoderInstance = speex_encoder_init(speex_lib_get_mode(SPEEX_MODEID_WB));<br>speex_encoder_ctl(thisEncoder-&gt;speexEncoderInstance,
 SPEEX_SET_QUALITY, &amp;encodermode);<br>&nbsp;<br>where encodermode = 8<br>&nbsp;<br>&nbsp;<br><strong>Init Decoder:</strong><br>thisDecoder-&gt;speexDecoderInstance = speex_decoder_init(speex_lib_get_mode(SPEEX_MODEID_WB));<br>speex_decoder_ctl(thisDecoder-&gt;speexDecoderInstance, SPEEX_SET_QUALITY, &amp;decodermode);<br>speex_bits_init(&amp;thisDecoder-&gt;bits);<br>&nbsp;<br>where decodermode = 8<br>&nbsp;<br>&nbsp;<br><strong>Encode:</strong><br>/* Reset bitstream */<br>speex_bits_reset(&amp;thisEncoder-&gt;bits);<br>/* PCM -&gt; Bitstream */<br>speex_encode_int(thisEncoder-&gt;speexEncoderInstance, pAudiodataIn, &amp;thisEncoder-&gt;bits);<br>/* Bitstream -&gt; Byteblock */<br>nBytes = speex_bits_nbytes(&amp;thisEncoder-&gt;bits);<br>nBytes = speex_bits_write(&amp;thisEncoder-&gt;bits, (i8*) pEncodedAudioOut, nBytes);</div><div>firstbyte = (pEncodedAudioOut[0] &gt;&gt; 3) &amp; 15;<br>printf("Actual mode: %d \n", firstbyte);<br>wideband =
 (pEncodedAudioOut[0] &gt;&gt; 7);<br>printf("Wideband: %d \n", wideband);<br>&nbsp;<br>&nbsp;<br><strong>Decode:</strong><br>/* Byteblock -&gt; Bitstream */<br>speex_bits_read_from(&amp;thisDecoder-&gt;bits, (i8*) pEncodedAudioIn, (int) thisDecoder-&gt;payloadSize);</div><div>/* Bitstream -&gt; PCM */<br>speex_decode_int(thisDecoder-&gt;speexDecoderInstance, &amp;thisDecoder-&gt;bits, pDecodedAudioOut);<br>speex_bits_reset(&amp;thisDecoder-&gt;bits);<br>&nbsp;<br></div><div>&nbsp;</div><div>&nbsp;</div><div>What am I doing wrong?&nbsp;</div><div>&nbsp;</div><div>Thanks.</div><div><var id="yui-ie-cursor"></var>&nbsp;</div></div></body></html>