CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2008
    Posts
    93

    Getting input from Soundcard

    Hi @ all,

    is it possible to catch if the soundcard gets any input with basic c++, also without any windows methods? I ask this to try to make my application os undependent.

    Greetz
    Crazy

  2. #2
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: Getting input from Soundcard

    No.
    Every OS uses a different method. Windows has several APIs, whereas Linux has a device that takes read/write with ioctl calls.

    To be OS independant you would need a third party API that undefneith calls the local OS's soundcard functions. You could probably do this yourself by using complier directives.

    There are several APIs for Windows:
    MMAPI: Plus: Been around forever (Win 3.0), fairly simple. Minus: Can have latency issues and be processor intensive.
    DirectX: Plus: Fast, simple. Minus: Poorly documented. API calls but no explanation.
    ASIO: Plus: Fast. Minux: Requires 3rd party drivers.
    WDM: Plus: Fastest. Directly uses kmixer. Minus: Not documented at all. (I have been trying to find info on this for ages.)

    Good luck,
    -Erik

  3. #3
    Join Date
    Sep 2008
    Posts
    93

    Re: Getting input from Soundcard

    Ok thanks for the info. Then I have to switch between the different os´s.

  4. #4
    Join Date
    Aug 2005
    Location
    LI, NY
    Posts
    576

    Re: Getting input from Soundcard

    Portaudio is a pretty good cross-platform sound library that you could use. If you're a novice programmer and don't want to muck about with a separate thread for audio, this library is particularly neat in that it supports blocking I/O, which allows you to capture sound card input in a streams-like manner.

    Detecting sound card input, however, is not something supported by most sound APIs (as far as I know). You could accomplish this by looking for samples in the sound input that exceed a reasonable noise threshold and firing some sort of event if one is encountered. The trick here is to use a time-out, i.e. the maximum interval between the current sample and the last non-silent sample, to detect when the input source has stopped (and therefore when it is okay to fire another input detection event).
    - Alon

  5. #5
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    Re: Getting input from Soundcard

    Any other cross platform API ?

    Is this used for capture sound and play sound ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured