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.

147 lines
3.9KB

  1. /*
  2. * ZaMultiCompX2 stereo multiband 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 ZAMULTICOMPUI_HPP_INCLUDED
  18. #define ZAMULTICOMPUI_HPP_INCLUDED
  19. #include "DistrhoUI.hpp"
  20. #include "Geometry.hpp"
  21. #include "ImageKnob.hpp"
  22. #include "ImageToggle.hpp"
  23. #define COMPOINTS 1000
  24. #define MAX_COMP 3
  25. #include "ZaMultiCompX2Artwork.hpp"
  26. #include "ZaMultiCompX2Plugin.hpp"
  27. using DGL::Image;
  28. using DGL::ImageKnob;
  29. using DGL::ImageToggle;
  30. START_NAMESPACE_DISTRHO
  31. // -----------------------------------------------------------------------
  32. class ZaMultiCompX2UI : public UI,
  33. public ImageKnob::Callback,
  34. public ImageToggle::Callback
  35. {
  36. public:
  37. ZaMultiCompX2UI();
  38. ~ZaMultiCompX2UI() override;
  39. protected:
  40. // -------------------------------------------------------------------
  41. // Information
  42. unsigned int d_getWidth() const noexcept override
  43. {
  44. return ZaMultiCompX2Artwork::zamulticompx2Width;
  45. }
  46. unsigned int d_getHeight() const noexcept override
  47. {
  48. return ZaMultiCompX2Artwork::zamulticompx2Height;
  49. }
  50. void compcurve(float in, int k, float* x, float* y);
  51. void calc_compcurves(void);
  52. // -------------------------------------------------------------------
  53. // DSP Callbacks
  54. void d_parameterChanged(uint32_t index, float value) override;
  55. void d_programChanged(uint32_t index) override;
  56. void d_stateChanged(const char*, const char*) override;
  57. // -------------------------------------------------------------------
  58. // Widget Callbacks
  59. void imageKnobDragStarted(ImageKnob* knob) override;
  60. void imageKnobDragFinished(ImageKnob* knob) override;
  61. void imageKnobValueChanged(ImageKnob* knob, float value) override;
  62. void imageToggleClicked(ImageToggle* toggle, int button) override;
  63. void onDisplay() override;
  64. inline double
  65. to_dB(double g) {
  66. return (20.*log10(g));
  67. }
  68. inline double
  69. from_dB(double gdb) {
  70. return (exp(gdb/20.*log(10.)));
  71. }
  72. inline double
  73. sanitize_denormal(double value) {
  74. if (!std::isnormal(value)) {
  75. return (0.);
  76. }
  77. return value;
  78. }
  79. private:
  80. Image fImgBackground;
  81. ImageKnob* fKnobAttack;
  82. ImageKnob* fKnobRelease;
  83. ImageKnob* fKnobThresh1;
  84. ImageKnob* fKnobThresh2;
  85. ImageKnob* fKnobThresh3;
  86. ImageKnob* fKnobRatio;
  87. ImageKnob* fKnobKnee;
  88. ImageKnob* fKnobGlobalGain;
  89. ImageKnob* fKnobMakeup1;
  90. ImageKnob* fKnobMakeup2;
  91. ImageKnob* fKnobMakeup3;
  92. ImageKnob* fKnobXover1;
  93. ImageKnob* fKnobXover2;
  94. ImageToggle* fToggleBypass1;
  95. ImageToggle* fToggleBypass2;
  96. ImageToggle* fToggleBypass3;
  97. ImageToggle* fToggleListen1;
  98. ImageToggle* fToggleListen2;
  99. ImageToggle* fToggleListen3;
  100. ImageToggle* fToggleStereo;
  101. Image fLedRedImg;
  102. float fLedRedValue1;
  103. float fLedRedValue2;
  104. float fLedRedValue3;
  105. Image fLedYellowImg;
  106. float fLedYellowValueL;
  107. float fLedYellowValueR;
  108. DGL::Rectangle<int> fCanvasArea;
  109. float fThresh[MAX_COMP];
  110. float fRatio;
  111. float fKnee;
  112. float fMakeup[MAX_COMP];
  113. float fBypass[MAX_COMP];
  114. float fMaster;
  115. float compx[MAX_COMP][COMPOINTS];
  116. float compy[MAX_COMP][COMPOINTS];
  117. };
  118. // -----------------------------------------------------------------------
  119. END_NAMESPACE_DISTRHO
  120. #endif // ZAMULTICOMPUI_HPP_INCLUDED