16 #define F_PI (3.14159265358979323846f) /* pi */
17 #define F_PI_2 (1.57079632679489661923f) /* pi/2 */
20 static __inline
float powf(float x
, float y
)
21 { return (float)pow(x
, y
); }
25 static __inline
float sqrtf(float x
)
26 { return (float)sqrt(x
); }
30 static __inline
float cosf(float x
)
31 { return (float)cos(x
); }
35 static __inline
float sinf(float x
)
36 { return (float)sin(x
); }
40 static __inline
float acosf(float x
)
41 { return (float)acos(x
); }
45 static __inline
float asinf(float x
)
46 { return (float)asin(x
); }
50 static __inline
float atanf(float x
)
51 { return (float)atan(x
); }
55 static __inline
float atan2f(float x
, float y
)
56 { return (float)atan2(x
, y
); }
60 static __inline
float fabsf(float x
)
61 { return (float)fabs(x
); }
65 static __inline
float log10f(float x
)
66 { return (float)log10(x
); }
70 static __inline
float floorf(float x
)
71 { return (float)floor(x
); }
83 typedef ALvoid (*DryMixerFunc
)(struct ALsource
*self
, ALCdevice
*Device
,
84 struct DirectParams
*params
,
85 const ALfloat
*RESTRICT data
, ALuint srcchan
,
86 ALuint OutPos
, ALuint SamplesToDo
,
88 typedef ALvoid (*WetMixerFunc
)(struct SendParams
*params
,
89 const ALfloat
*RESTRICT data
,
90 ALuint OutPos
, ALuint SamplesToDo
,
94 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
95 #define AIRABSORBGAINHF (0.99426f) /* -0.05dB */
97 #define FRACTIONBITS (14)
98 #define FRACTIONONE (1<<FRACTIONBITS)
99 #define FRACTIONMASK (FRACTIONONE-1)
102 static __inline ALfloat
minf(ALfloat a
, ALfloat b
)
103 { return ((a
> b
) ? b
: a
); }
104 static __inline ALfloat
maxf(ALfloat a
, ALfloat b
)
105 { return ((a
> b
) ? a
: b
); }
106 static __inline ALfloat
clampf(ALfloat val
, ALfloat min
, ALfloat max
)
107 { return minf(max
, maxf(min
, val
)); }
109 static __inline ALuint
minu(ALuint a
, ALuint b
)
110 { return ((a
> b
) ? b
: a
); }
111 static __inline ALuint
maxu(ALuint a
, ALuint b
)
112 { return ((a
> b
) ? a
: b
); }
113 static __inline ALuint
clampu(ALuint val
, ALuint min
, ALuint max
)
114 { return minu(max
, maxu(min
, val
)); }
116 static __inline ALint
mini(ALint a
, ALint b
)
117 { return ((a
> b
) ? b
: a
); }
118 static __inline ALint
maxi(ALint a
, ALint b
)
119 { return ((a
> b
) ? a
: b
); }
120 static __inline ALint
clampi(ALint val
, ALint min
, ALint max
)
121 { return mini(max
, maxi(min
, val
)); }
123 static __inline ALint64
mini64(ALint64 a
, ALint64 b
)
124 { return ((a
> b
) ? b
: a
); }
125 static __inline ALint64
maxi64(ALint64 a
, ALint64 b
)
126 { return ((a
> b
) ? a
: b
); }
127 static __inline ALint64
clampi64(ALint64 val
, ALint64 min
, ALint64 max
)
128 { return mini64(max
, maxi64(min
, val
)); }
130 static __inline ALuint64
minu64(ALuint64 a
, ALuint64 b
)
131 { return ((a
> b
) ? b
: a
); }
132 static __inline ALuint64
maxu64(ALuint64 a
, ALuint64 b
)
133 { return ((a
> b
) ? a
: b
); }
134 static __inline ALuint64
clampu64(ALuint64 val
, ALuint64 min
, ALuint64 max
)
135 { return minu64(max
, maxu64(min
, val
)); }
138 static __inline ALfloat
lerp(ALfloat val1
, ALfloat val2
, ALfloat mu
)
140 return val1
+ (val2
-val1
)*mu
;
142 static __inline ALfloat
cubic(ALfloat val0
, ALfloat val1
, ALfloat val2
, ALfloat val3
, ALfloat mu
)
145 ALfloat a0
= -0.5f
*val0
+ 1.5f
*val1
+ -1.5f
*val2
+ 0.5f
*val3
;
146 ALfloat a1
= val0
+ -2.5f
*val1
+ 2.0f
*val2
+ -0.5f
*val3
;
147 ALfloat a2
= -0.5f
*val0
+ 0.5f
*val2
;
150 return a0
*mu
*mu2
+ a1
*mu2
+ a2
*mu
+ a3
;
154 static __inline
void aluCrossproduct(const ALfloat
*inVector1
, const ALfloat
*inVector2
, ALfloat
*outVector
)
156 outVector
[0] = inVector1
[1]*inVector2
[2] - inVector1
[2]*inVector2
[1];
157 outVector
[1] = inVector1
[2]*inVector2
[0] - inVector1
[0]*inVector2
[2];
158 outVector
[2] = inVector1
[0]*inVector2
[1] - inVector1
[1]*inVector2
[0];
161 static __inline ALfloat
aluDotproduct(const ALfloat
*inVector1
, const ALfloat
*inVector2
)
163 return inVector1
[0]*inVector2
[0] + inVector1
[1]*inVector2
[1] +
164 inVector1
[2]*inVector2
[2];
167 static __inline
void aluNormalize(ALfloat
*inVector
)
169 ALfloat lengthsqr
= aluDotproduct(inVector
, inVector
);
172 ALfloat inv_length
= 1.0f
/sqrtf(lengthsqr
);
173 inVector
[0] *= inv_length
;
174 inVector
[1] *= inv_length
;
175 inVector
[2] *= inv_length
;
180 ALvoid
aluInitPanning(ALCdevice
*Device
);
182 ALvoid
ComputeAngleGains(const ALCdevice
*device
, ALfloat angle
, ALfloat hwidth
, ALfloat ingain
, ALfloat
*gains
);
184 ALvoid
CalcSourceParams(struct ALsource
*ALSource
, const ALCcontext
*ALContext
);
185 ALvoid
CalcNonAttnSourceParams(struct ALsource
*ALSource
, const ALCcontext
*ALContext
);
187 ALvoid
MixSource(struct ALsource
*Source
, ALCdevice
*Device
, ALuint SamplesToDo
);
189 ALvoid
aluMixData(ALCdevice
*device
, ALvoid
*buffer
, ALsizei size
);
190 ALvoid
aluHandleDisconnect(ALCdevice
*device
);
192 extern ALfloat ConeScale
;
193 extern ALfloat ZScale
;