Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18013
Number of posts: 55386

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Getting data from the soundcard Posted by Lorq on 12 Apr 2002 at 1:51 AM
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

Report
Re: Getting data from the soundcard Posted by JamesFos on 17 Apr 2002 at 12:10 PM
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?

Report
Re: Getting data from the soundcard Posted by mfroeb on 12 Nov 2002 at 5:58 AM
: 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


Strange things happen ...


Don't forget to visit http://aac.net.tf for the best cd ripper for windows!




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.