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
cubic32(const ALfloat
*vals
, ALuint frac
)
16 { return cubic(vals
[-1], vals
[0], vals
[1], vals
[2], frac
* (1.0f
/FRACTIONONE
)); }
18 void Resample_copy32_C(const ALfloat
*data
, ALuint
UNUSED(frac
),
19 ALuint increment
, ALfloat
*restrict OutBuffer
, ALuint BufferSize
)
21 assert(increment
==FRACTIONONE
);
22 memcpy(OutBuffer
, data
, BufferSize
*sizeof(ALfloat
));
25 #define DECL_TEMPLATE(Sampler) \
26 void Resample_##Sampler##_C(const ALfloat *data, ALuint frac, \
27 ALuint increment, ALfloat *restrict OutBuffer, ALuint BufferSize) \
32 for(i = 0;i < BufferSize;i++) \
34 OutBuffer[i] = Sampler(data + pos, frac); \
37 pos += frac>>FRACTIONBITS; \
38 frac &= FRACTIONMASK; \
42 DECL_TEMPLATE(point32
)
44 DECL_TEMPLATE(cubic32
)
49 static inline void ApplyCoeffsStep(ALuint Offset
, ALfloat (*restrict Values
)[2],
51 ALfloat (*restrict Coeffs
)[2],
52 const ALfloat (*restrict CoeffStep
)[2],
53 ALfloat left
, ALfloat right
)
56 for(c
= 0;c
< IrSize
;c
++)
58 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
59 Values
[off
][0] += Coeffs
[c
][0] * left
;
60 Values
[off
][1] += Coeffs
[c
][1] * right
;
61 Coeffs
[c
][0] += CoeffStep
[c
][0];
62 Coeffs
[c
][1] += CoeffStep
[c
][1];
66 static inline void ApplyCoeffs(ALuint Offset
, ALfloat (*restrict Values
)[2],
68 ALfloat (*restrict Coeffs
)[2],
69 ALfloat left
, ALfloat right
)
72 for(c
= 0;c
< IrSize
;c
++)
74 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
75 Values
[off
][0] += Coeffs
[c
][0] * left
;
76 Values
[off
][1] += Coeffs
[c
][1] * right
;
81 #include "mixer_inc.c"
85 void MixDirect_C(DirectParams
*params
, const ALfloat
*restrict data
, ALuint srcchan
,
86 ALuint OutPos
, ALuint BufferSize
)
88 ALfloat (*restrict OutBuffer
)[BUFFERSIZE
] = params
->OutBuffer
;
89 ALuint Counter
= maxu(params
->Counter
, OutPos
) - OutPos
;
90 ALfloat DrySend
, Step
;
93 for(c
= 0;c
< MaxChannels
;c
++)
96 DrySend
= params
->Mix
.Gains
.Current
[srcchan
][c
];
97 Step
= params
->Mix
.Gains
.Step
[srcchan
][c
];
98 if(Step
!= 1.0f
&& Counter
> 0)
100 for(;pos
< BufferSize
&& pos
< Counter
;pos
++)
102 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*DrySend
;
106 DrySend
= params
->Mix
.Gains
.Target
[srcchan
][c
];
107 params
->Mix
.Gains
.Current
[srcchan
][c
] = DrySend
;
110 if(!(DrySend
> GAIN_SILENCE_THRESHOLD
))
112 for(;pos
< BufferSize
;pos
++)
113 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*DrySend
;
118 void MixSend_C(SendParams
*params
, const ALfloat
*restrict data
,
119 ALuint OutPos
, ALuint BufferSize
)
121 ALfloat (*restrict OutBuffer
)[BUFFERSIZE
] = params
->OutBuffer
;
122 ALuint Counter
= maxu(params
->Counter
, OutPos
) - OutPos
;
123 ALfloat WetSend
, Step
;
127 WetSend
= params
->Gain
.Current
;
128 Step
= params
->Gain
.Step
;
129 if(Step
!= 1.0f
&& Counter
> 0)
131 for(;pos
< BufferSize
&& pos
< Counter
;pos
++)
133 OutBuffer
[0][OutPos
+pos
] += data
[pos
]*WetSend
;
137 WetSend
= params
->Gain
.Target
;
138 params
->Gain
.Current
= WetSend
;
141 if(!(WetSend
> GAIN_SILENCE_THRESHOLD
))
143 for(;pos
< BufferSize
;pos
++)
144 OutBuffer
[0][OutPos
+pos
] += data
[pos
] * WetSend
;