Attenuation Models #971
Replies: 1 comment 1 reply
-
When I implemented the high level stuff in miniaudio I based a lot of it off the OpenAL feature set (which I'm kind of regretting), and as a result the attenuation models in miniaudio are just what OpenAL uses. To be honest, I just implemented the OpenAL attenuation models and just moved on without putting any more thought into it. It could do with another pass and I'm happy to look at that FMOD stuff. Do you by chance know if FMOD documents the actual formula of their attenuation models? I had a cursory look at the links you mentioned but I couldn't see anything. If I can get those details I can probably plug those in straight away without any problem at all. You're right about the documentation. That also needs another pass. There's quite a few other things as well where I just quickly listed the various options and then just never got around to fleshing out the details. I need to refresh my memory on the attenuation stuff and get that documented. I like those graphs from the FMOD documentation - I might even do my own.
Possibly? I'll need to investigate. Thanks for pointing that out.
Just thought I'd quickly mention, just in case you weren't aware miniaudio is very literal about how it plays sounds. If you tell it to play a sound, it'll do it, even if it's out of audible range. So if you want to skip processing sounds, you'll need to manage it yourself. This is another thing I want to address with the engine API. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In our engine we have support for FMOD, but I've decided to also implement a MiniAudio backend as a free alternative for people to choose. Consequently, although certainly unfair, I'm comparing the functionality that I get out of MiniAudio with what I'm used to from FMOD.
Overall, MiniAudio is really, really good and I'm quite happy with how the integration is coming along. However, I've been playing around with the parameters for the attenuation models and have found them to be hard to use.
Problem 1) is first and foremost about documentation. The attenuation models are barely mentioned and the effect of the parameters (min/max distance, min/max gain, rolloff) isn't explained, at all, as far as I could tell. From searching the discussions here, I was able to figure out a few pieces, but I am missing a clear explanation and exact formulas. This should be a relatively "easy fix".
Problem 2) is, that none of the models seem to be doing what I want.
In games I would argue that 3 things are important: believable results, good performance and control for artists. Note that "physical accuracy" isn't on that list.
I don't know about performance yet. but I'm struggling with the other two points. When I place a sound source, typically I don't have any sound occlusion etc. That's a known limitation, that means we need to work around this. Therefore I want to be able to clearly define up to what distance a sound is audible, at all. This is a key feature. If I can hear a machine humming even at 20 meters through thick walls, that's breaking the illusion. Unfortunately, the standard inverse model doesn't give me any way to configure this clearly.
So I want to be able to configure the "size" of a sound (where it's always equally loud) and where it is definitely inaudible. That only leaves the "linear" attenuation model with min/max distance. However, that doesn't work well either. With a rolloff of 1, the sound gets only slowly quieter by distance, and then changes from pretty-well-audible to inaudible within the last 5% or so. It is very obvious. I understand why that is mathematically/physically the case. I tried different rolloff values, but that only seems to push that very sudden point back and forth, it doesn't stretch the distance over which the sound drops to inaudible. Frankly, I have no idea how rolloff works, so maybe that's the expected behavior.
It gets even worse with a rolloff below 1, because that pushes the inaudible distance outside the max-distance, which means that such a sound stays audible at any distance. Could this be a bug?
Now I'm not an expert in FMOD, but their distance model have worked pretty well for me.
Here are some details from their documentation:
First of all, I'm not sure whether they expose any additional rolloff value, I think it exists in the runtime API, but I haven't seen it in their UI. The only options for artists are the min and max distance values.
Second, they added FMOD_3D_LINEARSQUAREROLLOFF and FMOD_3D_INVERSETAPEREDROLLOFF, which are meant to give you this full control of the max distance, while also giving you a more natural attenuation behavior in between.
As far as I can tell FMOD_3D_LINEARSQUAREROLLOFF is now their default (even though the documentation says otherwise), probably because it makes the most sense for games.
It would be really useful to have such additional models in MiniAudio. I'm also wondering about performance here. In a model that definitely drops to zero after max-distance, it should be much easier to skip processing those sounds.
Beta Was this translation helpful? Give feedback.
All reactions