Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Positional sound: Limit volume when closer than 1 node
Change OpenAL distance model from AL_INVERSE_DISTANCE to AL_INVERSE_DISTANCE_CLAMPED to avoid excessive volume when very close to the sound location, for example MTG doors, and MTG fire sounds which are combined at an average position and often located in air nodes. Because AL_REFERENCE_DISTANCE has been reduced to 1 node (the distance under which gain is clamped), multiply volume by the same factor to keep sound gains the same as before, since the gain is calculated as: gain = (AL_REFERENCE_DISTANCE / distance)
- Loading branch information
a455297
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the gain be calculated following way because it's a 3d wave?
gain = AL_REFERENCE_DISTANCE * AL_REFERENCE_DISTANCE / (distance * distance)
a455297
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like openal gets the positions and calculated the distance itself
a455297
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Page 87 here https://www.openal.org/documentation/OpenAL_Programmers_Guide.pdf
There is an AL_EXPONENT_DISTANCE_CLAMPED distance model that could do inverse-square.
a455297
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Human volume perception is not linear (therefore the dB unit), the exponent distance model with rollback factor 2 may work better but it doesn't matter as long as media (e.g. walls and water) have no effect on the sound in minetest.