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.

122 lines
3.1KB

  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. protected:
  39. // -------------------------------------------------------------------
  40. // Information
  41. const char* d_getLabel() const noexcept override
  42. {
  43. return "ZamComp";
  44. }
  45. const char* d_getMaker() const noexcept override
  46. {
  47. return "Damien Zammit";
  48. }
  49. const char* d_getLicense() const noexcept override
  50. {
  51. return "GPL v2+";
  52. }
  53. uint32_t d_getVersion() const noexcept override
  54. {
  55. return 0x1000;
  56. }
  57. long d_getUniqueId() const noexcept override
  58. {
  59. return d_cconst('Z', 'C', 'M', 'P');
  60. }
  61. // -------------------------------------------------------------------
  62. // Init
  63. void d_initParameter(uint32_t index, Parameter& parameter) override;
  64. void d_initProgramName(uint32_t index, d_string& programName) override;
  65. // -------------------------------------------------------------------
  66. // Internal data
  67. float d_getParameterValue(uint32_t index) const override;
  68. void d_setParameterValue(uint32_t index, float value) override;
  69. void d_setProgram(uint32_t index) override;
  70. // -------------------------------------------------------------------
  71. // Process
  72. static inline float
  73. sanitize_denormal(float v) {
  74. if(!std::isnormal(v))
  75. return 0.f;
  76. return v;
  77. }
  78. static inline float
  79. from_dB(float gdb) {
  80. return (exp(gdb/20.f*log(10.f)));
  81. }
  82. static inline float
  83. to_dB(float g) {
  84. return (20.f*log10(g));
  85. }
  86. void d_activate() override;
  87. void d_run(const float** inputs, float** outputs, uint32_t frames) override;
  88. // -------------------------------------------------------------------
  89. private:
  90. float attack,release,knee,ratio,thresdb,makeup,gainr,outlevel; //parameters
  91. float old_yl, old_y1;
  92. };
  93. // -----------------------------------------------------------------------
  94. END_NAMESPACE_DISTRHO
  95. #endif // ZAMCOMP_HPP_INCLUDED