Limit convolution processing to the output ambisonic order
[openal-soft.git] / alc / filters / nfc.h
blob2327c9664b0089061ddd5986d5a071f90b4c0174
1 #ifndef FILTER_NFC_H
2 #define FILTER_NFC_H
4 #include <cstddef>
6 #include "alspan.h"
9 struct NfcFilter1 {
10 float base_gain, gain;
11 float b1, a1;
12 float z[1];
14 struct NfcFilter2 {
15 float base_gain, gain;
16 float b1, b2, a1, a2;
17 float z[2];
19 struct NfcFilter3 {
20 float base_gain, gain;
21 float b1, b2, b3, a1, a2, a3;
22 float z[3];
24 struct NfcFilter4 {
25 float base_gain, gain;
26 float b1, b2, b3, b4, a1, a2, a3, a4;
27 float z[4];
30 class NfcFilter {
31 NfcFilter1 first;
32 NfcFilter2 second;
33 NfcFilter3 third;
34 NfcFilter4 fourth;
36 public:
37 /* NOTE:
38 * w0 = speed_of_sound / (source_distance * sample_rate);
39 * w1 = speed_of_sound / (control_distance * sample_rate);
41 * Generally speaking, the control distance should be approximately the
42 * average speaker distance, or based on the reference delay if outputing
43 * NFC-HOA. It must not be negative, 0, or infinite. The source distance
44 * should not be too small relative to the control distance.
47 void init(const float w1) noexcept;
48 void adjust(const float w0) noexcept;
50 /* Near-field control filter for first-order ambisonic channels (1-3). */
51 void process1(const al::span<const float> src, float *RESTRICT dst);
53 /* Near-field control filter for second-order ambisonic channels (4-8). */
54 void process2(const al::span<const float> src, float *RESTRICT dst);
56 /* Near-field control filter for third-order ambisonic channels (9-15). */
57 void process3(const al::span<const float> src, float *RESTRICT dst);
59 /* Near-field control filter for fourth-order ambisonic channels (16-24). */
60 void process4(const al::span<const float> src, float *RESTRICT dst);
63 #endif /* FILTER_NFC_H */