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
+1)*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+1;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
UNUSED(SamplesToDo
), 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 Step
= params
->Mix
.Gains
.Step
[srcchan
][c
];
97 if(Step
!= 0.0f
&& Counter
> 0)
99 DrySend
= params
->Mix
.Gains
.Current
[srcchan
][c
];
100 for(;pos
< BufferSize
&& pos
< Counter
;pos
++)
102 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*DrySend
;
105 params
->Mix
.Gains
.Current
[srcchan
][c
] = DrySend
;
108 DrySend
= params
->Mix
.Gains
.Target
[srcchan
][c
];
109 if(!(DrySend
> GAIN_SILENCE_THRESHOLD
))
111 for(;pos
< BufferSize
;pos
++)
112 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*DrySend
;
117 void MixSend_C(SendParams
*params
, const ALfloat
*restrict data
,
118 ALuint OutPos
, ALuint SamplesToDo
, ALuint BufferSize
)
120 ALfloat (*restrict OutBuffer
)[BUFFERSIZE
] = params
->OutBuffer
;
121 ALfloat
*restrict ClickRemoval
= params
->ClickRemoval
;
122 ALfloat
*restrict PendingClicks
= params
->PendingClicks
;
126 WetSend
= params
->Gain
;
127 if(!(WetSend
> GAIN_SILENCE_THRESHOLD
))
131 ClickRemoval
[0] -= data
[0] * WetSend
;
132 for(pos
= 0;pos
< BufferSize
;pos
++)
133 OutBuffer
[0][OutPos
+pos
] += data
[pos
] * WetSend
;
134 if(OutPos
+pos
== SamplesToDo
)
135 PendingClicks
[0] += data
[pos
] * WetSend
;