Thread: Sound Tutorial

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    1

    Sound Tutorial

    Does anyone know where I can get a good sound tutorial for C++?

  2. #2
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    For DOS or Windows or what?

    For DOS i use PlaySound().
    I don't do windows yet

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    well, sound is not part of C++, so you might wanna try an api like SDL(libsdl.org).

  4. #4
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    For Windows it's really simple.

    Make sure you include winmm.lib in your linked library files.

    Make sure you include mmsystem.h
    #include <mmsystem.h>

    Use PlaySound to actually play the sound.
    PlaySound("dice.wav",NULL,SND_FILENAME | SND_ASYNC);

    In this case "dice.wav" is the name of a *.wav file that is in the root directory of my project.

    The second param is NULL if you are playing your *.wav from a file (as opposed to playing it from a resource, in which case this param would be the handle to the executable file that has the sound resource).

    The last param lists the flags for playing the file. To play a sound from a *.wav file you only need: SND_FILENAME - tells it that the first param is a filename of the sound to play ** and ** SND_ASYNC - tells it that the sound is to play asynchronously and the function will return immediately after the start of the sound (as opposed to SND_SYNC in which case it plays back synchronously and the function returns after the sound ends).

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