Re: Sound Card read Data

From: Corey Murtagh (emonk_at_slingshot.no.uce)
Date: 04/17/04


Date: Sun, 18 Apr 2004 07:59:31 +1200

barmagan@transvaro.com.tr wrote:
> Hi,
> I want to read realtime data from sound cards R/L channels.
> I've found sources of an oscilloscope program using
> waveIn*** APIs. Program transfers sound card buffer to an
> other buffer. But I couldn't modify the source in order to
> read only the current realtime data, because I don't
> understand how these APIs and sound card work.
> I can only init (waveInOpen) and start the A/D conversion
> (waveInStart). but I don't know the procedure (which APIs
> to use and How) for reading realtime data from both
> channels. Can you help me?

You need to prepare a set of buffers (at least 2 for seamless capture)
using the waveInPrepareHeader function, start the waveIn device, then
process messages/callbacks from the device. You will get a message (or
callback) each time one of the buffers fills up, at which point you call
waveInUnprepareHeader, copy the data from the buffer, then re-prepare it.

Using two (or more) buffers ensures that the waveIn device continues to
capture while you're working with the current buffer. It's quite
possible on a reasonably fast machine to use two smallish buffers - say
20ms each - if you're not doing too much with the data. The larger the
buffer the larger the lag between your program and real-time.

-- 
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"


Relevant Pages

  • Re: Mystic Playback stops problem with waveInPrepareHeader, waveInAddBuffer etc.
    ... > modern sound cards you are probably ok reusing accross AddBuffer ... > If you use a thread for wavein and another thread for waveout, ... > have a sufficiently deep record buffer pool, ... > into any performance issues when preparing/unpreparing with every use. ...
    (microsoft.public.win32.programmer.mmedia)
  • WaveIn Problem in XP
    ... This won't make much sense unless you have used waveIn functions to ... record wave files. ... When the buffer is filled with wave data it sends a MM_WIM_DATA message ...
    (comp.lang.pascal.delphi.misc)
  • Re: Can someone explain how to correctly use Low level Digital Audio A
    ... You have to have more than one buffer and associated WaveHdr structure ... All that starts the waveIn recording. ... PtrWaveHdr: PWaveHdr; ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: callback function immediatly called with an empty buffer
    ... > I try to record a wavefile with wavein API. ... > Waveinprepareheader and waveinAddbuffer work fine, with a waveheader ... > buffer large to hold a few seconds audio. ... > Strangely, just after waveinstart, the callback function is executed, ...
    (microsoft.public.win32.programmer.mmedia)
  • Sound Card read Data
    ... I want to read realtime data from sound cards R/L channels. ... waveIn*** APIs. ... understand how these APIs and sound card work. ...
    (comp.programming)