Advertisement

sound in windows

Started by March 28, 2000 12:07 PM
5 comments, last by ettamme 24 years, 5 months ago
Hey guys, i am looking for a simple way to play .wav files in windows without using any directx or any other outside things. Just plain o''l windows. Im actually using a book Called tricks of the windows game programming gurus, and it tells you how to play waves using PlaySound, but its rather vague. So if somone could explain it in detail or give another idea of how to play wav''s that would be great! Thanks, ~Eric
"there is beer coming from the chimney, code 3, I am proceeding on foot,i repeat bring pretzles."
Your compiler probably comes with some sort of Win32 reference, try looking up PlaySound() in it, this will probably make things more clear.

I think the function is located in som dll called winmm.dll but I'm not sure...

/. Muzzafarath

Edited by - Muzzafarath on 3/29/00 10:12:54 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Advertisement
Well looking at your responce it appears that you didnt finish reading my post. Try reading the whole thing and then respond again.
"there is beer coming from the chimney, code 3, I am proceeding on foot,i repeat bring pretzles."
Here''s the basic ways to use PlaySound:

PlaySound("mywav.wav", NULL, SND_FILENAME);
will play mywav.wav and return when it''s done.

PlaySound("mywav.wav", NULL, SND_FILENAME + SND_ASYNC);
will play mywav.wav and return immediately.

To learn more read the Multimedia Platform SDK description.

You should know that using PlaySound it is not possible to play 2 sounds at the same time...(SUCKS!)

-- There IS something rotten in the state of Denmark --
-------------Ban KalvinB !
I agree with granat
PlaySound is not capable of mixing, therefore it cannot play two sound at the same time.
Actually, using directSound to play wav files is quite simple, and it does have mixing capability.
I suggest use Microsoft''s directSound utility, dsound.h and use HSOUNDOBJ to do this task.

Just refer to the directX SDK.
Advertisement
Um, PlaySound() is capable of mixing. I wrote a proram in VB that played several sounds at the same time. The code in VB looked like this:

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
'' Play Asynchronously
Const SND_ASYNC = &H1

And when you called the function:

sndPlaySound("C:\windows\media\chimes.wav", SND_ASYNC)

So all you have to do is add a little number at the end (0x1).

/. Muzzafarath
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall

This topic is closed to new replies.

Advertisement