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 void ALfilterState_processC(ALfilterState
*filter
, ALfloat
*restrict dst
, const ALfloat
*src
, ALuint numsamples
)
52 for(i
= 0;i
< numsamples
;i
++)
53 *(dst
++) = ALfilterState_processSingle(filter
, *(src
++));
57 static inline void ApplyCoeffsStep(ALuint Offset
, ALfloat (*restrict Values
)[2],
59 ALfloat (*restrict Coeffs
)[2],
60 const ALfloat (*restrict CoeffStep
)[2],
61 ALfloat left
, ALfloat right
)
64 for(c
= 0;c
< IrSize
;c
++)
66 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
67 Values
[off
][0] += Coeffs
[c
][0] * left
;
68 Values
[off
][1] += Coeffs
[c
][1] * right
;
69 Coeffs
[c
][0] += CoeffStep
[c
][0];
70 Coeffs
[c
][1] += CoeffStep
[c
][1];
74 static inline void ApplyCoeffs(ALuint Offset
, ALfloat (*restrict Values
)[2],
76 ALfloat (*restrict Coeffs
)[2],
77 ALfloat left
, ALfloat right
)
80 for(c
= 0;c
< IrSize
;c
++)
82 const ALuint off
= (Offset
+c
)&HRIR_MASK
;
83 Values
[off
][0] += Coeffs
[c
][0] * left
;
84 Values
[off
][1] += Coeffs
[c
][1] * right
;
89 #include "mixer_inc.c"
93 void MixDirect_C(ALfloat (*restrict OutBuffer
)[BUFFERSIZE
], const ALfloat
*data
,
94 MixGains
*Gains
, ALuint Counter
, ALuint OutPos
, ALuint BufferSize
)
96 ALfloat DrySend
, Step
;
99 for(c
= 0;c
< MaxChannels
;c
++)
102 DrySend
= Gains
->Current
[c
];
103 Step
= Gains
->Step
[c
];
104 if(Step
!= 1.0f
&& Counter
> 0)
106 for(;pos
< BufferSize
&& pos
< Counter
;pos
++)
108 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*DrySend
;
112 DrySend
= Gains
->Target
[c
];
113 Gains
->Current
[c
] = DrySend
;
116 if(!(DrySend
> GAIN_SILENCE_THRESHOLD
))
118 for(;pos
< BufferSize
;pos
++)
119 OutBuffer
[c
][OutPos
+pos
] += data
[pos
]*DrySend
;
124 void MixSend_C(SendParams
*params
, const ALfloat
*restrict data
,
125 ALuint OutPos
, ALuint BufferSize
)
127 ALfloat (*restrict OutBuffer
)[BUFFERSIZE
] = params
->OutBuffer
;
128 ALuint Counter
= maxu(params
->Counter
, OutPos
) - OutPos
;
129 ALfloat WetSend
, Step
;
133 WetSend
= params
->Gain
.Current
;
134 Step
= params
->Gain
.Step
;
135 if(Step
!= 1.0f
&& Counter
> 0)
137 for(;pos
< BufferSize
&& pos
< Counter
;pos
++)
139 OutBuffer
[0][OutPos
+pos
] += data
[pos
]*WetSend
;
143 WetSend
= params
->Gain
.Target
;
144 params
->Gain
.Current
= WetSend
;
147 if(!(WetSend
> GAIN_SILENCE_THRESHOLD
))
149 for(;pos
< BufferSize
;pos
++)
150 OutBuffer
[0][OutPos
+pos
] += data
[pos
] * WetSend
;