The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: fusspot on August 31, 2007, 02:48:30 PM

Title: sounds
Post by: fusspot on August 31, 2007, 02:48:30 PM
I am programming a game and I want to incorporate sounds to it. How do I do that?
Title: Re: sounds
Post by: ragdog on August 31, 2007, 03:23:22 PM
hi

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


greets
ragdog
Title: Re: sounds
Post by: fusspot on September 01, 2007, 04:54:01 AM
bells, buzz etc.
Title: Re: sounds
Post by: sonic on September 01, 2007, 06:24:30 PM
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.
Title: Re: sounds
Post by: u on September 02, 2007, 09:54:30 PM
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)
Title: Re: sounds
Post by: pcMike on September 03, 2007, 07:18:11 AM
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