diff options
author | Boris I. Bendovsky <[email protected]> | 2022-01-30 14:47:32 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-01-30 04:47:32 -0800 |
commit | 19ed994dc30ed84ea7cbbb5152577669fc25caf6 (patch) | |
tree | f68933bf8f778806618bd6c0b1bf9ced1b0ccf08 /common/alnumeric.h | |
parent | 619249371a40f03cf988d1f5750d643df797c485 (diff) |
Add EAX extensions (EAX 2.0-5.0, X-RAM) (#632)
* Add EAX extensions (EAX 2.0-5.0, X-RAM)
* Comment out C++17 leftovers
* Remove everything related to patching
* Update alsoftrc.sample
* Rewrite integration
* Fix GCC compilation under Linux
* Always reset EAX effect properties when loading it into FX slot
Diffstat (limited to 'common/alnumeric.h')
-rw-r--r-- | common/alnumeric.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/common/alnumeric.h b/common/alnumeric.h index c16f3e62..d72ba1e3 100644 --- a/common/alnumeric.h +++ b/common/alnumeric.h @@ -1,6 +1,10 @@ #ifndef AL_NUMERIC_H #define AL_NUMERIC_H +#if ALSOFT_EAX +#include <cmath> +#endif // ALSOFT_EAX + #include <cstddef> #include <cstdint> #ifdef HAVE_INTRIN_H @@ -271,4 +275,45 @@ 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 +{ + return value < min_value ? min_value : (value > max_value ? max_value : value); +} + +// Converts level (mB) to gain. +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); + } +} + +// Converts gain to level (mB). +inline float gain_to_level_mb( + float x) +{ + if (x <= 0.0F) + { + return -10'000.0F; + } + else + { + return std::log10(x * 2'000.0F); + } +} +#endif // ALSOFT_EAX + #endif /* AL_NUMERIC_H */ |