[openal] Extending max source gain
chris.kcat at gmail.com
Tue Aug 9 19:33:04 EDT 2016
I've had a few requests for this now, and have always been a bit stumped
by the design decision. Currently, according to the spec, the source's
AL_GAIN property can be set to anything >= 0, including 2, 4, etc.
However, sources also have the AL_MAX_GAIN property which clamps the
source's gain, but can only be set up to 1, meaning a source's gain will
always be clamped to 1 even though an app can set it to something greater.
Another thing is that the spec says (section 4.1, under AL_GAIN):
"the implementation is free to clamp the total gain (effective gain
per-source multiplied by the listener gain) to one to prevent overflow."
This further makes me wonder why AL_MAX_GAIN is limited to 1, since
implementations are allowed to implicitly clamp the total as needed anyway.
Currently, it is possible to work around this limitation by increasing
the listener's AL_GAIN above 1. Since the listener gain is applied after
clamping, a source's effective gain can be made greater than 1 if the
implementation doesn't implicitly clamp the total (and if it does, it's
still as loud as it can be). This workaround is pretty hacky, though.
I'd like to propose the following. Allow AL_MAX_GAIN (and AL_MIN_GAIN,
since it's a companion property) to be set to values greater than 1.
Since the implementation can clamp the total anyway, why not FLT_MAX?
Further, it may be useful to have a query (retrieved via alGetFloat and
friends) to specify the total maximum gain a source may be clamped to by
the implementation, rather than leaving it as a hidden detail. That way,
an app can know what limits there are for the combined gains, such that
increasing it beyond said limit won't make it any louder.
More information about the openal