Free Electron
nfc.h
1 #ifndef FILTER_NFC_H
2 #define FILTER_NFC_H
3 
4 struct NfcFilter1 {
5  float base_gain, gain;
6  float b1, a1;
7  float z[1];
8 };
9 struct NfcFilter2 {
10  float base_gain, gain;
11  float b1, b2, a1, a2;
12  float z[2];
13 };
14 struct NfcFilter3 {
15  float base_gain, gain;
16  float b1, b2, b3, a1, a2, a3;
17  float z[3];
18 };
19 
20 typedef struct NfcFilter {
21  struct NfcFilter1 first;
22  struct NfcFilter2 second;
23  struct NfcFilter3 third;
24 } NfcFilter;
25 
26 
27 /* NOTE:
28  * w0 = speed_of_sound / (source_distance * sample_rate);
29  * w1 = speed_of_sound / (control_distance * sample_rate);
30  *
31  * Generally speaking, the control distance should be approximately the average
32  * speaker distance, or based on the reference delay if outputing NFC-HOA. It
33  * must not be negative, 0, or infinite. The source distance should not be too
34  * small relative to the control distance.
35  */
36 
37 void NfcFilterCreate(NfcFilter *nfc, const float w0, const float w1);
38 void NfcFilterAdjust(NfcFilter *nfc, const float w0);
39 
40 /* Near-field control filter for first-order ambisonic channels (1-3). */
41 void NfcFilterProcess1(NfcFilter *nfc, float *restrict dst, const float *restrict src, const int count);
42 
43 /* Near-field control filter for second-order ambisonic channels (4-8). */
44 void NfcFilterProcess2(NfcFilter *nfc, float *restrict dst, const float *restrict src, const int count);
45 
46 /* Near-field control filter for third-order ambisonic channels (9-15). */
47 void NfcFilterProcess3(NfcFilter *nfc, float *restrict dst, const float *restrict src, const int count);
48 
49 #endif /* FILTER_NFC_H */