Use a separate method to set initial HRTF coefficients

This commit is contained in:
Chris Robinson
2014-11-24 22:26:42 -08:00
parent cbe22763ee
commit 8e6c131b36
4 changed files with 52 additions and 6 deletions
+12
View File
@@ -59,6 +59,18 @@ void ALfilterState_processC(ALfilterState *filter, ALfloat *restrict dst, const
}
static inline void SetupCoeffs(ALfloat (*restrict OutCoeffs)[2],
const HrtfParams *hrtfparams,
ALuint IrSize, ALuint Counter)
{
ALuint c;
for(c = 0;c < IrSize;c++)
{
OutCoeffs[c][0] = hrtfparams->Coeffs[c][0] - (hrtfparams->CoeffStep[c][0]*Counter);
OutCoeffs[c][1] = hrtfparams->Coeffs[c][1] - (hrtfparams->CoeffStep[c][1]*Counter);
}
}
static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2],
const ALuint IrSize,
ALfloat (*restrict Coeffs)[2],
+4 -6
View File
@@ -14,6 +14,9 @@
#define MixHrtf MERGE(MixHrtf_,SUFFIX)
static inline void SetupCoeffs(ALfloat (*restrict OutCoeffs)[2],
const HrtfParams *hrtfparams,
ALuint IrSize, ALuint Counter);
static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2],
const ALuint irSize,
ALfloat (*restrict Coeffs)[2],
@@ -33,13 +36,8 @@ void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
ALuint Delay[2];
ALfloat left, right;
ALuint pos;
ALuint c;
for(c = 0;c < IrSize;c++)
{
Coeffs[c][0] = hrtfparams->Coeffs[c][0] - (hrtfparams->CoeffStep[c][0]*Counter);
Coeffs[c][1] = hrtfparams->Coeffs[c][1] - (hrtfparams->CoeffStep[c][1]*Counter);
}
SetupCoeffs(Coeffs, hrtfparams, IrSize, Counter);
Delay[0] = hrtfparams->Delay[0] - (hrtfparams->DelayStep[0]*Counter);
Delay[1] = hrtfparams->Delay[1] - (hrtfparams->DelayStep[1]*Counter);
+19
View File
@@ -9,6 +9,25 @@
#include "hrtf.h"
static inline void SetupCoeffs(ALfloat (*restrict OutCoeffs)[2],
const HrtfParams *hrtfparams,
ALuint IrSize, ALuint Counter)
{
ALuint c;
float32x4_t counter4;
{
float32x2_t counter2 = vdup_n_f32(-(float)Counter);
counter4 = vcombine_f32(counter2, counter2);
}
for(c = 0;c < IrSize;c += 2)
{
float32x4_t step4 = vld1q_f32((float32_t*)hrtfparams->CoeffStep[c]);
float32x4_t coeffs = vld1q_f32((float32_t*)hrtfparams->Coeffs[c]);
coeffs = vmlaq_f32(coeffs, step4, counter4);
vst1q_f32((float32_t*)OutCoeffs[c], coeffs);
}
}
static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2],
const ALuint IrSize,
ALfloat (*restrict Coeffs)[2],
+17
View File
@@ -19,6 +19,23 @@
#include "mixer_defs.h"
static inline void SetupCoeffs(ALfloat (*restrict OutCoeffs)[2],
const HrtfParams *hrtfparams,
ALuint IrSize, ALuint Counter)
{
const __m128 counter4 = _mm_set1_ps((float)Counter);
__m128 coeffs, step4;
ALuint i;
for(i = 0;i < IrSize;i += 2)
{
step4 = _mm_load_ps(&hrtfparams->CoeffStep[i][0]);
coeffs = _mm_load_ps(&hrtfparams->Coeffs[i][0]);
coeffs = _mm_sub_ps(coeffs, _mm_mul_ps(step4, counter4));
_mm_store_ps(&OutCoeffs[i][0], coeffs);
}
}
static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2],
const ALuint IrSize,
ALfloat (*restrict Coeffs)[2],