0
0

Hi, im currently studying at a game course and we are using FMOD for our end of course project. everything works fine except for moving samples (i.e. having an engine sound on a vehicle and letting it stay with the vehicle ). i currently do this by setting the 3d attributes for the channel the sample is playing on without pausing the track first ( if i did it still wont move but give a horrible crackling sound ) and setting the sample’s position and velocity to that of the vehicle. Can anyone help me??

  • You must to post comments
0
0

ive now tried starting it paused, set the attributes, unpause. but the sound still seems to be at a fixed position. i know that the position is not the problem as it is pulled straight from the vehicles matrix and i can drive it around. the listener is working fine. any idea why the sounds position is not being updated?

  • You must to post comments
0
0

oh, i had also forgotten to mention, im am using this on a win32 platform with renderware. programming in c++/c ( i have written a c++ wrapper around my needed functions )

  • You must to post comments
0
0

but i am. the the vehicle class we have an update function, which is where i am setting the new position. i have checked this and it is calling the set 3d attributes function but does not seem to be setting the new position. in the update for the vehicle i call

[code:2acu50xr]
CAudioSystem::GetInstance()->Set3DAttributes( m_RPMSound, m_vPosition, m_vLinearVelocity );
[/code:2acu50xr]

where this funtion is:

[code:2acu50xr]
void CAudioSystem::Set3DAttributes( SFMODSound p_Sound, Vec3 p_vPos, Vec3 p_vVelocity ) {
FSOUND_SAMPLE *pSample;
pSample = FSOUND_GetCurrentSample( p_Sound.m_iChannel );

if( pSample == p_Sound.m_pSample ) {

    float pos[3] = { p_vPos.x, p_vPos.y, p_vPos.z };
    float vel[3] = { p_vVelocity.x, p_vVelocity.y, p_vVelocity.z };

    assert( FSOUND_3D_SetAttributes( p_Sound.m_iChannel, pos, vel ) );
}

}
[/code:2acu50xr]
the SFMODSound is just a struct that holds the sample and channel

am i doing something wrong here

p.s

thanks in advance for the help

  • You must to post comments
0
0

it works in the 3d sample, thats why it’s so confusing for me on why it doesn’t want to work in our game. as for your question on whay i assign a channel to a sample is for that fact, in our game there will be many of the same sounds, but want to keep track of the channel for each instance of a sample. for example, we have 16 vehicles, as say the are all the same type, so they all use the same sound file. to create an engine sound i have an idle sound and a rpm sound which i pitch-shift using the Set Frequency function. so everytime i want a new sound i load it in.

[quote:1volmrsn]
I dont suppose i have to ask if you have FSOUND_HW3D and that you are calling FSOUND_Update.
[/quote:1volmrsn]

yes i am using FSOUND_HW3D and am calling FSOUND_Update every frame.

[quote:1volmrsn]
Anyway, just try modifying fmod’s 3d example, you will find it works, and you will probably find your problem.
[/quote:1volmrsn]

yes it does, but the only answer why it works that i can come up with is that i am using a global variable in the 3d sample, but in our game i convert it in a functions local variable, so it would loose scope outside the function. may this be causing my problem??

  • You must to post comments
0
0

right, heres an update. i’ve replaced the 3d sample with my own C++ wrapper and it works fine, but one thing i noticed was that there was a 50ms sleep time. is this needed?? and is all i need to check is being called set 3d attributes, listener update, then fsound update?? (in this order?)

  • You must to post comments
0
0

found the problem, someone had changed our timer in the game so update was not actually being called. fixed now. thanks for all your help brett, you truly are a god.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.