aboutsummaryrefslogtreecommitdiffstats
path: root/core/mixer/hrtfdefs.h
blob: 89a9bb8df6f2213aaed183ded196e9922023515e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef CORE_MIXER_HRTFDEFS_H
#define CORE_MIXER_HRTFDEFS_H

#include <array>

#include "core/ambidefs.h"
#include "core/bufferline.h"
#include "core/filters/splitter.h"


using float2 = std::array<float,2>;
using ubyte = unsigned char;
using ubyte2 = std::array<ubyte,2>;
using ushort = unsigned short;
using uint = unsigned int;
using uint2 = std::array<uint,2>;

constexpr uint HrtfHistoryBits{6};
constexpr uint HrtfHistoryLength{1 << HrtfHistoryBits};
constexpr uint HrtfHistoryMask{HrtfHistoryLength - 1};

constexpr uint HrirBits{7};
constexpr uint HrirLength{1 << HrirBits};
constexpr uint HrirMask{HrirLength - 1};

constexpr uint MinIrLength{8};

constexpr uint HrtfDirectDelay{256};

using HrirArray = std::array<float2,HrirLength>;

struct MixHrtfFilter {
    const HrirArray *Coeffs;
    uint2 Delay;
    float Gain;
    float GainStep;
};

struct HrtfFilter {
    alignas(16) HrirArray Coeffs;
    uint2 Delay;
    float Gain;
};


struct HrtfChannelState {
    std::array<float,HrtfDirectDelay> mDelay{};
    BandSplitter mSplitter;
    float mHfScale{};
    alignas(16) HrirArray mCoeffs{};
};

#endif /* CORE_MIXER_HRTFDEFS_H */