diff options
author | Chris Robinson <[email protected]> | 2009-11-23 16:25:37 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-11-23 16:25:37 -0800 |
commit | c7c2f9385f7bfde9962eb7743770679cca07181e (patch) | |
tree | 0c308c6c703dc2e8fe30a4a1c0409653fc280015 /Alc | |
parent | d1f3dbb9a15146d3ee11983ef8c8748530b3185a (diff) |
Base air absorption on the distance attenuation
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -628,20 +628,20 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext, ALsource *ALSource, } // Distance-based air absorption - if(ALSource->AirAbsorptionFactor > 0.0f && ALSource->DistanceModel != AL_NONE) + if(ALSource->AirAbsorptionFactor > 0.0f) { - ALfloat dist = Distance-MinDist; + ALfloat amount = AIRABSORBGAINDBHF * ALSource->AirAbsorptionFactor * + MetersPerUnit; ALfloat absorb; - if(dist < 0.0f) dist = 0.0f; - // Absorption calculation is done in dB - absorb = (ALSource->AirAbsorptionFactor*AIRABSORBGAINDBHF) * - (dist*MetersPerUnit); - // Convert dB to linear gain before applying - absorb = pow(10.0, absorb/20.0); - DryGainHF *= absorb; - for(i = 0;i < MAX_SENDS;i++) - WetGainHF[i] *= absorb; + // Convert a -6dB rolloff into a -0.05dB rolloff + absorb = pow(10.0f, log10(flAttenuation) * amount / -6.0f); + if(absorb < 1.0f) + { + DryGainHF *= absorb; + for(i = 0;i < MAX_SENDS;i++) + WetGainHF[i] *= absorb; + } } //3. Apply directional soundcones |