Thread: connect to sound card

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    161

    connect to sound card

    1. How do I connect to a sound card?

    2. After connecting I wanting to send signals there how do I do that?

    3. What is the format of the signals that I send have to be in?

    I know I can use windows api's to acheive all of this more easily, but I want to see if it is possible to take a sound such as a person saying "a" and making it say anything by changing the frequency adding and changing things.

    Thanx in advance!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Here is perhaps worth a read through
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    1. & 2. You almost have to use the Windows API/Drivers. This does not mean that you have to write a full-GUI program. The sound card manufacturers don't usually seem to publish the specs necessary to communicate directly with their cards. The manufacturer writes a driver that interfaces with the OS/API in a standard way.

    Also, the newer versions of Windows won't allow you to access a hardware address in "user mode". (You can access the hardware with Win98.) You have to use a kernel mode driver. Writing a kernel mode driver is not trivial.

    3. There are 3 ways to get sounds. The 1st way is to send a stream of "samples" that form the "wave". This is how .wav and .mp3 files are played.

    The 2nd way is with MIDI. MIDI is generally for simulating musical instruments. With MIDI, you basically send some set-up information (i.e. to make a guitar sound) and then send the notes. Games usually use lots of MIDI because it doesn't require much CPU processing power, or bus-bandwidth. You just send the "musical notes" and the sound board does the processing. I think MIDI is what you want to use.

    The 3rd way is to send analog sound directly to the sound card. This is what happens when you play a music CD in you computer. The CD drive has it's own Digital-To-Analog converter, and the sound goes directly to the sound card via an analog cable. This puts no load on your CPU or data bus.

    [EDIT]
    Try searching microsoft.com for "Text-To-Speech". I believe you can download their TTS engine and some sample code. TTS seems to be included with WinXP.
    Last edited by DougDbug; 01-22-2004 at 06:47 PM.

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    161
    While I was researching I came across a function called _outp and _inp. _outp will connect to a port and send a byte to that port. Will I be able to use _outp to send signals to the sound card or there is another way? If I use _outp depending on what slot the sound card is in the mother board will set the value of the port adress to use. How can I search for a sound card? I know this is possible because no matter where I plug in my video card to the motherboard somehow it finds the video card and uses it to display.

    Thanx in advance!
    Last edited by Benzakhar; 01-22-2004 at 08:33 PM.

  5. #5
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Unhappy Don't try this at home !

    The sound card has a range of hardware addresses assigned to it via the "plug and play" process. (Older ISA-slot cards used to have their address set by DIP switches.) So, it doesn't matter which slot it's in.

    You can find-out the address thru the control panel:
    Start/Settings-> Control Panel-> System/Device Manager-> Sound Video & Game Controllers)-> (Your Sound Card)-> Properties-> Resources. Of course, if you know what you're doing, your program can get this info from the registry. (And no, I don't know what I'm doing.

    So, you can read and write bytes or words to and from the sound card. But, the real problem is to find-out the protocol / format of the data. Maybe you can get some specs from the soundcard manufacturer. Maybe the manufacturer uses an industry standard or psudo-standard. Like I tried to say above, normally, the standardized protocol interface is between the driver and the API. The sound card manufacturer does not have to disclose how to communicate with the hardware. They only have to disclose how to communicate with the driver. Or just supply a driver that communicates with the OS in a way specified by the OS manufacturer.

    The only good news is that many Linux drivers are written by 3rd parties. These people need the info you are looking for, so it is available for some cards. And, many cards are "Soundblaster compatable" or "Roland compatable", and these may have common interface, and the specs may be available somewhere.

    Use the manufacturer's driver and the OS API! Reading and writing bytes to and from the sound card is essentailly writing your own driver, and this is freeking difficult! Don't try this at home!

    Also: _outp and _inp are system-specific. The are not portable-standard C++. They will generate an "access violation" error on WinXP.
    Last edited by DougDbug; 01-22-2004 at 10:42 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bitwise Unwanted Output
    By pobri19 in forum C++ Programming
    Replies: 4
    Last Post: 09-15-2008, 04:07 AM
  2. Vector out of range program crash.
    By Shamino in forum C++ Programming
    Replies: 11
    Last Post: 01-18-2008, 05:37 PM
  3. Blackjack
    By Tommo in forum C Programming
    Replies: 10
    Last Post: 06-20-2007, 08:07 PM
  4. How can I access a struct (from a header file)?
    By loxslay in forum C++ Programming
    Replies: 3
    Last Post: 10-07-2006, 01:25 PM
  5. Low latency sound effects
    By VirtualAce in forum Game Programming
    Replies: 0
    Last Post: 12-21-2004, 01:58 AM