aboutsummaryrefslogtreecommitdiffstats
path: root/alc/mixer/hrtfbase.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-11-03 00:30:33 -0700
committerChris Robinson <[email protected]>2019-11-03 00:30:33 -0700
commitd2608e4bde41b3005a06346bea99bbe06404ef22 (patch)
treeb57b085c64bff88056b07437c41ddf6e09d7d9de /alc/mixer/hrtfbase.h
parent2741a94e58ed2f9a17d05fd2499e1a3ea4ac43e8 (diff)
Avoid holding HRTF accumulation samples per-source
It notably simplifies things to mix HRTF sources into an accumulation buffer together, which the Dry buffer's Ambisonic-to-HRTF decode is then added to, before being mixed to the Real output.
Diffstat (limited to 'alc/mixer/hrtfbase.h')
-rw-r--r--alc/mixer/hrtfbase.h27
1 files changed, 8 insertions, 19 deletions
diff --git a/alc/mixer/hrtfbase.h b/alc/mixer/hrtfbase.h
index cbc885c5..4a6eab50 100644
--- a/alc/mixer/hrtfbase.h
+++ b/alc/mixer/hrtfbase.h
@@ -13,9 +13,8 @@ using ApplyCoeffsT = void(&)(float2 *RESTRICT Values, const ALuint irSize, const
const float left, const float right);
template<ApplyCoeffsT ApplyCoeffs>
-inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
- const float *InSamples, float2 *RESTRICT AccumSamples, const size_t OutPos,
- const ALuint IrSize, MixHrtfFilter *hrtfparams, const size_t BufferSize)
+inline void MixHrtfBase(const float *InSamples, float2 *RESTRICT AccumSamples, const ALuint IrSize,
+ MixHrtfFilter *hrtfparams, const size_t BufferSize)
{
ASSUME(BufferSize > 0);
@@ -38,17 +37,11 @@ inline void MixHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
stepcount += 1.0f;
}
- for(size_t i{0u};i < BufferSize;++i)
- LeftOut[OutPos+i] += AccumSamples[i][0];
- for(size_t i{0u};i < BufferSize;++i)
- RightOut[OutPos+i] += AccumSamples[i][1];
-
hrtfparams->Gain = gain + gainstep*stepcount;
}
template<ApplyCoeffsT ApplyCoeffs>
-inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
- const float *InSamples, float2 *RESTRICT AccumSamples, const size_t OutPos,
+inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSamples,
const ALuint IrSize, const HrtfFilter *oldparams, MixHrtfFilter *newparams,
const size_t BufferSize)
{
@@ -89,11 +82,6 @@ inline void MixHrtfBlendBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut
stepcount += 1.0f;
}
- for(size_t i{0u};i < BufferSize;++i)
- LeftOut[OutPos+i] += AccumSamples[i][0];
- for(size_t i{0u};i < BufferSize;++i)
- RightOut[OutPos+i] += AccumSamples[i][1];
-
newparams->Gain = newGainStep*stepcount;
}
@@ -106,9 +94,6 @@ inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOu
const ALuint IrSize{State->IrSize};
- auto accum_iter = std::copy_n(State->Values.begin(), State->Values.size(), AccumSamples);
- std::fill_n(accum_iter, BufferSize, float2{});
-
auto coeff_iter = State->Coeffs.begin();
for(const FloatBufferLine &input : InSamples)
{
@@ -124,7 +109,11 @@ inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOu
for(size_t i{0u};i < BufferSize;++i)
RightOut[i] += AccumSamples[i][1];
- std::copy_n(AccumSamples + BufferSize, State->Values.size(), State->Values.begin());
+ /* Copy the new in-progress accumulation values to the front and clear the
+ * following samples for the next mix.
+ */
+ auto accum_iter = std::copy_n(AccumSamples+BufferSize, HRIR_LENGTH, AccumSamples);
+ std::fill_n(accum_iter, BufferSize, float2{});
}
#endif /* MIXER_HRTFBASE_H */