Skip to main content
GameDev.net gamedev.net
🔒 Locked

Direct Sound Capture Buffer

Started by sheidkamp Dec 4, 2001 at 7:32 PM 1 replies 400+ views
Original Post
sheidkamp
sheidkamp
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.
Shannon Barber
Shannon Barber
In 8bit mode 128 is actually zero, it''s unsigned and shifted.

So 0 -> -128 and 255 -> 127

Increase the volume/unmute the input using the volume control (switch to the recording settings). Try turning the gain on for a mic input.

Magmai Kai Holmlor
- Not For Rent
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
sheidkamp
sheidkamp
Thanks,
I thought that anything going through the soundcard (ie, WinAmp) would show up in the Capture Buffer, but I guess its only the line in. I''m in business.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.