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 4096
80 #define FRACTIONBITS (14)
81 #define FRACTIONONE (1<<FRACTIONBITS)
82 #define FRACTIONMASK (FRACTIONONE-1)
84 /* Size for temporary stack storage of buffer data. Larger values need more
85 * stack, while smaller values may need more iterations. The value needs to be
86 * a sensible size, however, as it constrains the max stepping value used for
88 * The mixer requires being able to do two samplings per mixing loop. A 16KB
89 * buffer can hold 512 sample frames for a 7.1 float buffer. With the cubic
90 * resampler (which requires 3 padding sample frames), this limits the maximum
91 * step to about 508. This means that buffer_freq*source_pitch cannot exceed
92 * device_freq*508 for an 8-channel 32-bit buffer. */
93 #ifndef STACK_DATA_SIZE
94 #define STACK_DATA_SIZE 16384
98 ALuint
aluBytesFromFormat(ALenum format
);
99 ALuint
aluChannelsFromFormat(ALenum format
);
100 static __inline ALuint
aluFrameSizeFromFormat(ALenum format
)
102 return aluBytesFromFormat(format
) * aluChannelsFromFormat(format
);
105 static __inline ALdouble
lerp(ALdouble val1
, ALdouble val2
, ALdouble mu
)
107 return val1
+ (val2
-val1
)*mu
;
109 static __inline ALdouble
cubic(ALdouble val0
, ALdouble val1
, ALdouble val2
, ALdouble val3
, ALdouble mu
)
111 ALdouble mu2
= mu
*mu
;
112 ALdouble a0
= -0.5*val0
+ 1.5*val1
+ -1.5*val2
+ 0.5*val3
;
113 ALdouble a1
= val0
+ -2.5*val1
+ 2.0*val2
+ -0.5*val3
;
114 ALdouble a2
= -0.5*val0
+ 0.5*val2
;
117 return a0
*mu
*mu2
+ a1
*mu2
+ a2
*mu
+ a3
;
122 ALvoid
aluInitPanning(ALCdevice
*Device
);
123 ALint
aluCart2LUTpos(ALfloat re
, ALfloat im
);
125 ALvoid
CalcSourceParams(struct ALsource
*ALSource
, const ALCcontext
*ALContext
);
126 ALvoid
CalcNonAttnSourceParams(struct ALsource
*ALSource
, const ALCcontext
*ALContext
);
128 ALvoid
MixSource(struct ALsource
*Source
, ALCdevice
*Device
, ALuint SamplesToDo
);
130 ALvoid
aluMixData(ALCdevice
*device
, ALvoid
*buffer
, ALsizei size
);
131 ALvoid
aluHandleDisconnect(ALCdevice
*device
);