Playing Sound?

Started by
5 comments, last by Surg AKA Kunark 21 years ago
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.
~~Johnathan~~LTM my new fad, know it, use it, love it, LAUGHING TO MYSELF
Advertisement
~~BUMP~~
~~Johnathan~~LTM my new fad, know it, use it, love it, LAUGHING TO MYSELF
<< 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
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
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.
Greenspun's Tenth Rule of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified bug-ridden slow implementation of half of Common Lisp."
I recently started using fmod. It is pretty staright forward and the part that got me hooked is that it comes with all sorts of documentation and samples as well as being extremely simple to set up. Best of all it is platform independent.

http://www.fmod.org
Evillive2
maybe sdl would be easy, but just try playsound() for now

Trang
>>trang.myBigLongExecutableFileExtension>>ERROR: no such file or directory

This topic is closed to new replies.

Advertisement