AudioSource, sound emit radius

Is there a way to calculate the radius in wich a sound is emitted. (from the emitter too the point you can nolonger here the sound)

the rolloff factor is undocumentated (or there is no info) and i need to draw a sphere to show the radius of the sound (handy for tweaking 3d sounds)

greetz,

Zero

That’s not how sound works. I was having a chat with my girlfriend, about some audio stuff I’m adding to the wiki, and she seemed to be under the impression that sound worked that way, too. It’s possible that this is something that is handled in code by unity, such as “if the volume isn’t over one bit, then don’t play it”, but you ought to be programatically disabling stuff that is far enough away for that. But as for it going away completely, that’s not something that happens.

wat you just said… doesn’t make any sense
sound always has an “emit” radius, thats how irrKlang works. And if i remember correctly that uses the same OpenAL that unity does…

and that still doesn’t give me any anwsers about the rolloff factor

Not quite sure what you are saying here… but the docs say:

So there is a radius where the sound drops off. but the docs don’t have the actual formula that is used.

Then Physics makes no sense. :stuck_out_tongue:

What I am saying is that sound never just dies at some radius. It gets asymptotically quieter over distance.

No, there isn’t a radius. Don’t know how you came to that conclusion. The formula is

volume = 1.0 / (1.0 + rolloff * (distance – 1.0))

http://forum.unity3d.com/viewtopic.php?t=19455&postdays=0&postorder=asc&start=15

The manual is actually quite wrong, for several properties of Audio Sources. Coincidentally, I am documenting that right now, and I will have a list on the wiki soon.

If you have an “emit radius” in irrKlang, then irrKlang does not work like Unity (even if they may both be using OpenAL). And in that case, irrKlang also doesn’t work like reality.

Actually, Jessy already explained quite well - but the same from a slightly different angle: Using a sphere that determines where the sound “stops” to be audible is actually quite misleading because if the implementation does its job well, there is no audible “now it’s off”. Instead, the sound becomes less and less audible - which is exactly how it happens in the physical world (in the end, whether you still hear a sound or not depends on how well your ears work :wink: ).

Using a sphere to represent fall-off seems to me like an attempt to make this more intuitive; but personally I just find it misleading.

well i call it an emit radius
but its more of an max an min distance where you can hear the sound
max distance being the distance where the volume will be 0 and min distance the distance the player must be to start hearing the sound.

the sphere is just to make a rought estimation to when the player will stop hearing the sound because the volume is low.

after lots of disscussion :stuck_out_tongue: we made this on the irc

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {
	public float targetvolume = 1.0f;
	
	void OnDrawGizmos () {
		if(targetvolume > 0  audio.rolloffFactor > 0) {
			float rad = ((( 1.0f / targetvolume) - 1.0f) / audio.rolloffFactor);
			Gizmos.DrawSphere (transform.position, rad);
		}
	}
}

works very nice, and its exactly what i needed

Maybe we have a different definition of what a radius is. To me that describes a radius around a sound emitter at which a sound can be heard at a certain volume. That’s all I was saying; not that sound just cuts out at a certain point.

I think Zero just wanted to know that formula so he can create a visual utility to accurately setup audio within his scene.