[openal] distance model questions
Chris Robinson
chris.kcat at gmail.com
Tue May 12 05:56:28 EDT 2015
On 05/12/2015 02:02 AM, Victorious wrote:
> What does ref stand for, the y-coordinate in RHS system of the
> listener?
'ref' is the source's reference distance (1 by default, so that means it
would be +1 or -1 on the listener's local Y axis, which is the
orientation's 'up' vector). Basically:
// If the sound source is above the listener's head
polar_pos = listener.up*ref_distance + listener.pos;
// else
polar_pos = listener.up*-ref_distance + listener.pos;
> How does lerping the source with (0, ref, 0) or (0, -ref,
> 0) help?
Lerping it with the above calculated polar position helps prevent the
sound from panning so strongly when it's near the listener. The closer
it is to the listener, the less the source's real position influences
the position the source is set to, thus the less it pans around. So if
the source was 0.5 units away at a +45 degree angle, rather than a 70%
pan it would roughly be a 47% pan.
> Also, why is this lerp done when distance(listener, source)
> is < REFERENCE_DISTANCE, and what is the lerp rate that I should use?
You can use any value for the radius you want, although
REFERENCE_DISTANCE is a sane implicit value (since that's also where the
sound will stop getting louder as it gets closer, by default). The lerp
is just a linear interpolation, so when the source is >=radius units
away the source position is used unmodified, and when it's 0 units away
the source position is completely overwritten, and when it's at half the
radius it's a 50% mix of the source's position with the polar position, etc.
> For the conflict, could you just use a different value for the enum?
That would break compatibility, and require a different extension. But
having multiple "active" extensions for the same behavior isn't that
nice either.
What I may end up doing is deprecating AL_SOFT_buffer_sub_data (and
AL_SOFT_buffer_samples, since that borrows the former's enums), and
replace it with a different extension that doesn't use the offending
enum value. A configuration option could be made available for apps that
rely on the buffer_sub_data or buffer_samples, re-exposing those
extensions and disabling AL_EXT_SOURCE_RADIUS support when set.
More information about the openal
mailing list