Game Development Community

Audio Falloffs

by Tim Heldna · in Torque Game Engine · 09/14/2006 (10:16 am) · 6 replies

Hi,

Going for a long shot here, just throwing it out there.

Question: Does anyone here have a fix for audio falloffs?

Details: Audio falloffs are not precise. They are being culled incorrectly. This results in a very poor and unsmooth falloff.

Thanks.

- Tim.

#1
09/14/2006 (3:28 pm)
Hi Tim

What do you mean not precise and is it an emitter or any other ?
The ref distans can be a pain to understand.
Its like how strong the actual source is and the reference amount, depending on this and the maxdistans you get the falloff .
And with the dB curve involved you can get different results with different sounds.
It works for me .
But maybe you have a special case :)
#2
09/15/2006 (1:25 am)
Hi Billy, specifically I am referring to audio emitters.

I assure you the falloff does not function correctly. The sound is not fading out to mute the way that it should be, this is a known problem in the engine. Falloffs do not fade precisely. It is not user error. Please understand that while they work to an extent, they are not behaving as they should.

i5.photobucket.com/albums/y189/fjs/falloff.jpg
referenceDistance = 100
maxDistance = 1000

The red line is the usual Inverse Distance (used in DS and OpenAL), the black line is the sound falloff when the MuteAtMaxDistance flag is enabled.
#3
09/15/2006 (8:53 am)
Marcelo (his last name escapes me atm) rewrote some of that code for the new openAL implementation. Should give you some ideas for modifications.
#4
09/15/2006 (3:15 pm)
Ok Tim
Give this a try i dont know if it solves your problem.
In Audio.cc in approximate3DVolume at the end
change this
return 1.0 - (distance - desc->mReferenceDistance) / (desc->mMaxDistance - desc->mReferenceDistance);
to
{
F32 vol = (desc->mMaxDistance - distance) / (desc->mMaxDistance - desc->mReferenceDistance);
return vol;
}

This is what i have for the moment in my audio.cc and it works for me.
If you want the the gain to uncull lower then 0.1 you must change it at the top of audio.cc.
#5
09/17/2006 (5:19 pm)
@Tim i have also a change with the AL_INVERSE_DISTANCE_CLAMPED Model

with these changes in approximate3DVolume
if(distance >= desc->mMaxDistance)
      return(0.f);
else if(distance < desc->mReferenceDistance)
      return 1.0f;
   else
{
 F32 gain; 
//AL_INVERSE_DISTANCE_CLAMPED Model  
distance = getMax(distance,desc->mReferenceDistance);
distance = getMin(distance,desc->mMaxDistance);
gain  = desc->mReferenceDistance /(desc->mReferenceDistance + 1 *(distance -desc>mReferenceDistance));
return gain;
}

And in alxUpdateScores
else if(dist > min)
{
             dist = getMax(dist,min);
             dist = getMin(dist,max);
             mScore[i] *= min /(min + 1 *(dist - min));
}
Test them out and see what you get.
1 is the so called AL_ROLLOFF_FACTOR i havent put that in yet.
#6
09/17/2006 (9:31 pm)
Thank you Billy. I will let you know how it pans out.