# Total noise heard by AudioListener

Hi all,

Is it possible to ask the AudioListener how much it’s currently “hearing”? Like for example if it was in a scene with:

A stereo audio source, volume 0.5
A mono audio source, volume 3.0

Then the total noise would be 0.5 + (3.0 - sound lose due to rolloff).

In the even that there isn’t a way to access such a variable, I guess I’ll have to calculate it myself. In that case, is anyone able to tell me what equation the RolloffFactor uses to calculate the decrease in sound over distance?

Thanks in advance,
Mark

Unity uses OpenAL for audio. If you get the OpenAL reference manual here and read about the alDistanceModel() function, it explains the various functions it uses to calculate rolloff.

Unfortunately, I don’t know which distance model it uses, so you’ll have to figure that out for yourself.

An old forum post suggests that Unity uses a linear falloff. Even if that is the case, I’m afraid I’m still throughly confused.

gain = (1 – AL_ROLLOFF_FACTOR * (distance –
AL_REFERENCE_DISTANCE) /
(AL_MAX_DISTANCE – AL_REFERENCE_DISTANCE))

AL_ROLLOFF_FACTOR and distance are clear, but I can’t figure out how I should calculate the variables (or rather, work out which values Unity uses) AL_MAX_DISTANCE and AL_REFERENCE_DISTANE. Am I being stupid somewhere, or do I need to just try plugging in values until I get something that resembles Unity’s system?

I’m assuming that VolumeAtSource*gain = VolumeAtListener?

Thanks,
Mark

I can’t see anything relating to reference distance in the GUI, although you might want to take note of the max and min volume properties of AudioSource - presumably these are used with the AL_LINEAR_DISTANCE_CLAMPED model. I imagine the reference distance is just a constant value that you’ll have to guess. Unless someone from UT can tell you exactly what they’ve done (or you’re happy with the idea of disassembling Unity to find out!), you’ll have to experiment to see what happens.

Seems reasonable.