[openal] distance model questions

Victorious dtvictorious at gmail.com
Sun May 24 14:05:52 EDT 2015

Would doing this achieve the same thing as the easier lerping i.e prevent the sound from panning too rapidly?

-----Original Message-----
From: openal [mailto:openal-bounces at openal.org] On Behalf Of Chris Robinson
Sent: Sunday, May 24, 2015 10:01 PM
To: openal mailing list
Subject: Re: [openal] distance model questions

On 05/24/2015 06:06 AM, Victorious wrote:
> I have a river on the left edge of a 10x10 grid. What I want to have
> is a single sound source for the river that plays towards the left
> when you're near the left edge (i.e a line segment of 10 units)

In that case, you can simply place the source at the closest point on 
the line to the listener. The easiest way to handle a sound that covers 
a convex area is to do a point-to-line (or plane or volume) test to find 
the closest point in the source area to the listener, and set the set 
the source position to that point.

For axis-aligned areas, you should be able to merely take the listener 
position and clamp the individual X, Y, and Z values to the source's 
world extents. i.e.

sourceX = clamp(listenerX, x - x_range, x + x_range);
sourceY = clamp(listenerY, y - y_range, y + y_range);
sourceZ = clamp(listenerZ, z - z_range, z + z_range);

where x, y, z is the center location of the sound, x_range, y_range, 
z_range is the radius for each axis (which must be >= 0), and sourceX, 
sourceY, sourceZ is the resulting position to set on the source.
openal mailing list
openal at openal.org

More information about the openal mailing list