Advertisement

PlaySound and sndPlaySound

Started by July 24, 2000 05:58 PM
1 comment, last by t2sherm 24 years, 5 months ago
I am having trouble playing a sound in my game, i have 2 sounds in my resource file, but only 1 will play in my game. After reading about it in the help, i noticed that it says PlaySound can play files from a resource, which is what i want, but i am using sndPlaySound, and it works for one of them, and it shouldn''t be should it? Anyway here is my resource file HIT WAV MOVEABLE PURE "Hit.wav" POPWAVE WAV MOVEABLE PURE "Pop.wav" In the game i use this and it works: sndPlaySound( "HIT", SND_ASYNC); but if i try this sndPlaySound( "POPWAVE", SND_ASYNC); it doesn''t work. I am probably just going to use directsound becuase even on the one that works, it really slows down everything and it sounds like crap, but I figured I should at least get it to work this way before trying to do something more complicated. Both of the wav files show up in the resource editor, and if i change the name of them in, i get an error when i try to compile, and also if i open the exe as a resource after i build it, both are in there, so i don''t know why they aren''t playing. Any ideas? t2sherm ô¿ô
t2sherm ô¿ô
I''d have to see more of the source than that to fix your sndPlaySound problem, but realistically, sndPlaySound only exists for backwards compatability. You really, really should be using PlaySound, or use DSound.

Have you tried playing just the "pop" sound? Realize that when you do a SND_ASYNC, if two sounds play semi-simultaneously you will only really hear one. SND_SYNC will allow you to hear both by waiting until the first is finished to play the second.

If you''re planning to only ever hear one sound at a given time, then PlaySound is sufficient. Otherwise, you need to use DSound. DSound really isn''t that bad, and WGPFD and TOTWGPG both have really good information about using it, though please ignore Andre''s hardcoding of the WAVEFORMATEX information, he loaded the correct WAVEFORMATEX in the mmio functions so use it... not sure why he did the hardcode.
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Advertisement
The sound works when I play it in windows. I did change to the PlaySound, it didn''t change anything, so I put the sounds in the directory with the exe, and instead of loading them as a resource, just loaded them as a file, and now that works. I still don''t kow why the other way didn''t work. When i tried to play the popwave sound, i got the windows default sound. Anyway even with the PlaySound, it sounds AWFUL when there are a lot of things being drawn on the screen, especailly if the sound is like a second or more, so it looks like I will have to use DSound. I have been reading about it on the net, and I have the TOTWGPG book, and I have been looking at that, and trying to figure it out, so hopefully I will be able to and hopefully it is WAY faster than the PlaySound, becuase otherwise I''m in trouble.

Thanks for your help

t2sherm ô¿ô
t2sherm ô¿ô

This topic is closed to new replies.

Advertisement