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
fir8_32(const ALfloat
*vals
, ALuint frac
)
18 { return resample_fir8(vals
[-3], vals
[-2], vals
[-1], vals
[0], vals
[1], vals
[2], vals
[3], vals
[4], frac
); }
21 const ALfloat
*Resample_copy32_C(const BsincState
* UNUSED(state
), const ALfloat
*src
, ALuint
UNUSED(frac
),
22 ALuint
UNUSED(increment
), ALfloat
*restrict dst
, ALuint numsamples
)
24 #if defined(HAVE_SSE) || defined(HAVE_NEON)
25 /* Avoid copying the source data if it's aligned like the destination. */
26 if((((intptr_t)src
)&15) == (((intptr_t)dst
)&15))
29 memcpy(dst
, src
, numsamples
*sizeof(ALfloat
));
33 #define DECL_TEMPLATE(Sampler) \
34 const ALfloat *Resample_##Sampler##_C(const BsincState* UNUSED(state), \
35 const ALfloat *src, ALuint frac, ALuint increment, \
36 ALfloat *restrict dst, ALuint numsamples) \
39 for(i = 0;i < numsamples;i++) \
41 dst[i] = Sampler(src, frac); \
44 src += frac>>FRACTIONBITS; \
45 frac &= FRACTIONMASK; \
50 DECL_TEMPLATE(point32
)
52 DECL_TEMPLATE(fir4_32
)
53 DECL_TEMPLATE(fir8_32
)
57 const ALfloat
*Resample_bsinc32_C(const BsincState
*state
, const ALfloat
*src
, ALuint frac
,
58 ALuint increment
, ALfloat
*restrict dst
, ALuint dstlen
)
60 const ALfloat
*fil
, *scd
, *phd
, *spd
;
61 const ALfloat sf
= state
->sf
;
62 const ALuint m
= state
->m
;
63 const ALint l
= state
->l
;
68 for(i
= 0;i
< dstlen
;i
++)
70 // Calculate the phase index and factor.
71 #define FRAC_PHASE_BITDIFF (FRACTIONBITS-BSINC_PHASE_BITS)
72 pi
= frac
>> FRAC_PHASE_BITDIFF
;
73 pf
= (frac
& ((1<<FRAC_PHASE_BITDIFF
)-1)) * (1.0f
/(1<<FRAC_PHASE_BITDIFF
));
74 #undef FRAC_PHASE_BITDIFF
76 fil
= state
->coeffs
[pi
].filter
;
77 scd
= state
->coeffs
[pi
].scDelta
;
78 phd
= state
->coeffs
[pi
].phDelta
;
79 spd
= state
->coeffs
[pi
].spDelta
;
81 // Apply the scale and phase interpolated filter.
83 for(j_f
= 0,j_s
= l
;j_f
< m
;j_f
++,j_s
++)
84 r
+= (fil
[j_f
] + sf
*scd
[j_f
] + pf
*(phd
[j_f
] + sf
*spd
[j_f
])) *
89 src
+= frac
>>FRACTIONBITS
;
96 void ALfilterState_processC(ALfilterState
*filter
, ALfloat
*restrict dst
, const ALfloat
*src
, ALuint numsamples
)
99 for(i
= 0;i
< numsamples
;i
++)
100 *(dst
++) = ALfilterState_processSingle(filter
, *(src
++));
104 static inline void ApplyCoeffsStep(ALuint Offset
, ALfloat (*restrict Values
)[2],
106 ALfloat (*restrict Coeffs
)[2],
107 const ALfloat (*restrict CoeffStep
)[2],
108 ALfloat left
, ALfloat right
)
111 for(c
= 0;c
< IrSize
;c
++)
113 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
114 Values
[off
][0] += Coeffs
[c
][0] * left
;
115 Values
[off
][1] += Coeffs
[c
][1] * right
;
116 Coeffs
[c
][0] += CoeffStep
[c
][0];
117 Coeffs
[c
][1] += CoeffStep
[c
][1];
121 static inline void ApplyCoeffs(ALuint Offset
, ALfloat (*restrict Values
)[2],
123 ALfloat (*restrict Coeffs
)[2],
124 ALfloat left
, ALfloat right
)
127 for(c
= 0;c
< IrSize
;c
++)
129 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
130 Values
[off
][0] += Coeffs
[c
][0] * left
;
131 Values
[off
][1] += Coeffs
[c
][1] * right
;
135 #define MixHrtf MixHrtf_C
136 #include "mixer_inc.c"
140 void Mix_C(const ALfloat
*data
, ALuint OutChans
, ALfloat (*restrict OutBuffer
)[BUFFERSIZE
],
141 MixGains
*Gains
, ALuint Counter
, ALuint OutPos
, ALuint BufferSize
)
146 for(c
= 0;c
< OutChans
;c
++)
149 gain
= Gains
[c
].Current
;
150 step
= Gains
[c
].Step
;
151 if(step
!= 0.0f
&& Counter
> 0)
153 ALuint minsize
= minu(BufferSize
, Counter
);
154 for(;pos
< minsize
;pos
++)
156 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*gain
;
160 gain
= Gains
[c
].Target
;
161 Gains
[c
].Current
= gain
;
164 if(!(fabsf(gain
) > GAIN_SILENCE_THRESHOLD
))
166 for(;pos
< BufferSize
;pos
++)
167 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*gain
;