diff options
author | Chris Robinson <[email protected]> | 2018-03-29 15:41:51 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-03-29 16:11:46 -0700 |
commit | 4a8c3b50b649815af123a08689efd7d16f9a571b (patch) | |
tree | 79c57333b8a2a18dcd91f64e0610d3a0b0460461 | |
parent | 852ad41176b089dcb808533aad9f2fd1384c11bd (diff) |
Apply the initial decay and air absorption after gain clamping
-rw-r--r-- | Alc/ALu.c | 84 |
1 files changed, 42 insertions, 42 deletions
@@ -1317,48 +1317,6 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop break; } - /* Distance-based air absorption */ - if(ClampedDist > props->RefDistance && props->RolloffFactor > 0.0f) - { - ALfloat meters_base = (ClampedDist-props->RefDistance) * props->RolloffFactor * - Listener->Params.MetersPerUnit; - if(props->AirAbsorptionFactor > 0.0f) - { - ALfloat hfattn = powf(AIRABSORBGAINHF, meters_base * props->AirAbsorptionFactor); - DryGainHF *= hfattn; - for(i = 0;i < NumSends;i++) - WetGainHF[i] *= hfattn; - } - - if(props->WetGainAuto) - { - /* Apply a decay-time transformation to the wet path, based on the - * source distance in meters. The initial decay of the reverb - * effect is calculated and applied to the wet path. - */ - for(i = 0;i < NumSends;i++) - { - ALfloat gain, gainhf, gainlf; - - if(!(DecayDistance[i] > 0.0f)) - continue; - - gain = powf(REVERB_DECAY_GAIN, meters_base/DecayDistance[i]); - WetGain[i] *= gain; - /* Yes, the wet path's air absorption is applied with - * WetGainAuto on, rather than WetGainHFAuto. - */ - if(gain > 0.0f) - { - gainhf = powf(REVERB_DECAY_GAIN, meters_base/DecayHFDistance[i]); - WetGainHF[i] *= minf(gainhf / gain, 1.0f); - gainlf = powf(REVERB_DECAY_GAIN, meters_base/DecayLFDistance[i]); - WetGainLF[i] *= minf(gainlf / gain, 1.0f); - } - } - } - } - /* Calculate directional soundcones */ if(directional && props->InnerAngle < 360.0f) { @@ -1414,6 +1372,48 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop WetGainLF[i] *= props->Send[i].GainLF; } + /* Distance-based air absorption and initial send decay. */ + if(ClampedDist > props->RefDistance && props->RolloffFactor > 0.0f) + { + ALfloat meters_base = (ClampedDist-props->RefDistance) * props->RolloffFactor * + Listener->Params.MetersPerUnit; + if(props->AirAbsorptionFactor > 0.0f) + { + ALfloat hfattn = powf(AIRABSORBGAINHF, meters_base * props->AirAbsorptionFactor); + DryGainHF *= hfattn; + for(i = 0;i < NumSends;i++) + WetGainHF[i] *= hfattn; + } + + if(props->WetGainAuto) + { + /* Apply a decay-time transformation to the wet path, based on the + * source distance in meters. The initial decay of the reverb + * effect is calculated and applied to the wet path. + */ + for(i = 0;i < NumSends;i++) + { + ALfloat gain, gainhf, gainlf; + + if(!(DecayDistance[i] > 0.0f)) + continue; + + gain = powf(REVERB_DECAY_GAIN, meters_base/DecayDistance[i]); + WetGain[i] *= gain; + /* Yes, the wet path's air absorption is applied with + * WetGainAuto on, rather than WetGainHFAuto. + */ + if(gain > 0.0f) + { + gainhf = powf(REVERB_DECAY_GAIN, meters_base/DecayHFDistance[i]); + WetGainHF[i] *= minf(gainhf / gain, 1.0f); + gainlf = powf(REVERB_DECAY_GAIN, meters_base/DecayLFDistance[i]); + WetGainLF[i] *= minf(gainlf / gain, 1.0f); + } + } + } + } + /* Initial source pitch */ Pitch = props->Pitch; |