I am trying to write a logrithmic attenuation algorithm for Javasound, since it doesn't have one built into it by default like OpenAL does.
My understanding of how attenuation works in the real world, is that waves attenuate according to the inverse of the distance squared:
intensity = initialIntensity / (1 + distance * distance);
So with sound waves, volume should be:
volume = initialVolume / (1 + distance * distance);
And then adding in a rollOff factor:
volume = initialVolume / (1 + rollOff * distance * distance);
Now here is were I am stumped. From what I understand, the "logrithmic" part of a logrithmic attinuation algorithm is there to compensate for the fact that the "loudness" of a sound detected by the human ear is not a linear function of that sound's decible value. I've been searching the internet, but I can't figure out exactly what I need to add to my formula for it to match what OpenAL does.
I thought I would post this here in case anyone happens to know anything about this topic. If not, I will just use the formula as is. Only drawback is my algorithm doesn't match the OpenAL algorithm, so you'd have to use different rolloff factors depending on whether you were in OpenAL or Javasound mode, and the attinuation effect would not be the same for both libraries (which may complicate things for the user).
Other solution would be to not use the built-in OpenAL logrithmic attenuation model, and use my algorithm for both Javasound and OpenAL. This would reduce the realism achieved with OpenAL, but it would ensure that both libraries have the same behavior.