<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=477203116-16092006><FONT face=Arial color=#0000ff size=2>Is
"nBytes" what it says -- the number of bytes in the buffer? If so, you're
overshooting the buffer by 2x by multiplying by 2 in your array access.
You probably want a variable called "nSamples" that represents the number of
16-bit words.</FONT></SPAN></DIV>
<DIV><SPAN class=477203116-16092006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=477203116-16092006><FONT face=Arial color=#0000ff size=2>Also,
if this is a little-endian (Windows on x86?) machine, you're reassembling
the word backwards.</FONT></SPAN></DIV>
<DIV><SPAN class=477203116-16092006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=477203116-16092006><FONT face=Arial color=#0000ff size=2>Not to
mention, shifting a BYTE left by 8 inside those parentheses is probably turning
it into 0. If you actually need to swap the bytes, try casting to
a short before shifting.</FONT></SPAN></DIV>
<DIV><SPAN class=477203116-16092006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=477203116-16092006><FONT face=Arial color=#0000ff size=2>--
john</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT><BR>for(j=0;j<nBytes;++J)
<BR>{<BR> BYTE a =
lpSaveBuffer[2*j]; // left
byte<BR> BYTE b = lpSaveBuffer[2*j + 1]; // right byte
<BR> short sample = (a << 8) | (b &
0xff);<BR>}<BR><BR>I'm getting garbage as a result of this conversion. Any help
would be appreciated.</DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"> </BLOCKQUOTE></BODY></HTML>