8 #include "alAuxEffectSlot.h"
11 static inline ALfloat
point32(const ALfloat
*vals
, ALuint
UNUSED(frac
))
13 static inline ALfloat
lerp32(const ALfloat
*vals
, ALuint frac
)
14 { return lerp(vals
[0], vals
[1], frac
* (1.0f
/FRACTIONONE
)); }
15 static inline ALfloat
fir4_32(const ALfloat
*vals
, ALuint frac
)
16 { return resample_fir4(vals
[-1], vals
[0], vals
[1], vals
[2], frac
); }
17 static inline ALfloat
fir6_32(const ALfloat
*vals
, ALuint frac
)
18 { return resample_fir6(vals
[-2], vals
[-1], vals
[0], vals
[1], vals
[2], vals
[3], frac
); }
20 const ALfloat
*Resample_copy32_C(const ALfloat
*src
, ALuint
UNUSED(frac
),
21 ALuint
UNUSED(increment
), ALfloat
*restrict dst
, ALuint numsamples
)
23 #if defined(HAVE_SSE) || defined(HAVE_NEON)
24 /* Avoid copying the source data if it's aligned like the destination. */
25 if((((intptr_t)src
)&15) == (((intptr_t)dst
)&15))
28 memcpy(dst
, src
, numsamples
*sizeof(ALfloat
));
32 #define DECL_TEMPLATE(Sampler) \
33 const ALfloat *Resample_##Sampler##_C(const ALfloat *src, ALuint frac, \
34 ALuint increment, ALfloat *restrict dst, ALuint numsamples) \
37 for(i = 0;i < numsamples;i++) \
39 dst[i] = Sampler(src, frac); \
42 src += frac>>FRACTIONBITS; \
43 frac &= FRACTIONMASK; \
48 DECL_TEMPLATE(point32
)
50 DECL_TEMPLATE(fir4_32
)
51 DECL_TEMPLATE(fir6_32
)
56 void ALfilterState_processC(ALfilterState
*filter
, ALfloat
*restrict dst
, const ALfloat
*src
, ALuint numsamples
)
59 for(i
= 0;i
< numsamples
;i
++)
60 *(dst
++) = ALfilterState_processSingle(filter
, *(src
++));
64 static inline void SetupCoeffs(ALfloat (*restrict OutCoeffs
)[2],
65 const HrtfParams
*hrtfparams
,
66 ALuint IrSize
, ALuint Counter
)
69 for(c
= 0;c
< IrSize
;c
++)
71 OutCoeffs
[c
][0] = hrtfparams
->Coeffs
[c
][0] - (hrtfparams
->CoeffStep
[c
][0]*Counter
);
72 OutCoeffs
[c
][1] = hrtfparams
->Coeffs
[c
][1] - (hrtfparams
->CoeffStep
[c
][1]*Counter
);
76 static inline void ApplyCoeffsStep(ALuint Offset
, ALfloat (*restrict Values
)[2],
78 ALfloat (*restrict Coeffs
)[2],
79 const ALfloat (*restrict CoeffStep
)[2],
80 ALfloat left
, ALfloat right
)
83 for(c
= 0;c
< IrSize
;c
++)
85 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
86 Values
[off
][0] += Coeffs
[c
][0] * left
;
87 Values
[off
][1] += Coeffs
[c
][1] * right
;
88 Coeffs
[c
][0] += CoeffStep
[c
][0];
89 Coeffs
[c
][1] += CoeffStep
[c
][1];
93 static inline void ApplyCoeffs(ALuint Offset
, ALfloat (*restrict Values
)[2],
95 ALfloat (*restrict Coeffs
)[2],
96 ALfloat left
, ALfloat right
)
99 for(c
= 0;c
< IrSize
;c
++)
101 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
102 Values
[off
][0] += Coeffs
[c
][0] * left
;
103 Values
[off
][1] += Coeffs
[c
][1] * right
;
107 #define MixHrtf MixHrtf_C
108 #include "mixer_inc.c"
112 void Mix_C(const ALfloat
*data
, ALuint OutChans
, ALfloat (*restrict OutBuffer
)[BUFFERSIZE
],
113 MixGains
*Gains
, ALuint Counter
, ALuint OutPos
, ALuint BufferSize
)
118 for(c
= 0;c
< OutChans
;c
++)
121 gain
= Gains
[c
].Current
;
122 step
= Gains
[c
].Step
;
123 if(step
!= 0.0f
&& Counter
> 0)
125 ALuint minsize
= minu(BufferSize
, Counter
);
126 for(;pos
< minsize
;pos
++)
128 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*gain
;
132 gain
= Gains
[c
].Target
;
133 Gains
[c
].Current
= gain
;
136 if(!(fabsf(gain
) > GAIN_SILENCE_THRESHOLD
))
138 for(;pos
< BufferSize
;pos
++)
139 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*gain
;