Help With DirectSound

So I am almost done with some code to make a 2D game in C++ and there is only one problem, no sound. I would like to use direct sound but if there is better code to use I’m willing to use it.

All the tutorials I tried online had some compiling error or something else wrong with it so if anyone has an example I could follow, it would be greatly appreciated. Thanks

Nobody… Really?

The most simple way to do this would be:

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

This should work for simple purposes. SND_ASYNC means the sound plays asynchronously, which means the program execution will continue when the sound plays. The opposite is SND_SYNC. SND_FILENAME means the sound is played from a file. The other option is playing a sound from a Windows resource, but that I will not explain here. In any case, Google is your friend.

If somehow this doesn’t suffice for your program (for example, when you need two sounds playing at the same time), then yes - have a look at DirectSound. Again, Google is your friend.

P.S: you would be better off looking for a good C++ forum. :wink:

You waited just over an hour before getting impatient? Do you have ADD or something?

An hour and a day actually. This forum is best viewed with your eyes open. :slight_smile:

^ Yeah I think I already tried it but it took a lot of system resources, but I’ll try it again. I’m working with OpenAL, and I compiled a few code samples yesterday with no problems. I’m going to write the code today and see how well it works.

Founded in 2004, Leakfree.org became one of the first online communities dedicated to Valve’s Source engine development. It is more famously known for the formation of Black Mesa: Source under the 'Leakfree Modification Team' handle in September 2004.