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.

141 lines
3.7KB

  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. ~ZamEQ2Plugin() override;
  44. protected:
  45. // -------------------------------------------------------------------
  46. // Information
  47. const char* d_getLabel() const noexcept override
  48. {
  49. return "ZamEQ2";
  50. }
  51. const char* d_getMaker() const noexcept override
  52. {
  53. return "Damien Zammit";
  54. }
  55. const char* d_getLicense() const noexcept override
  56. {
  57. return "GPL v2+";
  58. }
  59. uint32_t d_getVersion() const noexcept override
  60. {
  61. return 0x1000;
  62. }
  63. long d_getUniqueId() const noexcept override
  64. {
  65. return d_cconst('Z', 'E', 'Q', '2');
  66. }
  67. // -------------------------------------------------------------------
  68. // Init
  69. void d_initParameter(uint32_t index, Parameter& parameter) ;
  70. void d_initProgramName(uint32_t index, d_string& programName) ;
  71. // -------------------------------------------------------------------
  72. // Internal data
  73. float d_getParameterValue(uint32_t index) const override;
  74. void d_setParameterValue(uint32_t index, float value) override;
  75. void d_setProgram(uint32_t index) ;
  76. // -------------------------------------------------------------------
  77. // Process
  78. static inline double
  79. sanitize_denormal(double v) {
  80. if(!std::isnormal(v))
  81. return 0.f;
  82. return v;
  83. }
  84. static inline double
  85. from_dB(double gdb) {
  86. return (exp(gdb/20.f*log(10.f)));
  87. }
  88. static inline double
  89. to_dB(double g) {
  90. return (20.f*log10(g));
  91. }
  92. static inline int
  93. sign(double x) {
  94. return (x >= 0.f ? 1 : -1);
  95. }
  96. void d_activate() override;
  97. void d_deactivate() override;
  98. void d_run(float** inputs, float** outputs, uint32_t frames) override;
  99. void peq(int i, int ch, float srate, float fc, float g, float bw);
  100. void lowshelf(int i, int ch, float srate, float fc, float g);
  101. void highshelf(int i, int ch, float srate, float fc, float g);
  102. float run_filter(int i, int ch, double in);
  103. double x1[1][MAX_FILT], x2[1][MAX_FILT], y1[1][MAX_FILT], y2[1][MAX_FILT];
  104. double b0[1][MAX_FILT], b1[1][MAX_FILT], b2[1][MAX_FILT];
  105. double a1[1][MAX_FILT], a2[1][MAX_FILT];
  106. // -------------------------------------------------------------------
  107. private:
  108. float gain1,q1,freq1,gain2,q2,freq2,gainl,freql,gainh,freqh,master,togglepeaks; //parameters
  109. };
  110. // -----------------------------------------------------------------------
  111. END_NAMESPACE_DISTRHO
  112. #endif // ZAMCOMP_HPP_INCLUDED