Greetings, I’m currently attending school for game design and the game we’re making is using FMOD (I’m the sound guy) and while I have most of the 2D sounds and everything working fine I’m having a bit of trouble getting them into 3D.

I’ve browsed many of the topics here and thought maybe a few times I found the solution to the problems I was having. One of them included the sounds not being in mono 😳 Heh. However it still does not work for me.

At first the sound would play once, and then once in game it would discontinue to play. What we’re doing is, playing a sound at a “town” in the game and constantly playing it. We’re using Renderware and have reversed the x vectors, since FMOD and Renderware do not use the same coordinate system.

Here’s some of the code I have.

For initialization
[code:2dgi2vlm]if (!FSOUND_Init(44100, 32, FSOUND_INIT_GLOBALFOCUS))
return false;[/code:2dgi2vlm]

Loading in 3D sounds
[code:2dgi2vlm][FSOUND_SAMPLE * CSoundManager::Load3DSound(const char *strPath, bool Loop)
FSOUND_SAMPLE * Temp = FSOUND_Sample_Load(FSOUND_FREE, strPath, FSOUND_HW3D, 0, 0 );
FSOUND_Sample_SetMinMaxDistance(Temp, 4.0f, 10000.0f);
return Temp;

It’s update…
[code:2dgi2vlm] RwFrame * temp = CCameraSystem::GetInstance()->GetCameraFrame();
float CameraPos[3];
CameraPos[0] = temp->modelling.pos.x;
CameraPos[1] = temp->modelling.pos.y;
CameraPos[2] = temp->modelling.pos.z;
FSOUND_3D_Listener_SetAttributes(CameraPos, NULL, -(temp->modelling.at.x), temp->modelling.at.y, temp->modelling.at.z, -(temp->modelling.up.x), temp->modelling.up.y, temp->modelling.up.z);

And here is where I play it…
[code:2dgi2vlm] float Tempf[3];
Tempf[0] = (m_cHarborIterator.Current()->m_pFrame->modelling.pos.x);
Tempf[1] = m_cHarborIterator.Current()->m_pFrame->modelling.pos.y;
Tempf[2] = m_cHarborIterator.Current()->m_pFrame->modelling.pos.z;
if ( !FSOUND_IsPlaying(CSoundManager::CANNON_FIRE_3) )
FSOUND_3D_SetAttributes(CSoundManager::CANNON_FIRE_3, Tempf, NULL);[/code:2dgi2vlm]

I call the Update every frame too. Some time (and code) ago the sound would only play once and that was it. Now what happens, is it seems the sound plays about 10 times at a time, and then plays again 10 times… etc. And never in a “3D fashion”. Heheh.

Also in the last bit of code above, I also tried setting the x position of the HarborIterator to a negative as well, to no avail.

Any help would be greatly appreciated. Sorry if this has been asked in some way or another before, but I failed locating that post. 😉

  • You must to post comments

You’re probably right as I just picked up this a few days ago and I’m still learning it for the most part.

Sorry for the confusion but I have the sounds playing in a different function which is that play function. the CANNON_FIRE_3 is just an enum that I have setup just for simplicity. I gave each sound being loaded in it’s own channel.

[code:aw5gibpl]void CSoundManager::Play(int Sound)
Channels[Sound] = FSOUND_PlaySound(FSOUND_FREE, m_pSounds[Sound]);

Do you just suggest I have one int Channel and everytime I play a sound through it, I return PlaySound’s value to that one channel?

The reason for having the number of channels I do, is to easier check if that particular sound is playing, volume control, etc.

  • You must to post comments

Ok, well speaking of having the handles to use to see if there’s a sound playing. I’m having a problem with my main menu music as well. The problem is, it plays correctly the first time, then when I enter the game it stops as it should. The problem occurs when I re-enter the main menu, it sounds like the song is being played multiple times at once for sort of an echo effect.

Code is as follows. The MP3 is in 2D, and this gets called every frame.

[code:1xwf0e93]if (!FSOUND_IsPlaying(CSoundManager::WINGMAN) && m_nCurrentGameState == States_Main)

else if (FSOUND_IsPlaying(CSoundManager::WINGMAN) && m_nCurrentGameState != States_Main)

Where WINGMAN is just an int (enum) and the Play function is
[code:1xwf0e93]void CSoundManager::Play(int Sound)
Channels[Sound] = FSOUND_PlaySound(FSOUND_FREE, m_pSounds[Sound]);

I figure, since I’m always using the channel I assigned to the sound, the IsPlaying function would check to see if that handle was playing a sound or not etc. I’m a bit oblivious as to why the second time I try to go into the main menu, the sounds become an echo.

  • You must to post comments

Yes thanks, I just realized I was a clown and came here to post it, but you beat me to it. Heheh thanks. I’m still having no luck with the 3D sounds but I’ll post any updates on any progress. Thanks again mang 8)

  • You must to post comments

Are you FullSail? I am. Anyway, here’s a possible solution to your multiple sounds playing at once. It possible its an input problem. If you’re using GetAsyncKeyState() for some temporary input then you’ll end up with the multiple sounds playing at once. You’ll need to buffer that if its the case, or use kbhit() instead for temporary input.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.