PlaySound()

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Do you have the data preloaded into memory and processed into whatever the sound instance is for this library? For irrKlang which I use, I load the data into memory in the resource cache, than process it into an irrKlang sound source.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • I didn't realize there was a play sound even in Winmm, but I don't think it can really offer you as much flexibility as a dedicated sound library like DirectSound or irrKlang.

      You can load wav files manually, and I believe that there is even a function for doing so in GCC4, as I believe that DirectSound has to have a custom format (correct me if I'm wrong).

      FMOD and irrKlang are both free for hobbie projects and both are great to work with, they will handle the processing of your sound data for you, and give you a nice interface to use.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • RE: PlaySound()

      Originally posted by kaykry
      Does anyone else use PlaySound() for playing a .WAV sound effect in your game? Do you notice that it lags the first time it tries to play it?

      Nope, no one uses PlaySound(). ;) In generally, you avoid everything from the Windows multimedia API. DirectSound talks directly to the hardware through the driver while the functions like PlaySound() go through another layer. The lag is probably because it's loading the file. I wouldn't be surprised if it did it synchronously.


      It's pretty noticeable and annoying. I guess that I should be using DirectSound for sound effects too but PlaySound() was so easy and convenient.

      Yes, you should.


      What format is recommended for sound effects that are very common (sword attack, shoot arrow, etc)?

      It would be ideal if I didn't have to manually copy the data into a buffer like when loading OGG files.

      I recommend OGG. MP3 is proprietary and too expensive to license while WAV is uncompressed and way too big. For small sound effects, WAV might be okay for such a small game. In generally, I tend to use OGG for everything.


      Is it worth linking to this library, Winmm.lib, and adding the WAV file as a resource? Is there a simple way to load a .WAV file into memory and play it using DirectSound?

      If I were you, I'd probably leave it alone for this project and work with DirectSound or something next project. You could also use fmod or irrKlang as mholley suggests, though I tend to steer clear of licensed products for my side projects. Again, with only a week or so left, I'd let it go for this project.


      You can load wav files manually, and I believe that there is even a function for doing so in GCC4, as I believe that DirectSound has to have a custom format (correct me if I'm wrong).

      It's own format? You mean like the sound equivalent of DDS? I honestly don't know. I think it just uses the raw sound data and passes it down to the sound driver to translate, but that's just a guess. As far as I know, it doesn't have a native compressed format akin to the Direct Draw Surface that can be used for Direct3D textures.

      -Rez