aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-12-03 05:43:53 -0800
committerChris Robinson <[email protected]>2020-12-04 11:15:50 -0800
commit630a3b8cbd4cd582ba76c2890b9dbe218a8b7730 (patch)
tree1822caa568d3a4119998e2f426b2867917a3205b
parente3179aa058cbb2887b02ce9d27e3a3c2da270516 (diff)
Move lerp/cubic to alnumeric.h
-rw-r--r--alc/alu.h13
-rw-r--r--alc/mixer/mixer_neon.cpp1
-rw-r--r--alc/mixer/mixer_sse2.cpp1
-rw-r--r--alc/mixer/mixer_sse41.cpp1
-rw-r--r--common/alnumeric.h13
5 files changed, 16 insertions, 13 deletions
diff --git a/alc/alu.h b/alc/alu.h
index b626043e..ac9dddf4 100644
--- a/alc/alu.h
+++ b/alc/alu.h
@@ -39,19 +39,6 @@ constexpr float AirAbsorbGainHF{0.99426f}; /* -0.05dB */
constexpr float ReverbDecayGain{0.001f}; /* -60 dB */
-inline float lerp(float val1, float val2, float mu) noexcept
-{ return val1 + (val2-val1)*mu; }
-inline float cubic(float val1, float val2, float val3, float val4, float mu) noexcept
-{
- const float mu2{mu*mu}, mu3{mu2*mu};
- const float a0{-0.5f*mu3 + mu2 + -0.5f*mu};
- const float a1{ 1.5f*mu3 + -2.5f*mu2 + 1.0f};
- const float a2{-1.5f*mu3 + 2.0f*mu2 + 0.5f*mu};
- const float a3{ 0.5f*mu3 + -0.5f*mu2};
- return val1*a0 + val2*a1 + val3*a2 + val4*a3;
-}
-
-
enum HrtfRequestMode {
Hrtf_Default = 0,
Hrtf_Enable = 1,
diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp
index e9b47b33..1abf216f 100644
--- a/alc/mixer/mixer_neon.cpp
+++ b/alc/mixer/mixer_neon.cpp
@@ -7,6 +7,7 @@
#include "AL/al.h"
#include "AL/alc.h"
#include "alcmain.h"
+#include "alnumeric.h"
#include "alu.h"
#include "hrtf.h"
#include "defs.h"
diff --git a/alc/mixer/mixer_sse2.cpp b/alc/mixer/mixer_sse2.cpp
index f40f6ac5..4c74465f 100644
--- a/alc/mixer/mixer_sse2.cpp
+++ b/alc/mixer/mixer_sse2.cpp
@@ -23,6 +23,7 @@
#include <xmmintrin.h>
#include <emmintrin.h>
+#include "alnumeric.h"
#include "alu.h"
#include "defs.h"
diff --git a/alc/mixer/mixer_sse41.cpp b/alc/mixer/mixer_sse41.cpp
index d3839cb2..8c6a959f 100644
--- a/alc/mixer/mixer_sse41.cpp
+++ b/alc/mixer/mixer_sse41.cpp
@@ -24,6 +24,7 @@
#include <emmintrin.h>
#include <smmintrin.h>
+#include "alnumeric.h"
#include "alu.h"
#include "defs.h"
diff --git a/common/alnumeric.h b/common/alnumeric.h
index d3d0edfd..8d13f9bf 100644
--- a/common/alnumeric.h
+++ b/common/alnumeric.h
@@ -67,6 +67,19 @@ constexpr inline size_t clampz(size_t val, size_t min, size_t max) noexcept
{ return minz(max, maxz(min, val)); }
+constexpr inline float lerp(float val1, float val2, float mu) noexcept
+{ return val1 + (val2-val1)*mu; }
+constexpr inline float cubic(float val1, float val2, float val3, float val4, float mu) noexcept
+{
+ const float mu2{mu*mu}, mu3{mu2*mu};
+ const float a0{-0.5f*mu3 + mu2 + -0.5f*mu};
+ const float a1{ 1.5f*mu3 + -2.5f*mu2 + 1.0f};
+ const float a2{-1.5f*mu3 + 2.0f*mu2 + 0.5f*mu};
+ const float a3{ 0.5f*mu3 + -0.5f*mu2};
+ return val1*a0 + val2*a1 + val3*a2 + val4*a3;
+}
+
+
/** Find the next power-of-2 for non-power-of-2 numbers. */
inline uint32_t NextPowerOf2(uint32_t value) noexcept
{