Advertisement

Sound playing problem..

Started by January 31, 2001 07:00 PM
3 comments, last by ghostboy 24 years ago
I'm trying to play sounds using API in my console-text-game but it isnt quite working. I've included windows.h, and I'm trying to use sndPlaySound to play my wav file but it isnt working. My coding is sndPlaySound("c:\\windows\\desktop\\beep1.wav",0); Why won't this work? I'm getting the error.. Project1.obj : error LNK2001: unresolved external symbol __imp__sndPlaySoundA@8 Debug/Test Game.exe : fatal error LNK1120: 1 unresolved externals Any help for playing sounds using windows api? Edited by - ghostboy on January 31, 2001 8:04:24 PM
Link winmm.lib into your project and #include mmsystem.h.

you should use PlaySound instead of sndPlaySound
I''ve cranked some shitty example code here...

// global variables
BOOL g_bPlaying = false;

// play sound using waveOut device
void PlayTheDingSound( BOOL bLooping )
{
g_bPlaying = PlaySound(
"c:/windows/media/ding.wav",
NULL,
SND_FILENAME |
SND_ASYNC |
bLooping ? SND_LOOP : 0 );
}

// stop sound using waveOut device
void StopTheDingSound()
{
if( g_bPlaying )
g_bPlaying = !PlaySound( NULL, NULL, 0 );
}


Advertisement
Your code doesn''t error but no sound is played either

Hi,

Try "c:\windows\desktop\beep1.wav"
instead of

"c:\\windows\\desktop\\beep1.wav"

If it doesn''t wokrs, iI''ve made a little program who use FMOD.

You can download the source caode on my site :

http://slug-production.ibelgique.com

"Download" section and "FMOD-ENG" for english user.


========================
Leyder Dylan

dylan.leyder@ibelgique.com

========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
That looks like it should have worked, regardless of slashes. Of course, try \\ instead of \

You might want to check out BASS - it''s a great free audio library for WAV, MP3, MOD, ...

Can''t find the link immediately, I know I have it here though:
http://rsn.gamedev.net/sortedlinks.html

(blatant website plug in the process

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!

This topic is closed to new replies.

Advertisement