FMOD usage In Game

Started by
1 comment, last by CrystalClear 18 years, 7 months ago
I have a space game 80% coded, I am now unto sound using FMOD\VC++6 I have managed to get an mp3 track playing during my menu and when the user starts the game it continues to play. I have also got a .wav sound playing when the ship fires a shot however when collision occurs between rocket and alien the explosion cuts out the firing sound of the ship, I have tried different channels but no joy maybe there is something I am missing I have posted the procedure and the call itself Thx in advance


*CALL*
Play_Sound(0, ALIEN_EXPLODE, FSOUND_LOOP_OFF,1);

*PROCEDURE*
bool Play_Sound(long Channel, int Sound, int Mode, int Loaded)	// We play a sound
{

	if (Sound==PLAYER_SHOT)
	{
		// Sound to play
		Sound_To_Play_1 = FSOUND_Sample_Load(2,"data/sounds/shot.wav",FSOUND_STEREO, 0);
		// We play the sound
		FSOUND_PlaySound(Channel,Sound_To_Play_1);
	}

	if (Sound==ALIEN_EXPLODE)
	{
		// Sound to play
		Sound_To_Play_2 = FSOUND_Sample_Load(2,"data/sounds/explode.wav",FSOUND_STEREO, 0);
		// We play the sound
		FSOUND_PlaySound(Channel,Sound_To_Play_2);
	}


	return true;

}

Advertisement
Simplest way:

First, only load the samples once and keep a pointer to them (FSOUND_SAMPLE *) as returned by FSOUND_Sample_Load.

In FSOUND_Sample_Load() don't specify the sample pool (the first argument) use FSOUND_FREE instead.

When playing the sound don't specify the channel number use FSOUND_FREE again.

- Matt
thx for the reply ill check this out

I actually realised i was loading everytime but didnt have a clue how to keep it in memory, maybe that should have been my first question

Cheers

This topic is closed to new replies.

Advertisement