Only apply non-silent inputs for blended HRIR

This commit is contained in:
Chris Robinson 2020-05-25 16:37:31 -07:00
parent 5eb1ae5a14
commit 4e82feffef

View File

@ -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;
}
}
}