[openal] distance model questions

Victorious dtvictorious at gmail.com
Wed May 27 05:21:46 EDT 2015

I'm trying to understand how gain is calculated under the inverse distance clamped model.
gain = AL_REFERENCE_DISTANCE / (AL_REFERENCE_DISTANCE + (distance – AL_REFERENCE_DISTANCE)) = al_ref_distance/distance;
Let distance = 2 and reference distance = 1, so gain should be 0.5. However, when I checked the actual gain the source was set to, it was 1. It doesn't seem to be decreasing properly. Yet, I can hear the source getting softer. What could be causing this? Its quite puzzling.

-----Original Message-----
From: openal [mailto:openal-bounces at openal.org] On Behalf Of Chris Robinson
Sent: Wednesday, May 27, 2015 9:33 AM
To: openal mailing list
Subject: Re: [openal] distance model questions

On 05/26/2015 11:40 AM, Victorious wrote:
> let actual distance = 5, max distance = 4 and scale = 2. So source
> should be silent at distance of 6. gain = max(1.0 - (5 - 4)*2, 0.0)
> which evaluates to 0.0; the sound is silenced at a distance of 5, not
> 6.

On 05/26/2015 12:35 PM, Victorious wrote:
> Hm, just thought of this: could the following be better?
>
> The inverse rolloff clamped model is used when distance(source,
> listener) <= threshold% of sound's hearing range. Otherwise, a custom
> formula or an alternative distance model is used.

That's basically what my latter suggestion does. It uses inverse
distance up to max_distance, and then becomes linear.

> I plugged some numbers into the linear models, and it looks like gain
> doesn't hit 0 when sound is at max_distance (not sure why I thought
> it did).
> // with a rolloff factor of 1,
> gain = (1 - (distance - referenceDistance) / (maxDistance -
> referenceDistance));
>
> Looks like the only way to have 0 gain is if refDistance = distance
> and/or maxDistance = referenceDistance.

Nope, you're missing the '1 -' part. When distance = maxDistance, you get:

gain = (1 - (distance-refDistance) / (maxDistance-refDistance));
gain = (1 - dist_from_ref / dist_from_ref);
gain = (1 - 1);
gain = 0;
_______________________________________________
openal mailing list
openal at openal.org
http://openal.org/mailman/listinfo/openal