aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-04-09 22:42:45 -0700
committerChris Robinson <[email protected]>2019-04-09 22:42:45 -0700
commitd6f72b777a058f3feb42eb109b0baf66070c0528 (patch)
tree1289e6eb87abffece1f57c82fb7b2e75473f1686
parent55a3f38405c6c5e5510a01a28ca0b30648a43b37 (diff)
Fix usage of the voice's HRTF accumulation buffer when blending
-rw-r--r--Alc/mixvoice.cpp27
1 files changed, 7 insertions, 20 deletions
diff --git a/Alc/mixvoice.cpp b/Alc/mixvoice.cpp
index 210ddf4f..b2356514 100644
--- a/Alc/mixvoice.cpp
+++ b/Alc/mixvoice.cpp
@@ -650,6 +650,11 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
auto accum_iter = std::copy_n(parms.Hrtf.State.Values.begin(),
parms.Hrtf.State.Values.size(), std::begin(AccumSamples));
+ /* Clear the accumulation buffer that will start getting
+ * filled in.
+ */
+ std::fill_n(accum_iter, DstBufferSize, float2{});
+
/* If fading, the old gain is not silence, and this is the
* first mixing pass, fade between the IRs.
*/
@@ -657,11 +662,6 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
{
fademix = mini(DstBufferSize, 128);
- /* Clear the accumulation buffer that will start
- * getting filled in.
- */
- std::fill_n(accum_iter, fademix, float2{});
-
ALfloat gain{TargetGain};
/* The new coefficients need to fade in completely
@@ -693,24 +693,11 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
parms.Hrtf.Old.Gain = hrtfparams.Gain;
else
parms.Hrtf.Old.Gain = TargetGain;
-
- /* Copy the new in-progress accumulation values to the
- * front of the temp buffer for the following mix.
- */
- accum_iter = std::copy(std::begin(AccumSamples) + fademix,
- std::begin(AccumSamples) + fademix + HRIR_LENGTH,
- std::begin(AccumSamples));
}
if(LIKELY(fademix < DstBufferSize))
{
const ALsizei todo{DstBufferSize - fademix};
-
- /* Clear the accumulation buffer that will start
- * getting filled in.
- */
- std::fill_n(accum_iter, todo, float2{});
-
ALfloat gain{TargetGain};
/* Interpolate the target gain if the gain fading lasts
@@ -732,8 +719,8 @@ void MixVoice(ALvoice *voice, ALvoice::State vstate, const ALuint SourceID, ALCc
static_cast<ALfloat>(todo);
MixHrtfSamples(
voice->mDirect.Buffer[OutLIdx], voice->mDirect.Buffer[OutRIdx],
- HrtfSamples+fademix, AccumSamples, OutPos+fademix, IrSize, &hrtfparams,
- todo);
+ HrtfSamples+fademix, AccumSamples+fademix, OutPos+fademix, IrSize,
+ &hrtfparams, todo);
/* Store the interpolated gain or the final target gain
* depending if the fade is done.
*/