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.

133 lines
3.7KB

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