Getting data from the soundcard

Hi,

I wondered if it is possible to get data from the soundcard, process it and then display the result.
For instance, i want to read the input, do a fourier and then display a waterfall-display or amplitude values.
What do you need to do this ?

1. A connection to the soundcard
2. A buffer that contains the read data, size wil be variable (?) whats the format ?
3. A way to convert the incomming data to a usable bin-format so you can do stuff like FFT.

Knowing this is a large undertaking and probably VB is to slow to do this but as far as i know
it has not yet been atempted (cannot find any example or code on the web)?

Now the thing you dont want is first make a .wav file and then read the data from there, it has to
be "real-time" (from a .wav-file is done / code is available on the net).

Who can help ?

Jay

Comments

  • You can do it in C. That much is obvious.

    To do it in VB you inport the funcitons using the API viewer (or if you know it or find it another way type it directly).

    the functions you need are...

    waveInGetNumDevs
    waveInGetDevCaps
    waveInOpen
    waveInPrepareHeader
    waveInAddBuffer

    This will get you so far. As far as placing a buffer onto the sound card for it to fill with data from it's input. It pretty much in that order. Read the MSDN for more information on each of these.

    To get at the information once the soundcard has filled the buffer with the data, i'm not too clear on myself. I would imagine you call WaitForSingleObject using the handle given to you by waveInOpen which would return once the buffer was full. But of this i'm not certain. Maybe someone else could clue us both in.

    HTH James




    ----------------

    What does God need with a starship?

  • : You can do it in C. That much is obvious.
    :
    : To do it in VB you inport the funcitons using the API viewer (or if you know it or find it another way type it directly).
    :
    : the functions you need are...
    :
    : waveInGetNumDevs
    : waveInGetDevCaps
    : waveInOpen
    : waveInPrepareHeader
    : waveInAddBuffer
    :
    : This will get you so far. As far as placing a buffer onto the sound card for it to fill with data from it's input. It pretty much in that order. Read the MSDN for more information on each of these.
    :
    : To get at the information once the soundcard has filled the buffer with the data, i'm not too clear on myself. I would imagine you call WaitForSingleObject using the handle given to you by waveInOpen which would return once the buffer was full. But of this i'm not certain. Maybe someone else could clue us both in.
    :
    : HTH James
    :
    :
    :
    :
    : ----------------
    :
    : What does God need with a starship?
    :
    :

    you have first to open the device with waveinopen(...), then create two or more headers (wavhdr), equal number of buffers (byte array), prepare them all with waveinpreparebuffer(...), send them all to the device with waveinaddbufer(...), and start recording with waveinstart(...).
    then if a buffer is full (use at least 1/2-second-buffers) the callback function you specified in the call to waveinopen will be called with the filled buffer resp. header. you then have to save the data to somewhere else where you can process it, and add the buffer again.
    if you're finished, call waveinreset(...) to stop recording, then waveinclose(...) to close the device. half-filled buffers will be returned to you, via callback function. then process the data as you'd like to.
    vb hangs when calling waveinreset(...) somehow, if you step through with the debugger, everything behaves ok. you should insert sleep(0) calls then.

    i'm currently programming a multi-source-recording program to record our school choir in dolby digital 5.1.

    markus
    [hr]
    Strange things happen ...
    [hr]
    Don't forget to visit [blue][b]http://aac.net.tf[/b][/blue] for the best cd ripper for windows!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories