Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Surg AKA Kunark

Playing Sound?

This topic is 5546 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, ive been looking through the music and sound part of gamedev.net and have been having troubles getting the sounds to work. Could anyone help me out by telling me how i can get sound in my programs. Using GL and using Console. and any other way if possible.

Share this post


Link to post
Share on other sites
Advertisement
<< Hi, ive been looking through the music and sound part of gamedev.net and have been having troubles getting the sounds to work. Could anyone help me out by telling me how i can get sound in my programs. Using GL and using Console. and any other way if possible. >>

I have a question that goes with this. Just a beginner here, but I am using this simple function to play a wave file

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

That should play the wav file sound.wav if its in the same directory as your compiled .exe I believe. The include I use is

#include <mmsystem.h> // for PlaySound

However, I am getting a "linking error" with Visual C++ which reads

Compiling...
Linking...
GAMENAME.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12
Debug/GAMENAME.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

GAMENAME.exe - 2 error(s), 0 warning(s)

Not sure what to do. Is there another #include I need? Or might it be the "NULL" above in PlaySound?

Phil P

Share this post


Link to post
Share on other sites
Read the DirectX 9.0 docs, included with the DX 9.0 SDK. You can download the complete SDK here.

I followed the tutorials for "DirectX Audio", which is just explains the bare essentials for playing a sound file, and all my sound needs for my game were met.

Hope that helps.

-Q

Share this post


Link to post
Share on other sites
PhilVaz --

You should only have to #include <windows.h> to get the PlaySound function, since windows.h includes the header mmsystem.h

As for why you''re getting that error, it is because you are not linking with the library that is needed: winmm.lib

Depending on what compiler you are using, this may be done several different ways. An example: in visual studio you go to Project->Settings... which opens up a dialog box. It has a C/C++ tab that includes a textfield for static linked libraries, where you can enter winmm.lib

Surg --

Playing sound the easy way can be done with this PlaySound function, or you can use DirectSound and DirectMusic together to play the sound. If you''re anti-DX you can use OpenAL which is cross-platform but harder to interface and really is tailored for 3d sounds.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!