Update OpenAL-Soft to 1.22.0

This commit is contained in:
Alex Szpakowski
2022-04-30 21:02:11 -03:00
parent 4f72a5e5d9
commit 2b15394df5
229 changed files with 30602 additions and 7654 deletions
+17 -47
View File
@@ -12,7 +12,7 @@
using uint = unsigned int;
using ApplyCoeffsT = void(&)(float2 *RESTRICT Values, const size_t irSize,
const HrirArray &Coeffs, const float left, const float right);
const ConstHrirSpan Coeffs, const float left, const float right);
template<ApplyCoeffsT ApplyCoeffs>
inline void MixHrtfBase(const float *InSamples, float2 *RESTRICT AccumSamples, const size_t IrSize,
@@ -20,7 +20,7 @@ inline void MixHrtfBase(const float *InSamples, float2 *RESTRICT AccumSamples, c
{
ASSUME(BufferSize > 0);
const HrirArray &Coeffs = *hrtfparams->Coeffs;
const ConstHrirSpan Coeffs{hrtfparams->Coeffs};
const float gainstep{hrtfparams->GainStep};
const float gain{hrtfparams->Gain};
@@ -45,9 +45,9 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl
{
ASSUME(BufferSize > 0);
const auto &OldCoeffs = oldparams->Coeffs;
const ConstHrirSpan OldCoeffs{oldparams->Coeffs};
const float oldGainStep{oldparams->Gain / static_cast<float>(BufferSize)};
const auto &NewCoeffs = *newparams->Coeffs;
const ConstHrirSpan NewCoeffs{newparams->Coeffs};
const float newGainStep{newparams->GainStep};
if LIKELY(oldparams->Gain > GainSilenceThreshold)
@@ -84,56 +84,24 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl
}
template<ApplyCoeffsT ApplyCoeffs>
inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOut,
inline void MixDirectHrtfBase(const FloatBufferSpan LeftOut, const FloatBufferSpan RightOut,
const al::span<const FloatBufferLine> InSamples, float2 *RESTRICT AccumSamples,
float *TempBuf, HrtfChannelState *ChanState, const size_t IrSize, const size_t BufferSize)
{
ASSUME(BufferSize > 0);
/* Add the existing signal directly to the accumulation buffer, unfiltered,
* and with a delay to align with the input delay.
*/
for(size_t i{0};i < BufferSize;++i)
{
AccumSamples[HrtfDirectDelay+i][0] += LeftOut[i];
AccumSamples[HrtfDirectDelay+i][1] += RightOut[i];
}
for(const FloatBufferLine &input : InSamples)
{
/* For dual-band processing, the signal needs extra scaling applied to
* the high frequency response. The band-splitter alone creates a
* frequency-dependent phase shift, which is not ideal. To counteract
* it, combine it with a backwards phase shift.
* the high frequency response. The band-splitter applies this scaling
* with a consistent phase shift regardless of the scale amount.
*/
/* Load the input signal backwards, into a temp buffer with delay
* padding. The delay serves to reduce the error caused by the IIR
* filter's phase shift on a partial input.
*/
al::span<float> tempbuf{al::assume_aligned<16>(TempBuf), HrtfDirectDelay+BufferSize};
auto tmpiter = std::reverse_copy(input.begin(), input.begin()+BufferSize, tempbuf.begin());
std::copy(ChanState->mDelay.cbegin(), ChanState->mDelay.cend(), tmpiter);
/* Save the unfiltered newest input samples for next time. */
std::copy_n(tempbuf.begin(), ChanState->mDelay.size(), ChanState->mDelay.begin());
/* Apply the all-pass on the reversed signal and reverse the resulting
* sample array. This produces the forward response with a backwards
* phase shift (+n degrees becomes -n degrees).
*/
ChanState->mSplitter.applyAllpass(tempbuf);
tempbuf = tempbuf.subspan<HrtfDirectDelay>();
std::reverse(tempbuf.begin(), tempbuf.end());
/* Now apply the HF scale with the band-splitter. This applies the
* forward phase shift, which cancels out with the backwards phase
* shift to get the original phase on the scaled signal.
*/
ChanState->mSplitter.processHfScale(tempbuf, ChanState->mHfScale);
ChanState->mSplitter.processHfScale({input.data(), BufferSize}, TempBuf,
ChanState->mHfScale);
/* Now apply the HRIR coefficients to this channel. */
const auto &Coeffs = ChanState->mCoeffs;
const float *RESTRICT tempbuf{al::assume_aligned<16>(TempBuf)};
const ConstHrirSpan Coeffs{ChanState->mCoeffs};
for(size_t i{0u};i < BufferSize;++i)
{
const float insample{tempbuf[i]};
@@ -143,16 +111,18 @@ inline void MixDirectHrtfBase(FloatBufferLine &LeftOut, FloatBufferLine &RightOu
++ChanState;
}
/* Add the HRTF signal to the existing "direct" signal. */
float *RESTRICT left{al::assume_aligned<16>(LeftOut.data())};
float *RESTRICT right{al::assume_aligned<16>(RightOut.data())};
for(size_t i{0u};i < BufferSize;++i)
LeftOut[i] = AccumSamples[i][0];
left[i] += AccumSamples[i][0];
for(size_t i{0u};i < BufferSize;++i)
RightOut[i] = AccumSamples[i][1];
right[i] += AccumSamples[i][1];
/* 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, HrirLength+HrtfDirectDelay,
AccumSamples);
auto accum_iter = std::copy_n(AccumSamples+BufferSize, HrirLength, AccumSamples);
std::fill_n(accum_iter, BufferSize, float2{});
}