Audio plugin host https://kx.studio/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.

ZamEQ2Plugin.hpp 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * ZamEQ2 2 band parametric equaliser
  3. * Copyright (C) 2014 Damien Zammit <damien@zamaudio.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef ZAMCOMPPLUGIN_HPP_INCLUDED
  18. #define ZAMCOMPPLUGIN_HPP_INCLUDED
  19. #include "DistrhoPlugin.hpp"
  20. #define MAX_FILT 4
  21. START_NAMESPACE_DISTRHO
  22. // -----------------------------------------------------------------------
  23. class ZamEQ2Plugin : public Plugin
  24. {
  25. public:
  26. enum Parameters
  27. {
  28. paramGain1 = 0,
  29. paramQ1,
  30. paramFreq1,
  31. paramGain2,
  32. paramQ2,
  33. paramFreq2,
  34. paramGainL,
  35. paramFreqL,
  36. paramGainH,
  37. paramFreqH,
  38. paramMaster,
  39. paramTogglePeaks,
  40. paramCount
  41. };
  42. ZamEQ2Plugin();
  43. protected:
  44. // -------------------------------------------------------------------
  45. // Information
  46. const char* d_getLabel() const noexcept override
  47. {
  48. return "ZamEQ2";
  49. }
  50. const char* d_getMaker() const noexcept override
  51. {
  52. return "Damien Zammit";
  53. }
  54. const char* d_getLicense() const noexcept override
  55. {
  56. return "GPL v2+";
  57. }
  58. uint32_t d_getVersion() const noexcept override
  59. {
  60. return 0x1000;
  61. }
  62. long d_getUniqueId() const noexcept override
  63. {
  64. return d_cconst('Z', 'E', 'Q', '2');
  65. }
  66. // -------------------------------------------------------------------
  67. // Init
  68. void d_initParameter(uint32_t index, Parameter& parameter) ;
  69. void d_initProgramName(uint32_t index, d_string& programName) ;
  70. // -------------------------------------------------------------------
  71. // Internal data
  72. float d_getParameterValue(uint32_t index) const override;
  73. void d_setParameterValue(uint32_t index, float value) override;
  74. void d_setProgram(uint32_t index) ;
  75. // -------------------------------------------------------------------
  76. // Process
  77. static inline double
  78. sanitize_denormal(double v) {
  79. if(!std::isnormal(v))
  80. return 0.f;
  81. return v;
  82. }
  83. static inline double
  84. from_dB(double gdb) {
  85. return (exp(gdb/20.f*log(10.f)));
  86. }
  87. static inline double
  88. to_dB(double g) {
  89. return (20.f*log10(g));
  90. }
  91. static inline int
  92. sign(double x) {
  93. return (x >= 0.f ? 1 : -1);
  94. }
  95. void d_activate() override;
  96. void d_run(const float** inputs, float** outputs, uint32_t frames) override;
  97. void peq(int i, int ch, float srate, float fc, float g, float bw);
  98. void lowshelf(int i, int ch, float srate, float fc, float g);
  99. void highshelf(int i, int ch, float srate, float fc, float g);
  100. float run_filter(int i, int ch, double in);
  101. double x1[1][MAX_FILT], x2[1][MAX_FILT], y1[1][MAX_FILT], y2[1][MAX_FILT];
  102. double b0[1][MAX_FILT], b1[1][MAX_FILT], b2[1][MAX_FILT];
  103. double a1[1][MAX_FILT], a2[1][MAX_FILT];
  104. // -------------------------------------------------------------------
  105. private:
  106. float gain1,q1,freq1,gain2,q2,freq2,gainl,freql,gainh,freqh,master,togglepeaks; //parameters
  107. };
  108. // -----------------------------------------------------------------------
  109. END_NAMESPACE_DISTRHO
  110. #endif // ZAMCOMP_HPP_INCLUDED