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?
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.
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?
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.