Pass the offset latency properties to the set handler
[openal-soft.git] / OpenAL32 / Include / alu.h
blob11c03332a24c7f6086a97c1ac471d9138fac73e3
1 #ifndef _ALU_H_
2 #define _ALU_H_
4 #include "alMain.h"
6 #include <limits.h>
7 #include <math.h>
8 #ifdef HAVE_FLOAT_H
9 #include <float.h>
10 #endif
11 #ifdef HAVE_IEEEFP_H
12 #include <ieeefp.h>
13 #endif
16 #define F_PI (3.14159265358979323846f) /* pi */
17 #define F_PI_2 (1.57079632679489661923f) /* pi/2 */
19 #ifndef FLT_EPSILON
20 #define FLT_EPSILON (1.19209290e-07f)
21 #endif
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 struct ALsource;
29 struct ALbuffer;
30 struct DirectParams;
31 struct SendParams;
33 typedef void (*ResamplerFunc)(const ALfloat *src, ALuint frac, ALuint increment,
34 ALfloat *RESTRICT dst, ALuint dstlen);
36 typedef ALvoid (*DryMixerFunc)(const struct DirectParams *params,
37 const ALfloat *RESTRICT data, ALuint srcchan,
38 ALuint OutPos, ALuint SamplesToDo,
39 ALuint BufferSize);
40 typedef ALvoid (*WetMixerFunc)(const struct SendParams *params,
41 const ALfloat *RESTRICT data,
42 ALuint OutPos, ALuint SamplesToDo,
43 ALuint BufferSize);
46 #define SPEEDOFSOUNDMETRESPERSEC (343.3f)
47 #define AIRABSORBGAINHF (0.99426f) /* -0.05dB */
49 #define FRACTIONBITS (14)
50 #define FRACTIONONE (1<<FRACTIONBITS)
51 #define FRACTIONMASK (FRACTIONONE-1)
54 static __inline ALfloat minf(ALfloat a, ALfloat b)
55 { return ((a > b) ? b : a); }
56 static __inline ALfloat maxf(ALfloat a, ALfloat b)
57 { return ((a > b) ? a : b); }
58 static __inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max)
59 { return minf(max, maxf(min, val)); }
61 static __inline ALuint minu(ALuint a, ALuint b)
62 { return ((a > b) ? b : a); }
63 static __inline ALuint maxu(ALuint a, ALuint b)
64 { return ((a > b) ? a : b); }
65 static __inline ALuint clampu(ALuint val, ALuint min, ALuint max)
66 { return minu(max, maxu(min, val)); }
68 static __inline ALint mini(ALint a, ALint b)
69 { return ((a > b) ? b : a); }
70 static __inline ALint maxi(ALint a, ALint b)
71 { return ((a > b) ? a : b); }
72 static __inline ALint clampi(ALint val, ALint min, ALint max)
73 { return mini(max, maxi(min, val)); }
75 static __inline ALint64 mini64(ALint64 a, ALint64 b)
76 { return ((a > b) ? b : a); }
77 static __inline ALint64 maxi64(ALint64 a, ALint64 b)
78 { return ((a > b) ? a : b); }
79 static __inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max)
80 { return mini64(max, maxi64(min, val)); }
82 static __inline ALuint64 minu64(ALuint64 a, ALuint64 b)
83 { return ((a > b) ? b : a); }
84 static __inline ALuint64 maxu64(ALuint64 a, ALuint64 b)
85 { return ((a > b) ? a : b); }
86 static __inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max)
87 { return minu64(max, maxu64(min, val)); }
90 static __inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu)
92 return val1 + (val2-val1)*mu;
94 static __inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu)
96 ALfloat mu2 = mu*mu;
97 ALfloat a0 = -0.5f*val0 + 1.5f*val1 + -1.5f*val2 + 0.5f*val3;
98 ALfloat a1 = val0 + -2.5f*val1 + 2.0f*val2 + -0.5f*val3;
99 ALfloat a2 = -0.5f*val0 + 0.5f*val2;
100 ALfloat a3 = val1;
102 return a0*mu*mu2 + a1*mu2 + a2*mu + a3;
106 ALvoid aluInitPanning(ALCdevice *Device);
108 ALvoid ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, ALfloat ingain, ALfloat *gains);
110 ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
111 ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
113 ALvoid MixSource(struct ALsource *Source, ALCdevice *Device, ALuint SamplesToDo);
115 ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
116 ALvoid aluHandleDisconnect(ALCdevice *device);
118 extern ALfloat ConeScale;
119 extern ALfloat ZScale;
121 #ifdef __cplusplus
123 #endif
125 #endif