SV: [Speex-dev] converting 16-bit samples in LPSTR to short
Jonas Tärnström
njt at home.se
Sat Sep 16 11:52:40 PDT 2006
What kind of crazy old Win32 API is that?
Ive used DirectSound and WinMM and never needed to do something like
what you are doing.
AFAIK, all existing Win32 APIs for capturing sound returns buffers of
16-bit PCM data, assuming PCM was specified as buffer format.
//JT
-----Ursprungligt meddelande-----
Från: speex-dev-bounces at xiph.org [mailto:speex-dev-bounces at xiph.org] För
Peter Gien
Skickat: den 16 september 2006 16:48
Till: speex-dev
Ämne: [Speex-dev] converting 16-bit samples in LPSTR to short
Hi,
I am capturing 16 bit mono sound samples using some Win32 API function
calls. These function calls return the sound samples in an array of
characters. My assumption is that this array of characters represents
pairs of bytes that make up a short integer.
I'm using the following code to convert the samples:
LPTSTR *lpSaveBuffer;
......
for(j=0;j<nBytes;++J)
{
BYTE a = lpSaveBuffer[2*j]; // left byte
BYTE b = lpSaveBuffer[2*j + 1]; // right byte
short sample = (a << 8) | (b & 0xff);
}
I'm getting garbage as a result of this conversion. Any help would be
appreciated.
Thanks,
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20060916/60786246/attachment.htm
More information about the Speex-dev
mailing list