Original Post
Hi,
I''m trying to use the sound card as an input device, and using the following snippet of code (taken in a large part from the SDK docs) results in always getting a value of 127 or 128. Am I casting the void * array to a char wrong? Does anybody have any information about how the buffer stores the sound information... I assumed it was a simple time-ordered array of amplitudes/voltage through the sound card.
// Lock the capture buffer down
hr = pDSCB->Lock( blockNum*blockLength, blockLength,
&pbCaptureData, &dwCaptureLength,
&pbCaptureData2, &dwCaptureLength2, 0L );
soundBuffer = (BYTE *)pbCaptureData;
val = soundBuffer[rand()%blockLength];
// Unlock the capture buffer
pDSCB->Unlock( pbCaptureData, dwCaptureLength,
pbCaptureData2, dwCaptureLength2 );
and here''s the wave form def''n for the buffer:
WAVEFORMATEX wfx =
{WAVE_FORMAT_PCM, 1, 11025, 11025, 1, 8, 0};
If I look at the values that come out, its some way correlated to the sound, but obviouly not what I''m looking for (ie, why are 7 of 8 bits always the same?)
Any help would be appreciated,
Thanks.