aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-01-30 05:42:44 -0800
committerChris Robinson <[email protected]>2022-01-30 05:42:44 -0800
commit816bd8ab309dc0fe9afefcc5e3f2c294d3dc60a5 (patch)
tree75cf4b9c90bb3aa8d461b6a7dc417329bd2175d3 /common
parentc9d59ebc4a2c3566d34759a901be639b5f932e30 (diff)
Move ALSOFT_EAX definition to config.h
And disable it by default for non-Windows targets
Diffstat (limited to 'common')
-rw-r--r--common/alnumeric.h46
1 files changed, 13 insertions, 33 deletions
diff --git a/common/alnumeric.h b/common/alnumeric.h
index d72ba1e3..18df2689 100644
--- a/common/alnumeric.h
+++ b/common/alnumeric.h
@@ -1,10 +1,8 @@
#ifndef AL_NUMERIC_H
#define AL_NUMERIC_H
-#if ALSOFT_EAX
+#include <algorithm>
#include <cmath>
-#endif // ALSOFT_EAX
-
#include <cstddef>
#include <cstdint>
#ifdef HAVE_INTRIN_H
@@ -275,45 +273,27 @@ inline float fast_roundf(float f) noexcept
#endif
}
-#if ALSOFT_EAX
-template<
- typename T
->
-inline constexpr const T& clamp(
- const T& value,
- const T& min_value,
- const T& max_value) noexcept
+
+template<typename T>
+constexpr const T& clamp(const T& value, const T& min_value, const T& max_value) noexcept
{
- return value < min_value ? min_value : (value > max_value ? max_value : value);
+ return std::min(std::max(value, min_value), max_value);
}
// Converts level (mB) to gain.
-inline float level_mb_to_gain(
- float x)
+inline float level_mb_to_gain(float x)
{
- if (x <= -10'000.0F)
- {
- return 0.0F;
- }
- else
- {
- return std::pow(10.0F, x / 2'000.0F);
- }
+ if(x <= -10'000.0f)
+ return 0.0f;
+ return std::pow(10.0f, x / 2'000.0f);
}
// Converts gain to level (mB).
-inline float gain_to_level_mb(
- float x)
+inline float gain_to_level_mb(float x)
{
- if (x <= 0.0F)
- {
- return -10'000.0F;
- }
- else
- {
- return std::log10(x * 2'000.0F);
- }
+ if (x <= 0.0f)
+ return -10'000.0f;
+ return std::log10(x * 2'000.0f);
}
-#endif // ALSOFT_EAX
#endif /* AL_NUMERIC_H */