[openal] distance model questions
Chris Robinson
chris.kcat at gmail.com
Tue May 26 21:33:03 EDT 2015
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.
Right, that should be / instead of *. My bad.
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;
More information about the openal
mailing list