aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-05-16 11:35:55 -0700
committerChris Robinson <[email protected]>2020-05-16 11:35:55 -0700
commit36aebbb6ae02337a58705bd0cfd98be407a89c85 (patch)
treee7b164491d445b6abb50b9b23446448637556c64
parent0f81fafc6274068003a5d4fcf3a6e33f621d2665 (diff)
Include the existing direct signal in the UHJ delay
So any direct_channels sources and normal panned sources remain aligned, and the reported latency is accurate.
-rw-r--r--alc/uhjfilter.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/alc/uhjfilter.cpp b/alc/uhjfilter.cpp
index faf8fa3f..e0469bf9 100644
--- a/alc/uhjfilter.cpp
+++ b/alc/uhjfilter.cpp
@@ -165,6 +165,9 @@ void Uhj2Encoder::encode(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
{
ASSUME(SamplesToDo > 0);
+ float *RESTRICT left{al::assume_aligned<16>(LeftOut.data())};
+ float *RESTRICT right{al::assume_aligned<16>(RightOut.data())};
+
const float *RESTRICT winput{al::assume_aligned<16>(InSamples[0].data())};
const float *RESTRICT xinput{al::assume_aligned<16>(InSamples[1].data())};
const float *RESTRICT yinput{al::assume_aligned<16>(InSamples[2].data())};
@@ -178,6 +181,12 @@ void Uhj2Encoder::encode(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
std::transform(yinput, yinput+SamplesToDo, mSide.begin(),
[](const float y) noexcept -> float { return 0.6554516f*y; });
+ /* Include any existing direct signal in the mid/side buffers. */
+ for(size_t i{0};i < SamplesToDo;++i)
+ mMid[i] += left[i] + right[i];
+ for(size_t i{0};i < SamplesToDo;++i)
+ mSide[i] += left[i] - right[i];
+
/* Apply a delay to the non-filtered signal to align with the filter delay. */
if LIKELY(SamplesToDo >= sFilterSize)
{
@@ -209,11 +218,9 @@ void Uhj2Encoder::encode(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
allpass_process({mSide.data(), SamplesToDo}, mTemp.data());
/* Left = (S + D)/2.0 */
- float *RESTRICT left{al::assume_aligned<16>(LeftOut.data())};
for(size_t i{0};i < SamplesToDo;i++)
- left[i] += (mMid[i] + mSide[i]) * 0.5f;
+ left[i] = (mMid[i] + mSide[i]) * 0.5f;
/* Right = (S - D)/2.0 */
- float *RESTRICT right{al::assume_aligned<16>(RightOut.data())};
for(size_t i{0};i < SamplesToDo;i++)
- right[i] += (mMid[i] - mSide[i]) * 0.5f;
+ right[i] = (mMid[i] - mSide[i]) * 0.5f;
}