News
Tetris 3D
Lemmings Doom
Conrad Dangerous
Programming Guides






Game Progamming guides tutorials help opengl fmod directsound directmusic
These guides and tutorials are to help people with game programming code such as OpenGL, FMod, Directsound. I'll use code snippets from the Conrad Dangerous programming.

Using FMod To Play Mod or Midi Music in Visual C++:

Includes

Firstly we include "fmodvc.lib" for Visual C++:
#pragma comment(lib, "fmodvc.lib")

And the "fmod.h" header file:
#include "fmod.h"

Initialisation

To initialise FMod we need to tell it the frequency and channels and any flags:
FSOUND_Init(44100, 32, 0));
So the first paramater is the output frequency in hertz, the second is the channels, and the third is for FMod flags.

Load Music

First we set up an FMUSIC_MODULE variable for our first music file:
FMUSIC_MODULE *Song_1 = NULL;

Now we load the music file "song1.mod" into our variable:
Song_1 = FMUSIC_LoadSong("song1.mod");

Play Music

We can set the volume that we want our song to play at with the following line:
FMUSIC_SetMasterVolume(Song_1, 200);
The second parameter gives the volume with 0 being minimum and 256 the maximum.

To start our song playing we use:
FMUSIC_PlaySong(Song_1);

The following will stop the music playing:
FMUSIC_StopAllSongs();

Close Down

When you are finished with the song you should use the following line to free the memory for the song:
FMUSIC_FreeSong(mod);

And the following line to shut down FMod:
FSOUND_Close();