0
0

I’m doing a LAN game in which I would like to be able to have 3D sounds.
The goal is to have an opponent be able to fire their weapon from across the level and it be slightly audible, but get louder as you move towards your opponent.
The way I have it set up after reading the manual and forums is on the client side I am passing into my playsound function the position of the player who fired their weapon.

this is the function

bool CFMODWrapper::PlaySound(int nID, FMOD_MODE mode, D3DXVECTOR3 *pos)
{
// Error check and make sure the system has been initialized
if (!m_dsObject) return false;

//  Make sure ID is valid.
if (nID < 0 || nID >= (signed)FMODSoundList.size())   return false;

m_FMresult = m_FMsystem->playSound(FMOD_CHANNEL_FREE, FMODSoundList[nID].sound, false, &m_pChannel[nID]);

if (pos)
{
    FMOD_VECTOR vPos;

    vPos.x = pos->x;
    vPos.y = pos->y;
    vPos.z = pos->z;

    m_FMresult = FMODSoundList[nID].sound->set3DMinMaxDistance(0.0f, 10000.0f);
    m_FMresult = m_pChannel[nID]->set3DAttributes(&vPos, NULL);
}

return true;

}

when I call createsound, I use the following params: FMOD_3D | FMOD_LOOP_OFF | FMOD_HARDWARE | FMOD_3D_LINEARROLLOFF

at the bottom of my init FMOD function I set num3Dlisteners to 1

during my game update, after I adjust sound volume, I call set3DListenerAttributes(0, &pos, NULL, &fwd, &up)
filling out the position, forward, and up vectors based on the current client
then I call update()

Maybe I am not understanding how this should work, but I am getting poor results. Sometimes the sound effect will pan and sometimes it changes volume, but it does not work properly. Any help would be greatly appreciated.

Thanks,
Jon

  • You must to post comments
0
0

First thing i would do is start the sound paused, you’re going to get a pop noise every time you play if you set the 3d attributes AFTER you play it.

  • You must to post comments
0
0

Quick thought off the top of my head: are you using +X = right, +Y = up, +Z = forwards? (see FMOD help file, under "Tutorials > 3D sound > Orientation and left-handed vs right-handed coordinate systems")

  • You must to post comments
0
0

So I have made the change to make the sound start paused and then unpause it after I set the 3D attributes and I also have made the change to init using a right handed system which my game is using. I have also changed the create sound settings to use software and 3D head relative, but I am still not getting results. When I have another client connect to me, all their sound effects sound like they are right on top of me no matter how far or close I am and panning does not seem to be working either.

  • You must to post comments
0
0

I don’t think it needs to be 3D HR, just 3D. Also, are you updating the listener position? What kind of values are you setting for the position/listerner, are they in the same coordinates, we have to convert from cm to m, as we do everything in meters for audio (for example)?

  • You must to post comments
0
0

And you are calling System::update in your update? Sorry for stating the obvious but 3d sound problems have been that a few times on here.

  • You must to post comments
0
0

Yes I am calling update after I set my 3D listener attributes. I have currently stripped out everything accept sound and movement from my game. The environment that I’m moving on is restricted to -220,220 on the X and -175,175 on the Z. I am wondering what values I should set for set3DSettings and also where should I call that function? I set the 3DSettings in Init and I set the min max distance (0.1f, 10000.0f) right after I load the sound. I have a sound playing constantly at 0,0,0 and no matter where I move the player the sound does not attenuate. I can get it to pan sometimes, but it doesn’t seem right in any case.

  • You must to post comments
0
0

I think you need to go back to a test-bed. Look at the basic /examples/3d code, and /examples/geometry, it works as it should.

There’s got to be something -really- simple you’ve got wrong here, like not checking error codes, speaker setup in windows is wrong, you’ve called some other function that is affecting the sound (like set3DPanLevel or something) or you called setMode somewhere and are unwittingly turning off the 3d flag by not including it again when you call it.

  • You must to post comments
0
0

I got it to work somehow, I think it had something to do with setting lots of flags on creation of the sounds. So now I’m only calling FMOD_3D | FMOD_SOFTWARE and it works. My only problem now is that using software seems to cause tearing and popping in my sounds. When I use hardware it sounds better but then I don’t get good results from the 3D sounds. Can you think of anything that I might be doing wrong for that? Thanks for all the help.

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.