News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

sounds

Started by fusspot, August 31, 2007, 02:48:30 PM

Previous topic - Next topic

fusspot

I am programming a game and I want to incorporate sounds to it. How do I do that?

ragdog

hi

what for sound´s mp3,wav ...???


greets
ragdog

fusspot


sonic

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.

u

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)
Please use a smaller graphic in your signature.

pcMike

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