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.

127 lines
3.2KB

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