Biquad.h 802 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. class Biquad
  3. {
  4. public:
  5. Biquad();
  6. void copy_filter(const Biquad &other);
  7. void SetSampleRate(double fs);
  8. void set_freq(double f0);
  9. void set_s_eq(const double b[3], const double a[3]);
  10. void transform_s_to_z();
  11. void process_block(float *dest_ptr, const float *src_ptr, long nbr_spl);
  12. void clear_buffers();
  13. private:
  14. double _s_eq_b[3]; // Coefs for numerator (zeros)
  15. double _s_eq_a[3]; // Coefs for denominator (poles)
  16. double _z_eq_b[3]; // Direct coefficients, order z^(-n)
  17. double _z_eq_a[3]; // Recursive coefficients, order z^(-n)
  18. double sampleRate; // Hz, > 0
  19. double _f0; // Hz, > 0, _f0 % (_sample_freq/2) != 0
  20. double xn[2]; // Input memory, order z^(-n)
  21. double yn[2]; // Output memory, order z^(-n)
  22. int _mem_pos; // 0 or 1
  23. inline double process_sample(double x);
  24. };