BEST way to do sounds

As there is NO sound in openGL I thought I’d ask you lot how you solve this.

I have a simple pong game here and I’d love to embed a bit of sound in it. A simple wav would do to play when the ball hits a wall or something.
I have globally looked into several libraries as openAL and Fmod, but there are quite a few things unclear to about those libraries that aren’t explained in the helps either:
Do I need to supply a DLL for them to work?
I haven’t done anything with sound yet simply because I couldn’t find info on that.

On the other hand, NeHe uses a windows sound call to use sound, but I feel a bit uncertain about that thing too. I don’t want my app to load that file every time an event happens, as that’d slow it down too much.

Anyone any thoughts about this?

There are a few options, depending on what you need, and what platform(s) you target.

The simplest way, on Windows, is PlaySound. For a pong game this should be enough if all you need is a boink when the ball hits a paddle or a wall. For more advanced stuff, there are DirectSound, FMOD , Bass and OpenAL . I believe all but DirectSound can be used under other systems than Windows.

I use FMOD, and I can highly recomend it.

EDIT: Sorry, didn’t read your question completely. You already knew about those I mentioned. Can only speak for FMOD, since that’s what I’m using. FMOD requires a DLL under Windows. But that’s no problem, jusy chip the DLL with your program if you plan to distribute it.

[This message has been edited by Bob (edited 01-12-2003).]

I’m mainly worried about the delay of “PlaySound”… doesn’t it access the HD every time it has to play the sound? If the ball is moving around at incredible rates and it has to play the thing 3 times each second there is bound to be a delay when it accesses the HD.
Do you have experience with this?

You can place the sound as a resource in your program and play it from there. Have no experience with resources in Windows, but I would guess they are stored in memory. I suggest you take one of the APIs I suggested and use that instead. You can do so much more with them, and, at least FMOD, is very simple to use.

You can even use PlaySound() to play sound images directly from RAM. Just use SND_MEMORY as flag in fdwSound.
I’m not sure if the delay is OK when using SND_MEMORY, but I’d give it a shot if you don’t have too many sounds…
Nick

Hi!

Just wanted to mention another option: libMikMod . It’s the most portable sound toolkit you will ever find (>12 platforms supported), and it is very easy to use (not to mention completely free, and it’s also possible to link it statically).

You get 32 channels for sound sample playback and MOD music playback (16 different MOD formats supported) + easy control of things like panning, reverb and interpolation quality.

Thanks,
I shall test the SND_MEMORY tonight, as I don’t have a sound card in this computer (at work, behind a P2 233Mhz )

Marcus, does MikMod use an external file for sound or is it directly embedded in the executable? Heh heh… for me it doesn’t “feel” right having to supply a 3rd party dll… something I still have to get used to…

Originally posted by Structural:
Marcus, does MikMod use an external file for sound or is it directly embedded in the executable? Heh heh… for me it doesn’t “feel” right having to supply a 3rd party dll… something I still have to get used to…

It can do both (that was what I meant with “link statically”). You get the source, so you can build it pretty much the way you like. I think there is a MSVC Makefile in the distro. I had to tweak it a bit to compile with MinGW32 (my preferred compiler), and I did a static library then (static = ends up in the executable file).

I have made a few apps which use no external files at all (I even integrated the music module into the exe using a bin2c program and libMikMod:s custom file I/O facilities to create a “mem loader”).

SMPEG + libvorbis + Timidity + MikMod + Simple DirectMedia Layer == SDL_mixer, guys. Enjoy, this is what you’re looking for :slight_smile:
http://www.libsdl.org/projects/SDL_mixer/
Free software rules. To my knowledge, only license you have to worry about is the LGPL.