aboutsummaryrefslogtreecommitdiffstats
path: root/alc/mixer
diff options
context:
space:
mode:
Diffstat (limited to 'alc/mixer')
-rw-r--r--alc/mixer/defs.h3
-rw-r--r--alc/mixer/hrtfbase.h5
-rw-r--r--alc/mixer/hrtfdefs.h52
-rw-r--r--alc/mixer/mixer_c.cpp6
-rw-r--r--alc/mixer/mixer_neon.cpp5
-rw-r--r--alc/mixer/mixer_sse.cpp5
6 files changed, 67 insertions, 9 deletions
diff --git a/alc/mixer/defs.h b/alc/mixer/defs.h
index 897b23ff..69042ea4 100644
--- a/alc/mixer/defs.h
+++ b/alc/mixer/defs.h
@@ -2,6 +2,7 @@
#define MIXER_DEFS_H
#include <array>
+#include <stdlib.h>
#include "alspan.h"
#include "core/bufferline.h"
@@ -25,6 +26,8 @@ constexpr int MixerFracMask{MixerFracOne - 1};
*/
constexpr int MaxResamplerPadding{48};
+constexpr float GainSilenceThreshold{0.00001f}; /* -100dB */
+
enum class Resampler {
Point,
diff --git a/alc/mixer/hrtfbase.h b/alc/mixer/hrtfbase.h
index 4f5b399a..f25801b5 100644
--- a/alc/mixer/hrtfbase.h
+++ b/alc/mixer/hrtfbase.h
@@ -2,10 +2,11 @@
#define MIXER_HRTFBASE_H
#include <algorithm>
+#include <cmath>
-#include "../hrtf.h"
+#include "almalloc.h"
+#include "hrtfdefs.h"
#include "opthelpers.h"
-#include "voice.h"
using uint = unsigned int;
diff --git a/alc/mixer/hrtfdefs.h b/alc/mixer/hrtfdefs.h
new file mode 100644
index 00000000..5f9711cf
--- /dev/null
+++ b/alc/mixer/hrtfdefs.h
@@ -0,0 +1,52 @@
+#ifndef MIXER_HRTFDEFS_H
+#define MIXER_HRTFDEFS_H
+
+#include <array>
+
+#include "core/ambidefs.h"
+#include "core/bufferline.h"
+#include "core/filters/splitter.h"
+
+
+#define HRTF_HISTORY_BITS 6
+#define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS)
+#define HRTF_HISTORY_MASK (HRTF_HISTORY_LENGTH-1)
+
+#define HRIR_BITS 7
+#define HRIR_LENGTH (1<<HRIR_BITS)
+#define HRIR_MASK (HRIR_LENGTH-1)
+
+#define MIN_IR_LENGTH 8
+
+#define HRTF_DIRECT_DELAY 192
+
+using float2 = std::array<float,2>;
+using HrirArray = std::array<float2,HRIR_LENGTH>;
+using ubyte = unsigned char;
+using ubyte2 = std::array<ubyte,2>;
+using ushort = unsigned short;
+using uint = unsigned int;
+
+
+struct MixHrtfFilter {
+ const HrirArray *Coeffs;
+ std::array<uint,2> Delay;
+ float Gain;
+ float GainStep;
+};
+
+struct HrtfFilter {
+ alignas(16) HrirArray Coeffs;
+ std::array<uint,2> Delay;
+ float Gain;
+};
+
+
+struct HrtfChannelState {
+ std::array<float,HRTF_DIRECT_DELAY> mDelay{};
+ BandSplitter mSplitter;
+ float mHfScale{};
+ alignas(16) HrirArray mCoeffs{};
+};
+
+#endif /* MIXER_HRTFDEFS_H */
diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp
index c2fdec66..e7e66947 100644
--- a/alc/mixer/mixer_c.cpp
+++ b/alc/mixer/mixer_c.cpp
@@ -1,7 +1,7 @@
#include "config.h"
#include <cassert>
-
+#include <cmath>
#include <limits>
#include "alcmain.h"
@@ -172,7 +172,7 @@ void Mix_<CTag>(const al::span<const float> InSamples, const al::span<FloatBuffe
const float step{(*TargetGains-gain) * delta};
size_t pos{0};
- if(!(std::fabs(step) > std::numeric_limits<float>::epsilon()))
+ if(!(std::abs(step) > std::numeric_limits<float>::epsilon()))
gain = *TargetGains;
else
{
@@ -191,7 +191,7 @@ void Mix_<CTag>(const al::span<const float> InSamples, const al::span<FloatBuffe
++CurrentGains;
++TargetGains;
- if(!(std::fabs(gain) > GainSilenceThreshold))
+ if(!(std::abs(gain) > GainSilenceThreshold))
continue;
for(;pos != InSamples.size();++pos)
dst[pos] += InSamples[pos] * gain;
diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp
index 0c3367a9..af8f6b0c 100644
--- a/alc/mixer/mixer_neon.cpp
+++ b/alc/mixer/mixer_neon.cpp
@@ -2,6 +2,7 @@
#include <arm_neon.h>
+#include <cmath>
#include <limits>
#include "alnumeric.h"
@@ -234,7 +235,7 @@ void Mix_<NEONTag>(const al::span<const float> InSamples, const al::span<FloatBu
const float step{(*TargetGains-gain) * delta};
size_t pos{0};
- if(!(std::fabs(step) > std::numeric_limits<float>::epsilon()))
+ if(!(std::abs(step) > std::numeric_limits<float>::epsilon()))
gain = *TargetGains;
else
{
@@ -283,7 +284,7 @@ void Mix_<NEONTag>(const al::span<const float> InSamples, const al::span<FloatBu
++CurrentGains;
++TargetGains;
- if(!(std::fabs(gain) > GainSilenceThreshold))
+ if(!(std::abs(gain) > GainSilenceThreshold))
continue;
if(size_t todo{(InSamples.size()-pos) >> 2})
{
diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp
index 6adbc7fb..85b2f1ce 100644
--- a/alc/mixer/mixer_sse.cpp
+++ b/alc/mixer/mixer_sse.cpp
@@ -2,6 +2,7 @@
#include <xmmintrin.h>
+#include <cmath>
#include <limits>
#include "alnumeric.h"
@@ -198,7 +199,7 @@ void Mix_<SSETag>(const al::span<const float> InSamples, const al::span<FloatBuf
const float step{(*TargetGains-gain) * delta};
size_t pos{0};
- if(!(std::fabs(step) > std::numeric_limits<float>::epsilon()))
+ if(!(std::abs(step) > std::numeric_limits<float>::epsilon()))
gain = *TargetGains;
else
{
@@ -246,7 +247,7 @@ void Mix_<SSETag>(const al::span<const float> InSamples, const al::span<FloatBuf
++CurrentGains;
++TargetGains;
- if(!(std::fabs(gain) > GainSilenceThreshold))
+ if(!(std::abs(gain) > GainSilenceThreshold))
continue;
if(size_t todo{(InSamples.size()-pos) >> 2})
{