Thread: Sound

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    email for MystWind avatar MystWind's Avatar
    Join Date
    Feb 2005
    Location
    Holland , The Hague
    Posts
    88
    this is what I allready came up with :

    Code:
    PlaySound("ding.wav",NULL,SND_ASYNC|SND_FILENAME);
    but I include it this way : [CODE]#include "ding.wav"[\CODE]
    didn;t work.

    edit : [CODE]
    #include "ding.wav"

    main() {

    PlaySound("ding.wav",NULL,SND_ASYNC|SND_FILENAME);

    return 0;
    }[\CODE] this one works but its doesnt plays the sound..

    edit: I;ve found a new clue... give me a moment and don't mention me till then.
    Last edited by MystWind; 05-09-2005 at 01:48 PM.
    PLay MystWind beta , within two years

  2. #2
    email for MystWind avatar MystWind's Avatar
    Join Date
    Feb 2005
    Location
    Holland , The Hague
    Posts
    88

    Unhappy nope

    nope didn;t work out as i hoped it would:9 I'll just post my code :S can't do it alone.

    test.cpp
    Code:
    #include "ding.wav"
    #include "Mmsystem.h."
    #include "Coredll.lib."
    
    
    main() {
           
           PlaySound("ding.wav",NULL,SND_ASYNC|SND_FILENAME);
           
           return 0;
           }
    then i have ding.wav <-- the sound. and the automaticly created piece of code the dev compiler creates when you make a Windows application , headers :

    Code:
     #include <windows.h>
                #include "Mmsystem.h."
    sorry for the trouble.. I hope you guys can and are willing to help an old friend ( hmm....:P)
    PLay MystWind beta , within two years

  3. #3
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    Try this code:

    Code:
    #include "windows.h"
    #include "Mmsystem.h."
    
    
    main()
    {
    
        PlaySound("ding.wav",0,SND_SYNC|SND_FILENAME);
        return 0;
    }
    make sure that you link to winmm.lib

    for some reason the SND_ASYNC "works" on mine too but doesn't play the sound, but The SND_SYNC works and plays the sound

  4. #4
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    You must include the
    Code:
    #include <windows.h>

    Its a windows function.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by Darryl

    for some reason the SND_ASYNC "works" on mine too but doesn't play the sound, but The SND_SYNC works and plays the sound
    Probably because your program exits before the sound has a chance to play.

  6. #6
    Tropical Coder Darryl's Avatar
    Join Date
    Mar 2005
    Location
    Cayman Islands
    Posts
    503
    Quote Originally Posted by Quantum1024
    Probably because your program exits before the sound has a chance to play.
    Hey, you are absolutely right... I added a while (true) loop to keep it running and async worked perfectly.

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. Help me modify my Sound Server
    By zdude in forum C Programming
    Replies: 1
    Last Post: 05-14-2003, 05:15 PM
  5. sounds?
    By BODYBUILDNERD in forum C++ Programming
    Replies: 6
    Last Post: 12-06-2002, 03:34 PM