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.

124 lines
3.2KB

  1. /*
  2. * ZamComp mono compressor
  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. START_NAMESPACE_DISTRHO
  21. // -----------------------------------------------------------------------
  22. class ZamCompPlugin : public Plugin
  23. {
  24. public:
  25. enum Parameters
  26. {
  27. paramAttack = 0,
  28. paramRelease,
  29. paramKnee,
  30. paramRatio,
  31. paramThresh,
  32. paramMakeup,
  33. paramGainR,
  34. paramOutputLevel,
  35. paramCount
  36. };
  37. ZamCompPlugin();
  38. ~ZamCompPlugin() override;
  39. protected:
  40. // -------------------------------------------------------------------
  41. // Information
  42. const char* d_getLabel() const noexcept override
  43. {
  44. return "ZamComp";
  45. }
  46. const char* d_getMaker() const noexcept override
  47. {
  48. return "Damien Zammit";
  49. }
  50. const char* d_getLicense() const noexcept override
  51. {
  52. return "GPL v2+";
  53. }
  54. uint32_t d_getVersion() const noexcept override
  55. {
  56. return 0x1000;
  57. }
  58. long d_getUniqueId() const noexcept override
  59. {
  60. return d_cconst('Z', 'C', 'M', 'P');
  61. }
  62. // -------------------------------------------------------------------
  63. // Init
  64. void d_initParameter(uint32_t index, Parameter& parameter) ;
  65. void d_initProgramName(uint32_t index, d_string& programName) ;
  66. // -------------------------------------------------------------------
  67. // Internal data
  68. float d_getParameterValue(uint32_t index) const override;
  69. void d_setParameterValue(uint32_t index, float value) override;
  70. void d_setProgram(uint32_t index) ;
  71. // -------------------------------------------------------------------
  72. // Process
  73. static inline float
  74. sanitize_denormal(float v) {
  75. if(!std::isnormal(v))
  76. return 0.f;
  77. return v;
  78. }
  79. static inline float
  80. from_dB(float gdb) {
  81. return (exp(gdb/20.f*log(10.f)));
  82. }
  83. static inline float
  84. to_dB(float g) {
  85. return (20.f*log10(g));
  86. }
  87. void d_activate() override;
  88. void d_deactivate() override;
  89. void d_run(float** inputs, float** outputs, uint32_t frames) override;
  90. // -------------------------------------------------------------------
  91. private:
  92. float attack,release,knee,ratio,thresdb,makeup,gainr,outlevel; //parameters
  93. float old_yl, old_y1;
  94. };
  95. // -----------------------------------------------------------------------
  96. END_NAMESPACE_DISTRHO
  97. #endif // ZAMCOMP_HPP_INCLUDED