Strange issue with custom rolloff callback

(Jonathan Wilson) #1

We are installing a custom rolloff callback with FMOD_System_Set3DRolloffCallback

When we play a sound we call FMOD_System_PlaySound then FMOD_Channel_Set3DAttributes to set the position on the sound followed by FMOD_Channel_Set3DMinMaxDistance to set the rolloff distances.

In our callback we call FMOD_Channel_Get3DMinMaxDistance to retrieve the distances stored earlier before using them (and the current distance passed to the callback) to calculate the volume value we want.

What we are seeing in our debug logs is the call to FMOD_Channel_Set3DMinMaxDistance followed immediately by a call to our callback with a distance of 0. The call to FMOD_Channel_Get3DMinMaxDistance inside that first call is returning the default distances of 1 and 10000 instead of what was supposedly just set by FMOD_Channel_Set3DMinMaxDistance. Then immediately after that we see another call to our callback with a more reasonable looking distance value and correct values being returned from FMOD_Channel_Set3DMinMaxDistance.

Why is this strange bogus call to our callback happening and how can we stop it from happening (or identify it and filter it out without breaking cases where distance is legitimately zero and the guys editing the data have legitimately set min and max distances to 1 and 10000)?

We are using version 1.04.05 of FMOD Studio Programmers API.

(Jonathan Wilson) #2

Turns out the cause of this was because our audio system called FMOD_Channel_SetPaused to start the sound playing before it called FMOD_Channel_Set3DAttributes and FMOD_Channel_Set3DMinMaxDistance. Fixing that made the problem go away.