aboutsummaryrefslogtreecommitdiffstats
path: root/alc/hrtf.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-05-19 10:27:52 -0700
committerChris Robinson <[email protected]>2020-05-19 10:27:52 -0700
commit825206bfa2b59ae124cc8fb34c5b668f8a682224 (patch)
treee0198b6590c7e22352c651e0352db2e8b374a9d9 /alc/hrtf.h
parenta512eae7bb3554723b7b290985404e7c480b9bf1 (diff)
Apply the ambisonic HF scaling in real-time with HRTF
Rather than applying the HF scale to the IRs necessitating them to be truncated along with increasing the IR size, it can be applied to the input signal for the same results. Consequently, the IR size can be notably shortened while avoiding the extra truncation. In its place, the delayed reversed all-pass technique can still be used on the input for maintaining phase when applying the bandsplit/hfscalar filter to the input signal.
Diffstat (limited to 'alc/hrtf.h')
-rw-r--r--alc/hrtf.h20
1 files changed, 17 insertions, 3 deletions
diff --git a/alc/hrtf.h b/alc/hrtf.h
index 5b709e30..7876265b 100644
--- a/alc/hrtf.h
+++ b/alc/hrtf.h
@@ -12,6 +12,8 @@
#include "alspan.h"
#include "ambidefs.h"
#include "atomic.h"
+#include "bufferline.h"
+#include "filters/splitter.h"
#include "intrusive_ptr.h"
#include "vector.h"
@@ -77,12 +79,24 @@ struct AngularPoint {
AzRadians Azim;
};
+#define HRTF_DIRECT_DELAY 128
struct DirectHrtfState {
+ struct ChannelData {
+ std::array<float,HRTF_DIRECT_DELAY> mDelay{};
+ BandSplitter mSplitter;
+ float mHfScale{};
+ alignas(16) HrirArray mCoeffs{};
+ };
+
+ std::array<float,HRTF_DIRECT_DELAY> mLeftDelay{};
+ std::array<float,HRTF_DIRECT_DELAY> mRightDelay{};
+ std::array<float,HRTF_DIRECT_DELAY+BUFFERSIZE> mTemp;
+
/* HRTF filter state for dry buffer content */
ALuint mIrSize{0};
- al::FlexArray<HrirArray,16> mCoeffs;
+ al::FlexArray<ChannelData> mChannels;
- DirectHrtfState(size_t numchans) : mCoeffs{numchans} { }
+ DirectHrtfState(size_t numchans) : mChannels{numchans} { }
/**
* Produces HRTF filter coefficients for decoding B-Format, given a set of
* virtual speaker positions, a matching decoding matrix, and per-order
@@ -95,7 +109,7 @@ struct DirectHrtfState {
static std::unique_ptr<DirectHrtfState> Create(size_t num_chans);
- DEF_FAM_NEWDEL(DirectHrtfState, mCoeffs)
+ DEF_FAM_NEWDEL(DirectHrtfState, mChannels)
};