October 9th, 2003, 02:53 PM
Getting data i/p from a soundcard
I'm looking for information on writing to / reading from a soundcard. I have searched Google without finding anything useful, and I checked out the search on these forums; again without much success.
Basically, what i want to do is to use the card's adc to sample an incoming signal, then pass the sampled data onto my c program (for sig proc purposes). I have written code in the past to do this using an AMD29k processor, but never using a pc soundcard.
If anyone has any useful links or suggestions on the subject; I'd be grateful to hear them. I'm writing in a win98 environment with GCC.
All the best.
October 9th, 2003, 04:29 PM
look at directx. You should be able to download the sdk for free from microsoft. There's also the windows Playsound() function.
October 9th, 2003, 04:33 PM
Keep in mind that most modern OSs (Win2K, WinXP, *nix) won't allow you direct access to any hardware, so you will have to go through the OS API. DirectX is for Windows. In the old DOS world you had direct access to everything. If you want to bypass all the OS restrictions, either consider using a DOS equivelent or hacking the Linux kernel.
October 10th, 2003, 07:38 AM
Thanks for the replies, everyone.
Just to clarify -- if i work under windows at all; I can't directly access the sound h/w; and have to make calls via windows API. Presumably, this will allow for inter-OS compatibility (between win98 and win2k, for example); and inter-machine compatability (as i don't see the windows-soundcard dialogue)
The other option is to revert to dos or linux; but (i guess) this would give a very non-portable program (mem addresses of cards will change between machines, etc).
I think i see how that goes. One more question though -- what would you reccommend for a real-time system? Is access through the API up to that?
October 10th, 2003, 08:06 AM
If you are doing real-time programming do NOT use Windows, Linux, or any other standard, multi-user commercial OS. You cannot depend on your RT program being executed at any given instant as execution windows are based on machine load, queue status, hardware interupts, etc. RT OSs have almost all the windowing programming stripped out and very sensitive kernels that are heavily optimzed. If you are running on human reaction speeds, a lightly loaded Windows/*nix box will likely work fine, but if you are working on milisecond (or less) time frames, even with a machine that has no other user processes running will give you variable and inconsistant results. Even in DOS you can wind up with problems. It is not for nothing that a lot of hardware cards have almost as much processing power and memory as the CPU!
A note on using Windows APIs on Win9X/ME vs NT derived (NT, Win2K, XP): Since the 9x versions do not protect the hardware, some of the API interfaces in those OSs return without doing anything, which can cause problems porting to NT derived versions. Conversly, writing to the NT versions may cause unexpected behavior on the 9x versions. Also, there are differences in behavior in the various DirectX versions (it is only starting reach maturity at version 9), start with the most recent version you can get your hands on if you go that route.
October 10th, 2003, 08:21 AM
How about using FreeBSD or OpenBSD in developing for a program in getting data i/p from a sound card?
I'm not really aware about this kind of stuffs but I'm trying to cope up with the thread in this forum category.
Thank you mitakeet for those replies. I have read your other replies from previous threads and your opinion/reply is honest and reliable, for me.
October 10th, 2003, 08:29 AM
For real time programming, all BSD varients are the same as Windows/Linux, you can't depend on execution start or durations. As for hardware access, they use APIs just like Windows, though I have no idea what. I expect that the various *nix flavors have different APIs, though there may be free libraries that will conceal the various formats. I am a number cruncher by trade, doing most of my programming in ANSI which has no facilities for sound/video/etc., and only recently have been playing around with hardware level coding (I am working on a firewall for Windows, a real pain in the ***!), so I can't offer much advice on how to do it.
I appreciate your comments, it is nice to be able to share some of my painfully aquired experience and perhaps save some people some headaches.
October 10th, 2003, 10:21 AM
I guessd that windows probably wasn't much good in terms of RT. Like i mentioned, I've only ever done RT stuff on a dedicated AMD29k processor; which is a different kettle of fish!
Unfortunately, i'm a bit limited in terms of equipment right now; so perhaps i'll look into the directx solution with a view to eventually moving to a dedicated hardware solution in time.
Thanks again to everyone for the insights and suggestions!
October 10th, 2003, 10:48 AM
Just keep in mind that anything you learn with DirectX won't be portable to any other OS!