6 #include "alAuxEffectSlot.h"
9 static __inline ALfloat
point32(const ALfloat
*vals
, ALuint frac
)
10 { return vals
[0]; (void)frac
; }
11 static __inline ALfloat
lerp32(const ALfloat
*vals
, ALuint frac
)
12 { return lerp(vals
[0], vals
[1], frac
* (1.0f
/FRACTIONONE
)); }
13 static __inline ALfloat
cubic32(const ALfloat
*vals
, ALuint frac
)
14 { return cubic(vals
[-1], vals
[0], vals
[1], vals
[2], frac
* (1.0f
/FRACTIONONE
)); }
16 #define DECL_TEMPLATE(Sampler) \
17 void Resample_##Sampler##_C(const ALfloat *data, ALuint frac, \
18 ALuint increment, ALfloat *RESTRICT OutBuffer, ALuint BufferSize) \
23 for(i = 0;i < BufferSize+1;i++) \
25 OutBuffer[i] = Sampler(data + pos, frac); \
28 pos += frac>>FRACTIONBITS; \
29 frac &= FRACTIONMASK; \
33 DECL_TEMPLATE(point32
)
35 DECL_TEMPLATE(cubic32
)
40 static __inline
void ApplyCoeffsStep(ALuint Offset
, ALfloat (*RESTRICT Values
)[2],
42 ALfloat (*RESTRICT Coeffs
)[2],
43 ALfloat (*RESTRICT CoeffStep
)[2],
44 ALfloat left
, ALfloat right
)
47 for(c
= 0;c
< IrSize
;c
++)
49 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
50 Values
[off
][0] += Coeffs
[c
][0] * left
;
51 Values
[off
][1] += Coeffs
[c
][1] * right
;
52 Coeffs
[c
][0] += CoeffStep
[c
][0];
53 Coeffs
[c
][1] += CoeffStep
[c
][1];
57 static __inline
void ApplyCoeffs(ALuint Offset
, ALfloat (*RESTRICT Values
)[2],
59 ALfloat (*RESTRICT Coeffs
)[2],
60 ALfloat left
, ALfloat right
)
63 for(c
= 0;c
< IrSize
;c
++)
65 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
66 Values
[off
][0] += Coeffs
[c
][0] * left
;
67 Values
[off
][1] += Coeffs
[c
][1] * right
;
72 #include "mixer_inc.c"
76 void MixDirect_C(ALsource
*Source
, ALCdevice
*Device
, DirectParams
*params
,
77 const ALfloat
*RESTRICT data
, ALuint srcchan
,
78 ALuint OutPos
, ALuint SamplesToDo
, ALuint BufferSize
)
80 ALfloat (*RESTRICT DryBuffer
)[BUFFERSIZE
] = Device
->DryBuffer
;
81 ALfloat
*RESTRICT ClickRemoval
= Device
->ClickRemoval
;
82 ALfloat
*RESTRICT PendingClicks
= Device
->PendingClicks
;
88 for(c
= 0;c
< MaxChannels
;c
++)
90 DrySend
= params
->Gains
[srcchan
][c
];
91 if(DrySend
< 0.00001f
)
95 ClickRemoval
[c
] -= data
[0]*DrySend
;
96 for(pos
= 0;pos
< BufferSize
;pos
++)
97 DryBuffer
[c
][OutPos
+pos
] += data
[pos
]*DrySend
;
98 if(OutPos
+pos
== SamplesToDo
)
99 PendingClicks
[c
] += data
[pos
]*DrySend
;
104 void MixSend_C(SendParams
*params
, const ALfloat
*RESTRICT data
,
105 ALuint OutPos
, ALuint SamplesToDo
, ALuint BufferSize
)
107 ALeffectslot
*Slot
= params
->Slot
;
108 ALfloat (*RESTRICT WetBuffer
)[BUFFERSIZE
] = Slot
->WetBuffer
;
109 ALfloat
*RESTRICT WetClickRemoval
= Slot
->ClickRemoval
;
110 ALfloat
*RESTRICT WetPendingClicks
= Slot
->PendingClicks
;
111 ALfloat WetSend
= params
->Gain
;
115 WetClickRemoval
[0] -= data
[0] * WetSend
;
116 for(pos
= 0;pos
< BufferSize
;pos
++)
117 WetBuffer
[0][OutPos
+pos
] += data
[pos
] * WetSend
;
118 if(OutPos
+pos
== SamplesToDo
)
119 WetPendingClicks
[0] += data
[pos
] * WetSend
;