PlaySound() pauses game problem
I have written my first game using Win32 and C, the old fashioned way. I know, I must be a masochist. Anyway, I want to add a sound effect when a row is completed (can you guess the genre yet?!). So I use PlaySound() to load the .wav from my resources and play it asynchronously. This works, but the first time it is played there is a noticeable pause in the game as the sound is loaded. It pauses for about one second. After that I guess the sound is cached because it plays quickly. Anyway, how can I fix the pause when the sound is loaded? Is there a way to preload sounds at the beginning of the game, without actually playing them?
If I must use DirectX, can I just use the audio part and nothing else?
Don't know exaclty how playsound works, but rather avoid it.
You can use only Dx part responsible for sound/music playback (if you do so, use as old version of dx as possible to avoid possible problems with "you need to install dx9 in order to run this game...")
Another idea is to simply find a simple sound-playback source and use it. Loading Wav's and playing them is pretty straightforward
Ok here's a tutorial with sample code for using both waveout method and dsound to play sound.
Generally Waveout is better for you as you don't need dx for it, but for more advance functions (which you don't seem to need atm) you will want to consider dsound.
Last edited by MirekCz; 09-23-2004 at 12:49 AM.
I'd seriously consider FMOD, BASS or OpenAL to do your sound for you. No headaches, it's all Good Stuff.
I believe there's a cheapass license for shareware devs at $100 isn't there...?
Yes - down the page a bit.
LockResource on the sound will do it
Originally Posted by 20thCenturyBoy