aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-09-22 17:01:47 -0700
committerChris Robinson <[email protected]>2008-09-22 17:01:47 -0700
commit6567cdd7b5839da03b623c845ce942815691cd06 (patch)
tree16900a339ee69924482b7a0d8bdd9e7eb4e9c140
parent5bbf55a401a6460a833eec841b29682104e0b1e6 (diff)
Air absorption factor is applied to the dB value, not linear gain
-rw-r--r--Alc/ALu.c28
-rw-r--r--OpenAL32/Include/alMain.h1
2 files changed, 16 insertions, 13 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index f2ffb739..9baf6cee 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -383,34 +383,36 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource,
break;
case AL_NONE:
- default:
flAttenuation = 1.0f;
RoomAttenuation = 1.0f;
break;
}
- // Source Gain + Attenuation and clamp to Min/Max Gain
- DryMix = SourceVolume * flAttenuation;
- DryMix = __min(DryMix,MaxVolume);
- DryMix = __max(DryMix,MinVolume);
-
- WetMix = SourceVolume * RoomAttenuation;
- WetMix = __min(WetMix,MaxVolume);
- WetMix = __max(WetMix,MinVolume);
-
// Distance-based air absorption
- if(ALSource->AirAbsorptionFactor > 0.0f)
+ if(ALSource->AirAbsorptionFactor > 0.0f && ALContext->DistanceModel != AL_NONE)
{
ALfloat dist = Distance-MinDist;
ALfloat absorb;
if(dist < 0.0f) dist = 0.0f;
- absorb = pow(ALSource->AirAbsorptionFactor * AIRABSORBGAINHF,
- Distance * MetersPerUnit);
+ // Absorption calculation is done in dB
+ absorb = (ALSource->AirAbsorptionFactor*AIRABSORBGAINDBHF) *
+ (Distance*MetersPerUnit);
+ // Convert dB to linear gain before applying
+ absorb = pow(0.5, absorb/-6.0);
DryGainHF *= absorb;
WetGainHF *= absorb;
}
+ // Source Gain + Attenuation and clamp to Min/Max Gain
+ DryMix = SourceVolume * flAttenuation;
+ DryMix = __min(DryMix,MaxVolume);
+ DryMix = __max(DryMix,MinVolume);
+
+ WetMix = SourceVolume * RoomAttenuation;
+ WetMix = __min(WetMix,MaxVolume);
+ WetMix = __max(WetMix,MinVolume);
+
//3. Apply directional soundcones
Angle = aluAcos(aluDotproduct(Direction,SourceToListener)) * 180.0f /
3.141592654f;
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index fb9cfb5e..f378a72f 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -126,6 +126,7 @@ extern char _alDebug[256];
#define SPEEDOFSOUNDMETRESPERSEC (343.3f)
#define AIRABSORBGAINHF (0.994f)
+#define AIRABSORBGAINDBHF (-0.05f)
#define LOWPASSFREQCUTOFF (5000)