Avoid static constexpr for arrays iterated over at run-time
[openal-soft.git] / alc / filters / nfc.h
blobd2bf333967db51c7ebb2e3e909fd227dfbc93a15
1 #ifndef FILTER_NFC_H
2 #define FILTER_NFC_H
4 #include <cstddef>
7 struct NfcFilter1 {
8 float base_gain, gain;
9 float b1, a1;
10 float z[1];
12 struct NfcFilter2 {
13 float base_gain, gain;
14 float b1, b2, a1, a2;
15 float z[2];
17 struct NfcFilter3 {
18 float base_gain, gain;
19 float b1, b2, b3, a1, a2, a3;
20 float z[3];
22 struct NfcFilter4 {
23 float base_gain, gain;
24 float b1, b2, b3, b4, a1, a2, a3, a4;
25 float z[4];
28 class NfcFilter {
29 NfcFilter1 first;
30 NfcFilter2 second;
31 NfcFilter3 third;
32 NfcFilter4 fourth;
34 public:
35 /* NOTE:
36 * w0 = speed_of_sound / (source_distance * sample_rate);
37 * w1 = speed_of_sound / (control_distance * sample_rate);
39 * Generally speaking, the control distance should be approximately the
40 * average speaker distance, or based on the reference delay if outputing
41 * NFC-HOA. It must not be negative, 0, or infinite. The source distance
42 * should not be too small relative to the control distance.
45 void init(const float w1) noexcept;
46 void adjust(const float w0) noexcept;
48 /* Near-field control filter for first-order ambisonic channels (1-3). */
49 void process1(float *RESTRICT dst, const float *RESTRICT src, const size_t count);
51 /* Near-field control filter for second-order ambisonic channels (4-8). */
52 void process2(float *RESTRICT dst, const float *RESTRICT src, const size_t count);
54 /* Near-field control filter for third-order ambisonic channels (9-15). */
55 void process3(float *RESTRICT dst, const float *RESTRICT src, const size_t count);
57 /* Near-field control filter for fourth-order ambisonic channels (16-24). */
58 void process4(float *RESTRICT dst, const float *RESTRICT src, const size_t count);
61 #endif /* FILTER_NFC_H */