aboutsummaryrefslogtreecommitdiffstats
path: root/core/mixer/defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/mixer/defs.h')
-rw-r--r--core/mixer/defs.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/core/mixer/defs.h b/core/mixer/defs.h
index 48daca9b..4d0d19bf 100644
--- a/core/mixer/defs.h
+++ b/core/mixer/defs.h
@@ -2,7 +2,8 @@
#define CORE_MIXER_DEFS_H
#include <array>
-#include <stdlib.h>
+#include <cstdlib>
+#include <variant>
#include "alspan.h"
#include "core/bufferline.h"
@@ -17,12 +18,12 @@ using uint = unsigned int;
using float2 = std::array<float,2>;
-constexpr int MixerFracBits{16};
-constexpr int MixerFracOne{1 << MixerFracBits};
-constexpr int MixerFracMask{MixerFracOne - 1};
-constexpr int MixerFracHalf{MixerFracOne >> 1};
+inline constexpr int MixerFracBits{16};
+inline constexpr int MixerFracOne{1 << MixerFracBits};
+inline constexpr int MixerFracMask{MixerFracOne - 1};
+inline constexpr int MixerFracHalf{MixerFracOne >> 1};
-constexpr float GainSilenceThreshold{0.00001f}; /* -100dB */
+inline constexpr float GainSilenceThreshold{0.00001f}; /* -100dB */
enum class Resampler : uint8_t {
@@ -59,10 +60,7 @@ struct CubicState {
const CubicCoefficients *filter;
};
-union InterpState {
- CubicState cubic;
- BsincState bsinc;
-};
+using InterpState = std::variant<CubicState,BsincState>;
using ResamplerFunc = void(*)(const InterpState *state, const float *RESTRICT src, uint frac,
const uint increment, const al::span<float> dst);
@@ -94,7 +92,8 @@ void MixDirectHrtf_(const FloatBufferSpan LeftOut, const FloatBufferSpan RightOu
/* Vectorized resampler helpers */
template<size_t N>
-inline void InitPosArrays(uint frac, uint increment, uint (&frac_arr)[N], uint (&pos_arr)[N])
+inline void InitPosArrays(uint frac, uint increment, const al::span<uint,N> frac_arr,
+ const al::span<uint,N> pos_arr)
{
pos_arr[0] = 0;
frac_arr[0] = frac;