🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.7 KiB

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