Thread: C Sound codes

  1. #1
    Deleting... VOX's Avatar
    Join Date
    Oct 2004
    Location
    VA
    Posts
    94

    C Sound codes

    Hi. I'm new here, and I have been programming C for about a quarter of a year, but only just started again because of a long break.

    Glad that's out of the way.

    Does anyone know the correct hertz for all the musical notes?
    In C for Dummies: Vol. 2 in the back it lists them but I am certain that the hertz number does not match the note listed. For an example of what I am talking about:

    Middle G = 392 hertz.

    Also do you know how to change the way the speaker in the PC beeps? Or how to make different noises with the PC or normal speakers.

    A lot to ask, but you don't have to answer all of that if you are in a bad mood.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Playing sound through the sound card (or normal speakers as you call them) is OS dependent. Probably the easiest way to play sound in windows is using DirectSound which is part of DirectX. If you download the DirectX SDK, there are examples on how to do this.

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    The 'A' above middle C is 440 hz, this is standard concert pitch.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    >> Does anyone know the correct hertz for all the musical notes?
    Google("musical note hertz conversion")

    If you're not running Me, 98, or 95, an alternative to DirectSound is the Beep() function.

    gg

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    143
    Take a look here: http://www.math.niu.edu/~rusin/paper...ic/frequencies for a list of frequencies mapped to notes for standard (440Hz) tuning. The rest of the site is quite a good insight into how music works mathematically if you are interested in that sort of thing...
    DavT
    -----------------------------------------------

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sound lags in multi-thread version
    By VirtualAce in forum Game Programming
    Replies: 23
    Last Post: 08-27-2008, 11:54 AM
  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. sounds?
    By BODYBUILDNERD in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2002, 03:34 PM