15 #define M_PI 3.14159265358979323846 /* pi */
16 #define M_PI_2 1.57079632679489661923 /* pi/2 */
20 #define aluPow(x,y) ((ALfloat)powf((float)(x),(float)(y)))
22 #define aluPow(x,y) ((ALfloat)pow((double)(x),(double)(y)))
26 #define aluSqrt(x) ((ALfloat)sqrtf((float)(x)))
28 #define aluSqrt(x) ((ALfloat)sqrt((double)(x)))
32 #define aluAcos(x) ((ALfloat)acosf((float)(x)))
34 #define aluAcos(x) ((ALfloat)acos((double)(x)))
38 #define aluAtan(x) ((ALfloat)atanf((float)(x)))
40 #define aluAtan(x) ((ALfloat)atan((double)(x)))
44 #define aluFabs(x) ((ALfloat)fabsf((float)(x)))
46 #define aluFabs(x) ((ALfloat)fabs((double)(x)))
50 #if defined(max) && !defined(__max)
53 #if defined(min) && !defined(__min)
57 #define QUADRANT_NUM 128
58 #define LUT_NUM (4 * QUADRANT_NUM)
78 #define BUFFERSIZE 8192
80 #define FRACTIONBITS (14)
81 #define FRACTIONONE (1<<FRACTIONBITS)
82 #define FRACTIONMASK (FRACTIONONE-1)
83 #define MAX_PITCH (INT_MAX & ~FRACTIONMASK)
85 /* NOTE: The AL_FORMAT_REAR* enums aren't handled here because they're
86 * converted to AL_FORMAT_QUAD* when loaded */
87 static __inline ALuint
aluBytesFromFormat(ALenum format
)
92 case AL_FORMAT_STEREO8
:
93 case AL_FORMAT_QUAD8_LOKI
:
95 case AL_FORMAT_51CHN8
:
96 case AL_FORMAT_61CHN8
:
97 case AL_FORMAT_71CHN8
:
100 case AL_FORMAT_MONO16
:
101 case AL_FORMAT_STEREO16
:
102 case AL_FORMAT_QUAD16_LOKI
:
103 case AL_FORMAT_QUAD16
:
104 case AL_FORMAT_51CHN16
:
105 case AL_FORMAT_61CHN16
:
106 case AL_FORMAT_71CHN16
:
109 case AL_FORMAT_MONO_FLOAT32
:
110 case AL_FORMAT_STEREO_FLOAT32
:
111 case AL_FORMAT_QUAD32
:
112 case AL_FORMAT_51CHN32
:
113 case AL_FORMAT_61CHN32
:
114 case AL_FORMAT_71CHN32
:
117 case AL_FORMAT_MONO_DOUBLE_EXT
:
118 case AL_FORMAT_STEREO_DOUBLE_EXT
:
125 static __inline ALuint
aluChannelsFromFormat(ALenum format
)
129 case AL_FORMAT_MONO8
:
130 case AL_FORMAT_MONO16
:
131 case AL_FORMAT_MONO_FLOAT32
:
132 case AL_FORMAT_MONO_DOUBLE_EXT
:
135 case AL_FORMAT_STEREO8
:
136 case AL_FORMAT_STEREO16
:
137 case AL_FORMAT_STEREO_FLOAT32
:
138 case AL_FORMAT_STEREO_DOUBLE_EXT
:
141 case AL_FORMAT_QUAD8_LOKI
:
142 case AL_FORMAT_QUAD16_LOKI
:
143 case AL_FORMAT_QUAD8
:
144 case AL_FORMAT_QUAD16
:
145 case AL_FORMAT_QUAD32
:
148 case AL_FORMAT_51CHN8
:
149 case AL_FORMAT_51CHN16
:
150 case AL_FORMAT_51CHN32
:
153 case AL_FORMAT_61CHN8
:
154 case AL_FORMAT_61CHN16
:
155 case AL_FORMAT_61CHN32
:
158 case AL_FORMAT_71CHN8
:
159 case AL_FORMAT_71CHN16
:
160 case AL_FORMAT_71CHN32
:
167 static __inline ALuint
aluFrameSizeFromFormat(ALenum format
)
169 return aluBytesFromFormat(format
) * aluChannelsFromFormat(format
);
172 static __inline ALint
aluCart2LUTpos(ALfloat re
, ALfloat im
)
175 ALfloat denom
= aluFabs(re
) + aluFabs(im
);
177 pos
= (ALint
)(QUADRANT_NUM
*aluFabs(im
) / denom
+ 0.5);
180 pos
= 2 * QUADRANT_NUM
- pos
;
186 static __inline ALdouble
lerp(ALdouble val1
, ALdouble val2
, ALdouble mu
)
188 val1
+= (val2
-val1
) * mu
;
191 static __inline ALdouble
cubic(ALdouble val0
, ALdouble val1
, ALdouble val2
, ALdouble val3
, ALdouble mu
)
193 ALdouble mu2
= mu
*mu
;
194 ALdouble a0
= -0.5*val0
+ 1.5*val1
+ -1.5*val2
+ 0.5*val3
;
195 ALdouble a1
= val0
+ -2.5*val1
+ 2.0*val2
+ -0.5*val3
;
196 ALdouble a2
= -0.5*val0
+ 0.5*val2
;
199 return a0
*mu
*mu2
+ a1
*mu2
+ a2
*mu
+ a3
;
204 ALvoid
aluInitPanning(ALCdevice
*Device
);
206 ALvoid
CalcSourceParams(struct ALsource
*ALSource
, const ALCcontext
*ALContext
);
207 ALvoid
CalcNonAttnSourceParams(struct ALsource
*ALSource
, const ALCcontext
*ALContext
);
209 ALvoid
MixSource(struct ALsource
*Source
, ALCdevice
*Device
, ALuint SamplesToDo
);
211 ALvoid
aluMixData(ALCdevice
*device
, ALvoid
*buffer
, ALsizei size
);
212 ALvoid
aluHandleDisconnect(ALCdevice
*device
);