diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -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; |