Fix playback volume of mono sounds in the lwjgl3 backend #7365
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Might fix #6784
The position of sound sources was set to (0,0,1) in 3D space, resulting in sounds not playing at full volume. This led to varying levels of audio output volume compared to other backends (stereo sounds weren't affected).
This PR sets the position to (0,0,0). In order to not break panning, I had to change the way how 2D panning works.
If pan is set to 0 (center), sound output shouldn't differ from playing an unpanned sound. This was the case with the original panning calculation and a default source position of (0,0,1).
The new panning calculation is based on this comment by kcat, the author of OpenAL Soft. If you read the comment, you'll notice a mention of a second variant in the last block. I've chosen this method because the sound output closely matches the output prior to this PR.
Visual comparison:
play(volume, pitch, pan)
The red line indicates the maximum level of output.