Move some HRTF definitions to a separate header
This commit is contained in:
@@ -701,6 +701,7 @@ set(ALC_OBJS
|
||||
alc/voice.h
|
||||
alc/mixer/defs.h
|
||||
alc/mixer/hrtfbase.h
|
||||
alc/mixer/hrtfdefs.h
|
||||
alc/mixer/mixer_c.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -29,8 +29,6 @@ extern MixerFunc MixSamples;
|
||||
|
||||
constexpr float GainMixMax{1000.0f}; /* +60dB */
|
||||
|
||||
constexpr float GainSilenceThreshold{0.00001f}; /* -100dB */
|
||||
|
||||
constexpr float SpeedOfSoundMetersPerSec{343.3f};
|
||||
constexpr float AirAbsorbGainHF{0.99426f}; /* -0.05dB */
|
||||
|
||||
|
||||
+2
-31
@@ -13,26 +13,10 @@
|
||||
#include "core/bufferline.h"
|
||||
#include "core/filters/splitter.h"
|
||||
#include "intrusive_ptr.h"
|
||||
#include "mixer/hrtfdefs.h"
|
||||
#include "vector.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
|
||||
|
||||
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 HrtfStore {
|
||||
RefCount mRef;
|
||||
|
||||
@@ -65,13 +49,6 @@ struct HrtfStore {
|
||||
using HrtfStorePtr = al::intrusive_ptr<HrtfStore>;
|
||||
|
||||
|
||||
struct HrtfFilter {
|
||||
alignas(16) HrirArray Coeffs;
|
||||
std::array<uint,2> Delay;
|
||||
float Gain;
|
||||
};
|
||||
|
||||
|
||||
struct EvRadians { float value; };
|
||||
struct AzRadians { float value; };
|
||||
struct AngularPoint {
|
||||
@@ -79,13 +56,7 @@ struct AngularPoint {
|
||||
AzRadians Azim;
|
||||
};
|
||||
|
||||
#define HRTF_DIRECT_DELAY 192
|
||||
struct HrtfChannelState {
|
||||
std::array<float,HRTF_DIRECT_DELAY> mDelay{};
|
||||
BandSplitter mSplitter;
|
||||
float mHfScale{};
|
||||
alignas(16) HrirArray mCoeffs{};
|
||||
};
|
||||
|
||||
struct DirectHrtfState {
|
||||
std::array<float,HRTF_DIRECT_DELAY+BufferLineSize> mTemp;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
@@ -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;
|
||||
|
||||
@@ -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})
|
||||
{
|
||||
|
||||
@@ -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})
|
||||
{
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "inprogext.h"
|
||||
#include "logging.h"
|
||||
#include "mixer/defs.h"
|
||||
#include "mixer/hrtfdefs.h"
|
||||
#include "opthelpers.h"
|
||||
#include "ringbuffer.h"
|
||||
#include "threads.h"
|
||||
|
||||
@@ -42,14 +42,6 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
struct MixHrtfFilter {
|
||||
const HrirArray *Coeffs;
|
||||
std::array<uint,2> Delay;
|
||||
float Gain;
|
||||
float GainStep;
|
||||
};
|
||||
|
||||
|
||||
struct DirectParams {
|
||||
BiquadFilter LowPass;
|
||||
BiquadFilter HighPass;
|
||||
|
||||
Reference in New Issue
Block a user