I am programming a game and I want to incorporate sounds to it. How do I do that?
hi
what for sound´s mp3,wav ...???
greets
ragdog
bells, buzz etc.
If your files are wav/midi then u can use api's like PlaySound/mci* otherwise u can use a library like fmod or bass for playing most of the formats.
I recommend avoiding midi and MCI in games.
Use PlaySound, but having pre-loaded the .wav files into memory. (use SND_MEMORY and SND_ASYNC)
For simple Beeps you can do an invoke Beep,100,500
passing it tone and duration.
There is an intresting thread on going crazy with Beep here:
http://www.masm32.com/board/index.php?topic=1789.0
For better quality sound, play a Wav file like using "invoke PlayWav, addr logonwav" using this procedure:
PlayWav proc lpfilename
;
; Check if a WAV file exits, and if it does, play it
invoke GetFileAttributes, lpfilename
inc eax ; Check that EAX!=-1
jz NoPlay
Invoke PlaySound, lpfilename, NULL, SND_FILENAME or SND_ASYNC
NoPlay:
ret
PlayWav endp
Regards, Mike