aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-05-25 16:37:31 -0700
committerChris Robinson <[email protected]>2020-05-25 16:37:31 -0700
commit4e82feffef6c9c380e6f18a2836df72ac750dc26 (patch)
treeb02245b9c2dba2376416e1eed7552e0ffd759bb0 /alc
parent5eb1ae5a140c1a1f0ecd85bb4441c3ff8ebfef0b (diff)
Only apply non-silent inputs for blended HRIR
Diffstat (limited to 'alc')
-rw-r--r--alc/mixer/hrtfbase.h41
1 files changed, 24 insertions, 17 deletions
diff --git a/alc/mixer/hrtfbase.h b/alc/mixer/hrtfbase.h
index c96ae9bd..e8850447 100644
--- a/alc/mixer/hrtfbase.h
+++ b/alc/mixer/hrtfbase.h
@@ -48,29 +48,36 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl
const auto &NewCoeffs = *newparams->Coeffs;
const float newGainStep{newparams->GainStep};
- size_t ldelay{HRTF_HISTORY_LENGTH - oldparams->Delay[0]};
- size_t rdelay{HRTF_HISTORY_LENGTH - oldparams->Delay[1]};
- auto stepcount = static_cast<float>(BufferSize);
- for(size_t i{0u};i < BufferSize;++i)
+ if LIKELY(oldparams->Gain > GAIN_SILENCE_THRESHOLD)
{
- const float g{oldGainStep*stepcount};
- const float left{InSamples[ldelay++] * g};
- const float right{InSamples[rdelay++] * g};
- ApplyCoeffs(AccumSamples+i, IrSize, OldCoeffs, left, right);
+ size_t ldelay{HRTF_HISTORY_LENGTH - oldparams->Delay[0]};
+ size_t rdelay{HRTF_HISTORY_LENGTH - oldparams->Delay[1]};
+ auto stepcount = static_cast<float>(BufferSize);
+ for(size_t i{0u};i < BufferSize;++i)
+ {
+ const float g{oldGainStep*stepcount};
+ const float left{InSamples[ldelay++] * g};
+ const float right{InSamples[rdelay++] * g};
+ ApplyCoeffs(AccumSamples+i, IrSize, OldCoeffs, left, right);
- stepcount -= 1.0f;
+ stepcount -= 1.0f;
+ }
}
- ldelay = HRTF_HISTORY_LENGTH - newparams->Delay[0];
- rdelay = HRTF_HISTORY_LENGTH - newparams->Delay[1];
- for(size_t i{0u};i < BufferSize;++i)
+ if LIKELY(newGainStep*static_cast<float>(BufferSize) > GAIN_SILENCE_THRESHOLD)
{
- const float g{newGainStep*stepcount};
- const float left{InSamples[ldelay++] * g};
- const float right{InSamples[rdelay++] * g};
- ApplyCoeffs(AccumSamples+i, IrSize, NewCoeffs, left, right);
+ size_t ldelay{HRTF_HISTORY_LENGTH - newparams->Delay[0]};
+ size_t rdelay{HRTF_HISTORY_LENGTH - newparams->Delay[1]};
+ float stepcount{0.0f};
+ for(size_t i{0u};i < BufferSize;++i)
+ {
+ const float g{newGainStep*stepcount};
+ const float left{InSamples[ldelay++] * g};
+ const float right{InSamples[rdelay++] * g};
+ ApplyCoeffs(AccumSamples+i, IrSize, NewCoeffs, left, right);
- stepcount += 1.0f;
+ stepcount += 1.0f;
+ }
}
}