Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing ability to set rolloff factor in OpenAL #7532

Open
Ellpeck opened this issue Jul 14, 2021 · 2 comments
Open

Missing ability to set rolloff factor in OpenAL #7532

Ellpeck opened this issue Jul 14, 2021 · 2 comments

Comments

@Ellpeck
Copy link

Ellpeck commented Jul 14, 2021

MonoGame's SoundEffect class provides the DistanceScale value that claims to "get or set the scale of distance calculations", and that "higher values reduce the rate of falloff between the sound and listener." However, in the OpenAL implementation, it actually sets the reference distance property to this value. According to the OpenAL documentation, the reference distance is "the distance under which the volume for the source would normally drop by half (before being influenced by rolloff factor or AL_MAX_DISTANCE)."

It seems that a more fitting OpenAL property to use for DistanceScale would be the AL_ROLLOFF_FACTOR, which is used in calculations as a sort of distance scale property:

The AL_INVERSE_DISTANCE_CLAMPED model works according to the following
formula:

distance = min(distance,AL_MAX_DISTANCE);
gain = AL_REFERENCE_DISTANCE / (AL_REFERENCE_DISTANCE +
 AL_ROLLOFF_FACTOR *
 (distance – AL_REFERENCE_DISTANCE)); 

Since OpenAL's reference distance has a different effect from the rolloff factor, and the latter cannot be changed in the current implementation, it doesn't seem like there is currently a way to change OpenAL's actual distance scale.

What version of MonoGame does the bug occur on:

  • MonoGame 3.8

What operating system are you using:

  • Windows

What MonoGame platform are you using:

  • DesktopGL
@mrhelmut
Copy link
Contributor

I've been looking into the OpenAL code lately, and there are definitely some caveats in regard to Apply3D() and ApplyFilters(). I'm expecting to look into improving the accuracy toward WindowsDX/XNA soon.

@mrhelmut
Copy link
Contributor

OpenAL definitely is a dead-end when it comes to match the effect behaviors of WindowsDX/XNA. The best route of action is to replace OpenAL with a library which would allows that. As far as I've looked into that, FAudio seems to be the only candidate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants