External plugins for Carla
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.

75 lines
2.1KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. SV Filter.h - Several state-variable filters
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #ifndef SV_FILTER_H
  12. #define SV_FILTER_H
  13. #include "../globals.h"
  14. #include "Filter.h"
  15. namespace zyncarla {
  16. class SVFilter:public Filter
  17. {
  18. public:
  19. SVFilter(unsigned char Ftype,
  20. float Ffreq,
  21. float Fq,
  22. unsigned char Fstages,
  23. unsigned int srate, int bufsize);
  24. ~SVFilter();
  25. void filterout(float *smp);
  26. void setfreq(float frequency);
  27. void setfreq_and_q(float frequency, float q_);
  28. void setq(float q_);
  29. void settype(int type_);
  30. void setgain(float dBgain);
  31. void setstages(int stages_);
  32. void cleanup();
  33. struct response {
  34. response(float b0, float b1, float b2,
  35. float a0, float a1 ,float a2);
  36. float a[3];
  37. float b[3];
  38. };
  39. static response computeResponse(int type,
  40. float freq, float pq, int stages, float g, float fs);
  41. private:
  42. struct fstage {
  43. float low, high, band, notch;
  44. } st[MAX_FILTER_STAGES + 1];
  45. struct parameters {
  46. float f, q, q_sqrt;
  47. } par, ipar;
  48. void singlefilterout(float *smp, fstage &x, parameters &par);
  49. void computefiltercoefs(void);
  50. int type; // The type of the filter (LPF1,HPF1,LPF2,HPF2...)
  51. int stages; // how many times the filter is applied (0->1,1->2,etc.)
  52. float freq; // Frequency given in Hz
  53. float q; // Q factor (resonance or Q factor)
  54. float gain; // the gain of the filter (if are shelf/peak) filters
  55. bool abovenq, //if the frequency is above the nyquist
  56. oldabovenq;
  57. bool needsinterpolation, firsttime;
  58. };
  59. }
  60. #endif