Thread: Sound Cards With C++

  1. #1
    Registered User
    Join Date
    Sep 2004

    Sound Cards With C++

    I've decided to take on my most challenging project yet. A guitar FX "peddle". The only problem is I don't know how to read a "live stream" from the sound card in windows.

    A guitar will be plugged into the microphone jack (with the help of an adapter ) . The program will need the to know frequency and possibly the duration of the frequency. It will then perform mathematical calculations on the frequencies and play back the new frequencies.

    1. How would I address the sound card (i.e., is it a com port, file, etc.)?
    2. How will I know the duration of the frequency?

    Also, I would like to stick with to standards, but it's not necessary.

    Asm is also an alternative (actually, i plan on using asm for some parts)
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    For a portable solution you may want to check out fmod.

    The Windows specific APIs you could be interested in are Waveform Audio (samples and articles here) or possibly DirectSound.

    >> 2. How will I know the duration of the frequency? <<

    The sound data will be returned as a series of samples. If you need the duration of a specific frequency you will need to combine adjacent samples with the same frequency. Remember, there is likely to be some randomness during sound recording so the exact same frequency is unlikely.

  3. #3
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Frequency analysis requites some serious mathematics (Fourier transforms).
    MSVC++ 6.0

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Frequency analysis requites some serious mathematics (Fourier transforms).
    Actually, you can find code examples or libraries for FFT (Fast Fourier Transform). fmod may even include it, so, you don't have to do the math yourself.

    I have a book called Digital Audio Processing, by Doug Coulter. He supplies the source code for a complete audio editor. As I recall, he doesn't discuss how varioius guitar effects work, but if you have an idea what an effect does (distortion, filter, compression, etc.) the book will help you program it.


    The PC is great for processing a pre-recorded wave file. But if you want a real-time (live) effect, it could be tricky or unreliable. Windows uses cooperative multitasking, which means you can't count-on having control of the CPU and data bus when you need it. Your data stream can be interrupted.

    Normal Windows programs get-around the multitasking problems by using an input buffer, and/or an output buffer. As long as the buffers don't "run dry" or overflow, and as long as the CPU is fast enough, the PC can provide a continuous, but delayed, audio (or video) stream.

    It may be possible to get acceptable results (imperceptible delay) with DirextX. Some software/sound cards use low-latency ASIO drivers for real-time audio processing. (I don't know how these work.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help it won't compile!!!!!
    By esbo in forum C Programming
    Replies: 58
    Last Post: 01-04-2009, 03:22 PM
  2. Low latency sound effects
    By VirtualAce in forum Game Programming
    Replies: 0
    Last Post: 12-21-2004, 01:58 AM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  4. DirectSound - multiple sounds
    By Magos in forum Game Programming
    Replies: 9
    Last Post: 03-03-2004, 04:33 PM
  5. Cribbage Game
    By PJYelton in forum Game Programming
    Replies: 14
    Last Post: 04-07-2003, 10:00 AM