#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Durham, UK
    Posts
    68
    Rep Power
    11

    Getting data i/p from a soundcard


    Hey, folks.

    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.
  2. #2
  3. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1510
    look at directx. You should be able to download the sdk for free from microsoft. There's also the windows Playsound() function.
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  4. #3
  5. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    243
    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.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Durham, UK
    Posts
    68
    Rep Power
    11
    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?
  8. #5
  9. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    243
    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.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  10. #6
  11. sardonyx quinx
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    156
    Rep Power
    11
    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.
  12. #7
  13. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    243
    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.

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Durham, UK
    Posts
    68
    Rep Power
    11
    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!
  16. #9
  17. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    243
    Just keep in mind that anything you learn with DirectX won't be portable to any other OS!

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw

IMN logo majestic logo threadwatch logo seochat tools logo