There are a variety of audio APIs available to a developer. One that I use is called the FMOD Sound System, partially because of its cost (free to develop with, $100 for a hobbyist license for releasing games in a limited fashion), partially because of its ease of use, and partially because of its powerful features. Previously, I would use DirectShow to play music for my applications, but it lacks features I would very much like to use, and I’ve found FMOD to be a good replacement.

For example – to set up FMOD for audio playback, you would call:

FMOD::System* gpFMOD = NULL;

// Set up for 100 voice channels
gpFMOD->init(100, FMOD_INIT_NORMAL, 0);

To shut it down, you would call:


And to properly update callbacks, each frame you should call:


Each of these steps is fairly simple, and they provide options such as configuring for 5.1 surround sound, hardware/software voice channels, and so on.

To actually play a sound, all you have to do is:

FMOD::Sound* mpSound;
FMOD::Channel* mpChannel;
if (true == bStreaming)
    gpFMOD->createStream((char*)p_wcFilename, FMOD_SOFTWARE | FMOD_UNICODE, 0, &mpSound);
    gpFMOD->createSound((char*)p_wcFilename, FMOD_UNICODE, 0, &mpSound);

if (true == bLooping)

// Play the sound immediately, and get the
// sound's channel so we can modify
// volume/pitch/pause later
gpFMOD->playSound(FMOD_CHANNEL_FREE, mpSound, false, &mpChannel);

And that’s it – very easy to use.

Notice that I’m loading my sounds from Unicode filenames. In my code, I nearly always use Unicode for display strings and filename access, for ease of localization. Internal strings are represented as single-byte character arrays, or even just CRC32 hash values of the string if possible, since that lets me do integer compares on the hashed value, rather than time-consuming string comparisons.

Through FMOD’s Channel interface, you can pan sounds, set them in 3D space, adjust volume, frequency (playback rate), and so on. You can also add a callback for sound completion, which is very useful for switching music tracks in game.

Using FMOD, it should be very simple to create a simple sound/music system for a game, or to build up a more powerful game audio engine for your code to use.