Resonator.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef _Resonator_h_
  2. #define _Resonator_h_
  3. /* Resonator.h
  4. *
  5. * Copyright (C) 2008-2011, 2015 David Weenink
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. * See the GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /*
  21. * djmw 20081029
  22. * djmw 20110306 Latest modification
  23. */
  24. #include "Sound.h"
  25. Thing_define (Filter, Daata) {
  26. double dT;
  27. double a, b, c;
  28. double p1, p2;
  29. virtual double v_getOutput (double input);
  30. virtual void v_setFB (double f, double b);
  31. virtual void v_resetMemory ();
  32. };
  33. Thing_define (Resonator, Filter) {
  34. int normalisation;
  35. void v_setFB (double f, double b)
  36. override;
  37. };
  38. Thing_define (AntiResonator, Resonator) {
  39. double v_getOutput (double input)
  40. override;
  41. void v_setFB (double f, double b)
  42. override;
  43. };
  44. Thing_define (ConstantGainResonator, Filter) {
  45. double d;
  46. double p3, p4;
  47. double v_getOutput (double input)
  48. override;
  49. void v_setFB (double f, double b)
  50. override;
  51. void v_resetMemory ()
  52. override;
  53. };
  54. #define Resonator_NORMALISATION_H0 0
  55. #define Resonator_NORMALISATION_HMAX 1
  56. autoResonator Resonator_create (double dT, int normalisation);
  57. autoConstantGainResonator ConstantGainResonator_create (double dT);
  58. autoAntiResonator AntiResonator_create (double dT);
  59. /*
  60. Set a,b,c
  61. normalisation == 0: H(0) = 1 -> a = 1 -b - c
  62. normalisation == 1: H(Fmax) = 1 -> a = (1 + c)sin(2*pi*F*T)
  63. */
  64. void Filter_setFB (Filter me, double f, double b);
  65. double Filter_getOutput (Filter me, double input);
  66. void Filter_resetMemory (Filter me);
  67. #endif /* _Resonator_h_ */