aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include/alu.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-11-19 09:24:35 -0800
committerChris Robinson <[email protected]>2009-11-19 09:24:35 -0800
commitff8e09495d846f303479e75d11ef8b2e2957265f (patch)
tree7f6ebe3956767cfe8ad70946fec537b4411ce429 /OpenAL32/Include/alu.h
parente868eef67991f2d858ba4f11836789face0245ad (diff)
Move aluCart2LUTpos to alu.h
Diffstat (limited to 'OpenAL32/Include/alu.h')
-rw-r--r--OpenAL32/Include/alu.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 62350c3f..978527e5 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -5,6 +5,7 @@
#include "AL/alc.h"
#include "AL/alext.h"
+#include <math.h>
#ifdef HAVE_FLOAT_H
#include <float.h>
#endif
@@ -46,6 +47,9 @@
#define __min min
#endif
+#define QUADRANT_NUM 128
+#define LUT_NUM (4 * QUADRANT_NUM)
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -145,6 +149,20 @@ static __inline ALuint aluChannelsFromFormat(ALenum format)
}
}
+static __inline ALint aluCart2LUTpos(ALfloat re, ALfloat im)
+{
+ ALint pos = 0;
+ ALfloat denom = aluFabs(re) + aluFabs(im);
+ if(denom > 0.0f)
+ pos = (ALint)(QUADRANT_NUM*aluFabs(im) / denom + 0.5);
+
+ if(re < 0.0)
+ pos = 2 * QUADRANT_NUM - pos;
+ if(im < 0.0)
+ pos = LUT_NUM - pos;
+ return pos%LUT_NUM;
+}
+
ALvoid aluInitPanning(ALCcontext *Context);
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
ALvoid aluHandleDisconnect(ALCdevice *device);