playing sound and linking?

Hello, I am using wxDev-C++, and I'm trying to make my program play the windows chimes.wav file after the program hits a certain point, but I have been researching how on google about PlaySound() and still no idea how to do it. I have very little experience linking and making a project, I've only used 'file -> new -> program source code' when I create a new program because it doesn't require linking or setting up a project and I can press F9 to compile and run. I know about Beep() from <windows.h> but I want to use my own custom sounds.

Can anyone help me shed some light on this topic? Maybe on what I need to download or what project I need to create or how to link.. or a tutorial somewhere I can read etc.. Help is as always greatly appreciated!
closed account (D80DSL3A)
I posted some working PlaySound code in an earlier thread:

http://www.cplusplus.com/forum/windows/29294/

It is a simple windows program which is setup to play different .wav files using the keyboard.
Hopefully you can adapt it to your specific needs.


Hi I am curious does you all incorporate sounds into your programs or games ? I am considering but still I need someone voice to record the raw .wav files correct ? Which sound recording software you all using ? Preferably free :)

Usually I observe lady voice will 'attract' game players more. Is it the same old classic s*x oops I mean voice sells concept again ? :P

Last edited on
@fun2code Thank you very much for the code. I can understand about half of it but I'm sure I'd be able to understand more of it as I tinker around with it.

I have a question: For the playSoundShell.cpp code you posted, do I have to create a certain type of project and/or link to something to compile and run? I use wxDev-C++ and I have a lot of trouble working with "projects" because I have no idea what project does what right now.

@sohguanh I don't know much about recording sound but Windows have a Sound Recorder that is free
Last edited on
closed account (D80DSL3A)
You're welcome. The code is pretty self contained so there shouldn't be any need to link to other code. All include directives needed are contained in the example.
I don't use wxDev-C++ so I don't know how projects are created there. Hopefully an empty project will do. Just add one cpp file, paste the code into it and see if it works.

Remember: You will have to supply .wav files in the same folder that the exe file is in. Modify the file names near the top of my code to match what you set up for your sound file locations.
These lines:
LPCTSTR soundA = L"AudioClips\\GameOpen.wav";

My sound files are in a folder named AudioClips here.
Topic archived. No new replies allowed.