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.

234 lines
7.5KB

  1. /*
  2. * DISTRHO 3BandEQ Plugin, based on 3BandEQ by Michael Gruhn
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * For a full copy of the license see the doc/LGPL.txt file.
  15. */
  16. #include "DistrhoUI3BandEQ.hpp"
  17. START_NAMESPACE_DISTRHO
  18. // -----------------------------------------------------------------------
  19. DistrhoUI3BandEQ::DistrhoUI3BandEQ()
  20. : OpenGLUI(),
  21. fAboutWindow(this)
  22. {
  23. // background
  24. fImgBackground = Image(DistrhoArtwork3BandEQ::backgroundData, DistrhoArtwork3BandEQ::backgroundWidth, DistrhoArtwork3BandEQ::backgroundHeight, GL_BGR);
  25. // about
  26. Image imageAbout(DistrhoArtwork3BandEQ::aboutData, DistrhoArtwork3BandEQ::aboutWidth, DistrhoArtwork3BandEQ::aboutHeight, GL_BGR);
  27. fAboutWindow.setImage(imageAbout);
  28. // sliders
  29. Image sliderImage(DistrhoArtwork3BandEQ::sliderData, DistrhoArtwork3BandEQ::sliderWidth, DistrhoArtwork3BandEQ::sliderHeight);
  30. Point<int> sliderPosStart(57, 43);
  31. Point<int> sliderPosEnd(57, 43 + 160);
  32. // slider Low
  33. fSliderLow = new ImageSlider(this, sliderImage);
  34. fSliderLow->setStartPos(sliderPosStart);
  35. fSliderLow->setEndPos(sliderPosEnd);
  36. fSliderLow->setRange(-24.0f, 24.0f);
  37. fSliderLow->setValue(0.0f);
  38. fSliderLow->setCallback(this);
  39. // slider Mid
  40. sliderPosStart.setX(120);
  41. sliderPosEnd.setX(120);
  42. fSliderMid = new ImageSlider(*fSliderLow);
  43. fSliderMid->setStartPos(sliderPosStart);
  44. fSliderMid->setEndPos(sliderPosEnd);
  45. // slider High
  46. sliderPosStart.setX(183);
  47. sliderPosEnd.setX(183);
  48. fSliderHigh = new ImageSlider(*fSliderLow);
  49. fSliderHigh->setStartPos(sliderPosStart);
  50. fSliderHigh->setEndPos(sliderPosEnd);
  51. // slider Master
  52. sliderPosStart.setX(287);
  53. sliderPosEnd.setX(287);
  54. fSliderMaster = new ImageSlider(*fSliderLow);
  55. fSliderMaster->setStartPos(sliderPosStart);
  56. fSliderMaster->setEndPos(sliderPosEnd);
  57. // knobs
  58. Image knobImage(DistrhoArtwork3BandEQ::knobData, DistrhoArtwork3BandEQ::knobWidth, DistrhoArtwork3BandEQ::knobHeight);
  59. // knob Low-Mid
  60. fKnobLowMid = new ImageKnob(this, knobImage);
  61. fKnobLowMid->setPos(65, 269);
  62. fKnobLowMid->setRange(0.0f, 1000.0f);
  63. fKnobLowMid->setValue(220.0f);
  64. fKnobLowMid->setRotationAngle(270);
  65. fKnobLowMid->setCallback(this);
  66. // knob Mid-High
  67. fKnobMidHigh = new ImageKnob(this, knobImage);
  68. fKnobMidHigh->setPos(159, 269);
  69. fKnobMidHigh->setRange(1000.0f, 20000.0f);
  70. fKnobMidHigh->setValue(2000.0f);
  71. fKnobMidHigh->setRotationAngle(270);
  72. fKnobMidHigh->setCallback(this);
  73. // about button
  74. Image aboutImageNormal(DistrhoArtwork3BandEQ::aboutButtonNormalData, DistrhoArtwork3BandEQ::aboutButtonNormalWidth, DistrhoArtwork3BandEQ::aboutButtonNormalHeight);
  75. Image aboutImageHover(DistrhoArtwork3BandEQ::aboutButtonHoverData, DistrhoArtwork3BandEQ::aboutButtonHoverWidth, DistrhoArtwork3BandEQ::aboutButtonHoverHeight);
  76. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  77. fButtonAbout->setPos(264, 300);
  78. fButtonAbout->setCallback(this);
  79. }
  80. DistrhoUI3BandEQ::~DistrhoUI3BandEQ()
  81. {
  82. delete fSliderLow;
  83. delete fSliderMid;
  84. delete fSliderHigh;
  85. delete fSliderMaster;
  86. delete fKnobLowMid;
  87. delete fKnobMidHigh;
  88. delete fButtonAbout;
  89. }
  90. // -----------------------------------------------------------------------
  91. // DSP Callbacks
  92. void DistrhoUI3BandEQ::d_parameterChanged(uint32_t index, float value)
  93. {
  94. switch (index)
  95. {
  96. case DistrhoPlugin3BandEQ::paramLow:
  97. fSliderLow->setValue(value);
  98. break;
  99. case DistrhoPlugin3BandEQ::paramMid:
  100. fSliderMid->setValue(value);
  101. break;
  102. case DistrhoPlugin3BandEQ::paramHigh:
  103. fSliderHigh->setValue(value);
  104. break;
  105. case DistrhoPlugin3BandEQ::paramMaster:
  106. fSliderMaster->setValue(value);
  107. break;
  108. case DistrhoPlugin3BandEQ::paramLowMidFreq:
  109. fKnobLowMid->setValue(value);
  110. break;
  111. case DistrhoPlugin3BandEQ::paramMidHighFreq:
  112. fKnobMidHigh->setValue(value);
  113. break;
  114. }
  115. }
  116. void DistrhoUI3BandEQ::d_programChanged(uint32_t index)
  117. {
  118. if (index != 0)
  119. return;
  120. // Default values
  121. fSliderLow->setValue(0.0f);
  122. fSliderMid->setValue(0.0f);
  123. fSliderHigh->setValue(0.0f);
  124. fSliderMaster->setValue(0.0f);
  125. fKnobLowMid->setValue(220.0f);
  126. fKnobMidHigh->setValue(2000.0f);
  127. }
  128. // -----------------------------------------------------------------------
  129. // Widget Callbacks
  130. void DistrhoUI3BandEQ::imageButtonClicked(ImageButton* button, int)
  131. {
  132. if (button != fButtonAbout)
  133. return;
  134. fAboutWindow.exec();
  135. }
  136. void DistrhoUI3BandEQ::imageKnobDragStarted(ImageKnob* knob)
  137. {
  138. if (knob == fKnobLowMid)
  139. d_editParameter(DistrhoPlugin3BandEQ::paramLowMidFreq, true);
  140. else if (knob == fKnobMidHigh)
  141. d_editParameter(DistrhoPlugin3BandEQ::paramMidHighFreq, true);
  142. }
  143. void DistrhoUI3BandEQ::imageKnobDragFinished(ImageKnob* knob)
  144. {
  145. if (knob == fKnobLowMid)
  146. d_editParameter(DistrhoPlugin3BandEQ::paramLowMidFreq, false);
  147. else if (knob == fKnobMidHigh)
  148. d_editParameter(DistrhoPlugin3BandEQ::paramMidHighFreq, false);
  149. }
  150. void DistrhoUI3BandEQ::imageKnobValueChanged(ImageKnob* knob, float value)
  151. {
  152. if (knob == fKnobLowMid)
  153. d_setParameterValue(DistrhoPlugin3BandEQ::paramLowMidFreq, value);
  154. else if (knob == fKnobMidHigh)
  155. d_setParameterValue(DistrhoPlugin3BandEQ::paramMidHighFreq, value);
  156. }
  157. void DistrhoUI3BandEQ::imageSliderDragStarted(ImageSlider* slider)
  158. {
  159. if (slider == fSliderLow)
  160. d_editParameter(DistrhoPlugin3BandEQ::paramLow, true);
  161. else if (slider == fSliderMid)
  162. d_editParameter(DistrhoPlugin3BandEQ::paramMid, true);
  163. else if (slider == fSliderHigh)
  164. d_editParameter(DistrhoPlugin3BandEQ::paramHigh, true);
  165. else if (slider == fSliderMaster)
  166. d_editParameter(DistrhoPlugin3BandEQ::paramMaster, true);
  167. }
  168. void DistrhoUI3BandEQ::imageSliderDragFinished(ImageSlider* slider)
  169. {
  170. if (slider == fSliderLow)
  171. d_editParameter(DistrhoPlugin3BandEQ::paramLow, false);
  172. else if (slider == fSliderMid)
  173. d_editParameter(DistrhoPlugin3BandEQ::paramMid, false);
  174. else if (slider == fSliderHigh)
  175. d_editParameter(DistrhoPlugin3BandEQ::paramHigh, false);
  176. else if (slider == fSliderMaster)
  177. d_editParameter(DistrhoPlugin3BandEQ::paramMaster, false);
  178. }
  179. void DistrhoUI3BandEQ::imageSliderValueChanged(ImageSlider* slider, float value)
  180. {
  181. if (slider == fSliderLow)
  182. d_setParameterValue(DistrhoPlugin3BandEQ::paramLow, value);
  183. else if (slider == fSliderMid)
  184. d_setParameterValue(DistrhoPlugin3BandEQ::paramMid, value);
  185. else if (slider == fSliderHigh)
  186. d_setParameterValue(DistrhoPlugin3BandEQ::paramHigh, value);
  187. else if (slider == fSliderMaster)
  188. d_setParameterValue(DistrhoPlugin3BandEQ::paramMaster, value);
  189. }
  190. void DistrhoUI3BandEQ::onDisplay()
  191. {
  192. fImgBackground.draw();
  193. }
  194. // -----------------------------------------------------------------------
  195. UI* createUI()
  196. {
  197. return new DistrhoUI3BandEQ();
  198. }
  199. // -----------------------------------------------------------------------
  200. END_NAMESPACE_DISTRHO