sound

Pages: 12
May 20, 2011 at 6:24pm
I need to know how to use a sound with the windows program.
Sutch as when you push a button it will play a sound.
Without useing the Beep(,); command.

do you have eny idea?

I LOVE REPLIES!
May 20, 2011 at 6:37pm
If you just want to play .wav files, the easiest way is with PlaySound:

http://msdn.microsoft.com/en-us/library/ms712879(v=vs.85).aspx

Samples included on that page.
May 20, 2011 at 7:11pm
The Microsoft web page did not help. Do you have eny more ideas?
May 20, 2011 at 10:21pm
That web page he gave you tells you everything you need to know to play a simple windows sound in a Window program. You can set to play when a button is pushed or when some other action is performed. What exactly is it that you don't understand?
May 20, 2011 at 10:40pm
The Microsoft web page did not help.


There are examples at the bottom of the page.

You should be able to copy/paste and sub in your information.

If that isn't good enough for you I don't know what else we could do.
May 20, 2011 at 11:28pm
I tride to compile and run but it dose not use a sound!
can you give me an exampol?
May 20, 2011 at 11:43pm
Do you have a .wav file that you want to play? If yes, you can use this example:

PlaySound(TEXT("recycle.wav"), NULL, SND_FILENAME);

Do you want to play one of the built-in system sounds? If yes, you can use this example:

PlaySound((LPCTSTR)SND_ALIAS_SYSTEMSTART, NULL, SND_ALIAS_ID);

Note that both of these examples are just copy/pasted from that page I linked.
May 25, 2011 at 9:46pm
When i compiled it said

[Linker error] undefined reference to `PlaySoundA@12'
May 25, 2011 at 10:15pm
You'll have to link to winmm.lib

How you do that depends on what IDE you're using. Is this VC++?
May 25, 2011 at 10:19pm
C++
May 25, 2011 at 10:20pm
How do you link winmm.lib?
May 25, 2011 at 10:24pm
C++ is a language, not an IDE.

When you open your C++ program to write code, what is that program called? Is it Microsoft Visual C++?
May 26, 2011 at 2:37am
dev-cpp
May 26, 2011 at 2:35pm
I'm afraid I'm not familiar with how to use that particular IDE.

However a google search of "Dev C++ how to link libraries" turned up this page:

http://www.bloodshed.net/faq.html#9

Do that, but try linking to -lwinmm instead of -lopengl32 like it is saying.
May 26, 2011 at 2:50pm
ty98, DevC++ is not an advisable IDE to use: http://www.cplusplus.com/forum/articles/36896/
May 27, 2011 at 8:33am
Disch wrote:
How you do that depends on what IDE you're using. Is this VC++?
ty98 wrote:
C++
Disch wrote:
C++ is a language, not an IDE.


I rofl'd.

If you're having difficulty, I'd recommend dropping bloodshed... I'd pick up code::blocks, or heck even VC++express.

INSTRUCTIONS for bloodshed:
Select the project file in the File view, select Project => Settings , and then select the Link tab.

Add winmm.lib to the Object/library modules entry. To do this in Dev-C++, right-click on your project and select Project options. The Project options window opens.

In the Linker Options/Optional Libs or Object files field, enter -lwinmm

May 27, 2011 at 8:38am
heck even VC++express

Awww :( VC++ Express is awesome. IMO the Code Prediction & documentation popups beats Code::Blocks anyday. And more of C++0x seemed to work as well.
May 27, 2011 at 9:37am
Oh, and also SFML will do what you want. http://sfml-dev.org/

You can load and play a sound with it in three lines I think. And handling input isn't many more.
May 27, 2011 at 2:50pm
I would definitely switch to VC++ express if you are having problems here. IMO, only people who know what they are doing should be using other compilers/linkers, as there is far more support for MS VS.
May 27, 2011 at 9:06pm
What is VC++?!?!?!
Pages: 12