aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include/alu.h
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-26 07:06:02 +0100
committerSven Gothel <[email protected]>2014-01-26 07:06:02 +0100
commite6f4251945c228a775649b5ccd7f11dd4519c28d (patch)
tree8454b34363358cf9bb502021a68c6985c97daac4 /OpenAL32/Include/alu.h
parent389ae1f767bfad6116e21306fc3cdf89a4cbcc0a (diff)
parent49baa9128dd98e986639def4f24c7522d9ec6b56 (diff)
Merge branch 'UPSTREAM'
Diffstat (limited to 'OpenAL32/Include/alu.h')
-rw-r--r--OpenAL32/Include/alu.h76
1 files changed, 53 insertions, 23 deletions
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 01d3ca29..d88e860c 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -13,13 +13,17 @@
#endif
-#define F_PI (3.14159265358979323846f) /* pi */
-#define F_PI_2 (1.57079632679489661923f) /* pi/2 */
+#define F_PI (3.14159265358979323846f)
+#define F_PI_2 (1.57079632679489661923f)
+#define F_2PI (6.28318530717958647692f)
#ifndef FLT_EPSILON
#define FLT_EPSILON (1.19209290e-07f)
#endif
+#define DEG2RAD(x) ((ALfloat)(x) * (F_PI/180.0f))
+#define RAD2DEG(x) ((ALfloat)(x) * (180.0f/F_PI))
+
#ifdef __cplusplus
extern "C" {
@@ -31,18 +35,20 @@ struct DirectParams;
struct SendParams;
typedef void (*ResamplerFunc)(const ALfloat *src, ALuint frac, ALuint increment,
- ALfloat *RESTRICT dst, ALuint dstlen);
+ ALfloat *restrict dst, ALuint dstlen);
typedef ALvoid (*DryMixerFunc)(const struct DirectParams *params,
- const ALfloat *RESTRICT data, ALuint srcchan,
+ const ALfloat *restrict data, ALuint srcchan,
ALuint OutPos, ALuint SamplesToDo,
ALuint BufferSize);
typedef ALvoid (*WetMixerFunc)(const struct SendParams *params,
- const ALfloat *RESTRICT data,
+ const ALfloat *restrict data,
ALuint OutPos, ALuint SamplesToDo,
ALuint BufferSize);
+#define GAIN_SILENCE_THRESHOLD (0.00001f)
+
#define SPEEDOFSOUNDMETRESPERSEC (343.3f)
#define AIRABSORBGAINHF (0.99426f) /* -0.05dB */
@@ -51,47 +57,54 @@ typedef ALvoid (*WetMixerFunc)(const struct SendParams *params,
#define FRACTIONMASK (FRACTIONONE-1)
-static __inline ALfloat minf(ALfloat a, ALfloat b)
+inline ALfloat minf(ALfloat a, ALfloat b)
{ return ((a > b) ? b : a); }
-static __inline ALfloat maxf(ALfloat a, ALfloat b)
+inline ALfloat maxf(ALfloat a, ALfloat b)
{ return ((a > b) ? a : b); }
-static __inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max)
+inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max)
{ return minf(max, maxf(min, val)); }
-static __inline ALuint minu(ALuint a, ALuint b)
+inline ALdouble mind(ALdouble a, ALdouble b)
+{ return ((a > b) ? b : a); }
+inline ALdouble maxd(ALdouble a, ALdouble b)
+{ return ((a > b) ? a : b); }
+inline ALdouble clampd(ALdouble val, ALdouble min, ALdouble max)
+{ return mind(max, maxd(min, val)); }
+
+inline ALuint minu(ALuint a, ALuint b)
{ return ((a > b) ? b : a); }
-static __inline ALuint maxu(ALuint a, ALuint b)
+inline ALuint maxu(ALuint a, ALuint b)
{ return ((a > b) ? a : b); }
-static __inline ALuint clampu(ALuint val, ALuint min, ALuint max)
+inline ALuint clampu(ALuint val, ALuint min, ALuint max)
{ return minu(max, maxu(min, val)); }
-static __inline ALint mini(ALint a, ALint b)
+inline ALint mini(ALint a, ALint b)
{ return ((a > b) ? b : a); }
-static __inline ALint maxi(ALint a, ALint b)
+inline ALint maxi(ALint a, ALint b)
{ return ((a > b) ? a : b); }
-static __inline ALint clampi(ALint val, ALint min, ALint max)
+inline ALint clampi(ALint val, ALint min, ALint max)
{ return mini(max, maxi(min, val)); }
-static __inline ALint64 mini64(ALint64 a, ALint64 b)
+inline ALint64 mini64(ALint64 a, ALint64 b)
{ return ((a > b) ? b : a); }
-static __inline ALint64 maxi64(ALint64 a, ALint64 b)
+inline ALint64 maxi64(ALint64 a, ALint64 b)
{ return ((a > b) ? a : b); }
-static __inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max)
+inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max)
{ return mini64(max, maxi64(min, val)); }
-static __inline ALuint64 minu64(ALuint64 a, ALuint64 b)
+inline ALuint64 minu64(ALuint64 a, ALuint64 b)
{ return ((a > b) ? b : a); }
-static __inline ALuint64 maxu64(ALuint64 a, ALuint64 b)
+inline ALuint64 maxu64(ALuint64 a, ALuint64 b)
{ return ((a > b) ? a : b); }
-static __inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max)
+inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max)
{ return minu64(max, maxu64(min, val)); }
-static __inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu)
+inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu)
{
return val1 + (val2-val1)*mu;
}
-static __inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu)
+inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu)
{
ALfloat mu2 = mu*mu;
ALfloat a0 = -0.5f*val0 + 1.5f*val1 + -1.5f*val2 + 0.5f*val3;
@@ -105,7 +118,24 @@ static __inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat
ALvoid aluInitPanning(ALCdevice *Device);
-ALvoid ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, ALfloat ingain, ALfloat *gains);
+/**
+ * ComputeAngleGains
+ *
+ * Sets channel gains based on a given source's angle and its half-width. The
+ * angle and hwidth parameters are in radians.
+ */
+void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, ALfloat ingain, ALfloat gains[MaxChannels]);
+
+/**
+ * SetGains
+ *
+ * Helper to set the appropriate channels to the specified gain.
+ */
+inline void SetGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels])
+{
+ ComputeAngleGains(device, 0.0f, F_PI, ingain, gains);
+}
+
ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);
ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext);