Avoid tracing wide-char strings
[openal-soft.git] / Alc / mixer_inc.c
blob63003f03aa096fa8b07452793d3fc0bd41903b0a
1 #include "config.h"
3 #include "alMain.h"
4 #include "alSource.h"
6 #include "hrtf.h"
7 #include "mixer_defs.h"
8 #include "align.h"
11 #define REAL_MERGE(a,b) a##b
12 #define MERGE(a,b) REAL_MERGE(a,b)
14 #define MixHrtf MERGE(MixHrtf_,SUFFIX)
17 static inline void SetupCoeffs(ALfloat (*restrict OutCoeffs)[2],
18 const HrtfParams *hrtfparams,
19 ALuint IrSize, ALuint Counter);
20 static inline void ApplyCoeffsStep(ALuint Offset, ALfloat (*restrict Values)[2],
21 const ALuint irSize,
22 ALfloat (*restrict Coeffs)[2],
23 const ALfloat (*restrict CoeffStep)[2],
24 ALfloat left, ALfloat right);
25 static inline void ApplyCoeffs(ALuint Offset, ALfloat (*restrict Values)[2],
26 const ALuint irSize,
27 ALfloat (*restrict Coeffs)[2],
28 ALfloat left, ALfloat right);
31 void MixHrtf(ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat *data,
32 ALuint Counter, ALuint Offset, ALuint OutPos, const ALuint IrSize,
33 const HrtfParams *hrtfparams, HrtfState *hrtfstate, ALuint BufferSize)
35 alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
36 ALuint Delay[2];
37 ALfloat left, right;
38 ALuint pos;
40 SetupCoeffs(Coeffs, hrtfparams, IrSize, Counter);
41 Delay[0] = hrtfparams->Delay[0] - (hrtfparams->DelayStep[0]*Counter);
42 Delay[1] = hrtfparams->Delay[1] - (hrtfparams->DelayStep[1]*Counter);
44 pos = 0;
45 for(;pos < BufferSize && pos < Counter;pos++)
47 hrtfstate->History[Offset&HRTF_HISTORY_MASK] = data[pos];
48 left = lerp(hrtfstate->History[(Offset-(Delay[0]>>HRTFDELAY_BITS))&HRTF_HISTORY_MASK],
49 hrtfstate->History[(Offset-(Delay[0]>>HRTFDELAY_BITS)-1)&HRTF_HISTORY_MASK],
50 (Delay[0]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE));
51 right = lerp(hrtfstate->History[(Offset-(Delay[1]>>HRTFDELAY_BITS))&HRTF_HISTORY_MASK],
52 hrtfstate->History[(Offset-(Delay[1]>>HRTFDELAY_BITS)-1)&HRTF_HISTORY_MASK],
53 (Delay[1]&HRTFDELAY_MASK)*(1.0f/HRTFDELAY_FRACONE));
55 Delay[0] += hrtfparams->DelayStep[0];
56 Delay[1] += hrtfparams->DelayStep[1];
58 hrtfstate->Values[(Offset+IrSize)&HRIR_MASK][0] = 0.0f;
59 hrtfstate->Values[(Offset+IrSize)&HRIR_MASK][1] = 0.0f;
60 Offset++;
62 ApplyCoeffsStep(Offset, hrtfstate->Values, IrSize, Coeffs, hrtfparams->CoeffStep, left, right);
63 OutBuffer[0][OutPos] += hrtfstate->Values[Offset&HRIR_MASK][0];
64 OutBuffer[1][OutPos] += hrtfstate->Values[Offset&HRIR_MASK][1];
65 OutPos++;
68 Delay[0] >>= HRTFDELAY_BITS;
69 Delay[1] >>= HRTFDELAY_BITS;
70 for(;pos < BufferSize;pos++)
72 hrtfstate->History[Offset&HRTF_HISTORY_MASK] = data[pos];
73 left = hrtfstate->History[(Offset-Delay[0])&HRTF_HISTORY_MASK];
74 right = hrtfstate->History[(Offset-Delay[1])&HRTF_HISTORY_MASK];
76 hrtfstate->Values[(Offset+IrSize)&HRIR_MASK][0] = 0.0f;
77 hrtfstate->Values[(Offset+IrSize)&HRIR_MASK][1] = 0.0f;
78 Offset++;
80 ApplyCoeffs(Offset, hrtfstate->Values, IrSize, Coeffs, left, right);
81 OutBuffer[0][OutPos] += hrtfstate->Values[Offset&HRIR_MASK][0];
82 OutBuffer[1][OutPos] += hrtfstate->Values[Offset&HRIR_MASK][1];
83 OutPos++;
88 #undef MixHrtf
90 #undef MERGE
91 #undef REAL_MERGE