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.

DistrhoUI3BandEQ.cpp 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 LGPL.txt file
  15. */
  16. #include "DistrhoUI3BandEQ.hpp"
  17. #include "dgl/ImageAboutWindow.hpp"
  18. START_NAMESPACE_DISTRHO
  19. // -------------------------------------------------
  20. DistrhoUI3BandEQ::DistrhoUI3BandEQ()
  21. : OpenGLUI()
  22. {
  23. Window* win = getParent();
  24. // background
  25. fImgBackground = Image(DistrhoArtwork3BandEQ::backgroundData, DistrhoArtwork3BandEQ::backgroundWidth, DistrhoArtwork3BandEQ::backgroundHeight, GL_BGR);
  26. // sliders
  27. Image sliderImage(DistrhoArtwork3BandEQ::sliderData, DistrhoArtwork3BandEQ::sliderWidth, DistrhoArtwork3BandEQ::sliderHeight);
  28. Point<int> sliderPosStart(57, 43);
  29. Point<int> sliderPosEnd(57, 43 + 160);
  30. // slider Low
  31. fSliderLow = new ImageSlider(win, sliderImage);
  32. fSliderLow->setStartPos(sliderPosStart);
  33. fSliderLow->setEndPos(sliderPosEnd);
  34. fSliderLow->setRange(-24.0f, 24.0f);
  35. fSliderLow->setValue(0.0f);
  36. fSliderLow->setCallback(this);
  37. // slider Mid
  38. sliderPosStart.setX(120);
  39. sliderPosEnd.setX(120);
  40. fSliderMid = new ImageSlider(*fSliderLow);
  41. fSliderMid->setStartPos(sliderPosStart);
  42. fSliderMid->setEndPos(sliderPosEnd);
  43. // slider High
  44. sliderPosStart.setX(183);
  45. sliderPosEnd.setX(183);
  46. fSliderHigh = new ImageSlider(*fSliderLow);
  47. fSliderHigh->setStartPos(sliderPosStart);
  48. fSliderHigh->setEndPos(sliderPosEnd);
  49. // slider Master
  50. sliderPosStart.setX(287);
  51. sliderPosEnd.setX(287);
  52. fSliderMaster = new ImageSlider(*fSliderLow);
  53. fSliderMaster->setStartPos(sliderPosStart);
  54. fSliderMaster->setEndPos(sliderPosEnd);
  55. // knobs
  56. Image knobImage(DistrhoArtwork3BandEQ::knobData, DistrhoArtwork3BandEQ::knobWidth, DistrhoArtwork3BandEQ::knobHeight);
  57. // knob Low-Mid
  58. fKnobLowMid = new ImageKnob(win, knobImage);
  59. fKnobLowMid->setPos(66, 270);
  60. fKnobLowMid->setRange(0.0f, 1000.0f);
  61. fKnobLowMid->setValue(220.0f);
  62. fKnobLowMid->setCallback(this);
  63. // knob Mid-High
  64. fKnobMidHigh = new ImageKnob(win, knobImage);
  65. fKnobMidHigh->setPos(160, 270);
  66. fKnobMidHigh->setRange(1000.0f, 20000.0f);
  67. fKnobMidHigh->setValue(2000.0f);
  68. fKnobMidHigh->setCallback(this);
  69. // about button
  70. Image aboutImageNormal(DistrhoArtwork3BandEQ::aboutButtonNormalData, DistrhoArtwork3BandEQ::aboutButtonNormalWidth, DistrhoArtwork3BandEQ::aboutButtonNormalHeight);
  71. Image aboutImageHover(DistrhoArtwork3BandEQ::aboutButtonHoverData, DistrhoArtwork3BandEQ::aboutButtonHoverWidth, DistrhoArtwork3BandEQ::aboutButtonHoverHeight);
  72. fButtonAbout = new ImageButton(win, aboutImageNormal, aboutImageHover, aboutImageHover);
  73. fButtonAbout->setPos(264, 300);
  74. fButtonAbout->setCallback(this);
  75. }
  76. DistrhoUI3BandEQ::~DistrhoUI3BandEQ()
  77. {
  78. delete fSliderLow;
  79. delete fSliderMid;
  80. delete fSliderHigh;
  81. delete fSliderMaster;
  82. delete fKnobLowMid;
  83. delete fKnobMidHigh;
  84. delete fButtonAbout;
  85. }
  86. // -------------------------------------------------
  87. // DSP Callbacks
  88. void DistrhoUI3BandEQ::d_parameterChanged(uint32_t index, float value)
  89. {
  90. switch (index)
  91. {
  92. case DistrhoPlugin3BandEQ::paramLow:
  93. fSliderLow->setValue(value);
  94. break;
  95. case DistrhoPlugin3BandEQ::paramMid:
  96. fSliderMid->setValue(value);
  97. break;
  98. case DistrhoPlugin3BandEQ::paramHigh:
  99. fSliderHigh->setValue(value);
  100. break;
  101. case DistrhoPlugin3BandEQ::paramMaster:
  102. fSliderMaster->setValue(value);
  103. break;
  104. case DistrhoPlugin3BandEQ::paramLowMidFreq:
  105. fKnobLowMid->setValue(value);
  106. break;
  107. case DistrhoPlugin3BandEQ::paramMidHighFreq:
  108. fKnobMidHigh->setValue(value);
  109. break;
  110. }
  111. }
  112. void DistrhoUI3BandEQ::d_programChanged(uint32_t index)
  113. {
  114. if (index != 0)
  115. return;
  116. // Default values
  117. fSliderLow->setValue(0.0f);
  118. fSliderMid->setValue(0.0f);
  119. fSliderHigh->setValue(0.0f);
  120. fSliderMaster->setValue(0.0f);
  121. fKnobLowMid->setValue(220.0f);
  122. fKnobMidHigh->setValue(2000.0f);
  123. }
  124. // -------------------------------------------------
  125. // Widget Callbacks
  126. void DistrhoUI3BandEQ::imageButtonClicked(ImageButton* button, int)
  127. {
  128. if (button != fButtonAbout)
  129. return;
  130. Image imageAbout(DistrhoArtwork3BandEQ::aboutData, DistrhoArtwork3BandEQ::aboutWidth, DistrhoArtwork3BandEQ::aboutHeight, GL_BGRA);
  131. ImageAboutWindow aboutWindow(getApp(), getParent(), imageAbout);
  132. aboutWindow.exec();
  133. }
  134. void DistrhoUI3BandEQ::imageKnobDragStarted(ImageKnob* knob)
  135. {
  136. if (knob == fKnobLowMid)
  137. d_editParameter(DistrhoPlugin3BandEQ::paramLowMidFreq, true);
  138. else if (knob == fKnobMidHigh)
  139. d_editParameter(DistrhoPlugin3BandEQ::paramMidHighFreq, true);
  140. }
  141. void DistrhoUI3BandEQ::imageKnobDragFinished(ImageKnob* knob)
  142. {
  143. if (knob == fKnobLowMid)
  144. d_editParameter(DistrhoPlugin3BandEQ::paramLowMidFreq, false);
  145. else if (knob == fKnobMidHigh)
  146. d_editParameter(DistrhoPlugin3BandEQ::paramMidHighFreq, false);
  147. }
  148. void DistrhoUI3BandEQ::imageKnobValueChanged(ImageKnob* knob, float value)
  149. {
  150. if (knob == fKnobLowMid)
  151. d_setParameterValue(DistrhoPlugin3BandEQ::paramLowMidFreq, value);
  152. else if (knob == fKnobMidHigh)
  153. d_setParameterValue(DistrhoPlugin3BandEQ::paramMidHighFreq, value);
  154. }
  155. void DistrhoUI3BandEQ::imageSliderDragStarted(ImageSlider* slider)
  156. {
  157. if (slider == fSliderLow)
  158. d_editParameter(DistrhoPlugin3BandEQ::paramLow, true);
  159. else if (slider == fSliderMid)
  160. d_editParameter(DistrhoPlugin3BandEQ::paramMid, true);
  161. else if (slider == fSliderHigh)
  162. d_editParameter(DistrhoPlugin3BandEQ::paramHigh, true);
  163. else if (slider == fSliderMaster)
  164. d_editParameter(DistrhoPlugin3BandEQ::paramMaster, true);
  165. }
  166. void DistrhoUI3BandEQ::imageSliderDragFinished(ImageSlider* slider)
  167. {
  168. if (slider == fSliderLow)
  169. d_editParameter(DistrhoPlugin3BandEQ::paramLow, false);
  170. else if (slider == fSliderMid)
  171. d_editParameter(DistrhoPlugin3BandEQ::paramMid, false);
  172. else if (slider == fSliderHigh)
  173. d_editParameter(DistrhoPlugin3BandEQ::paramHigh, false);
  174. else if (slider == fSliderMaster)
  175. d_editParameter(DistrhoPlugin3BandEQ::paramMaster, false);
  176. }
  177. void DistrhoUI3BandEQ::imageSliderValueChanged(ImageSlider* slider, float value)
  178. {
  179. if (slider == fSliderLow)
  180. d_setParameterValue(DistrhoPlugin3BandEQ::paramLow, value);
  181. else if (slider == fSliderMid)
  182. d_setParameterValue(DistrhoPlugin3BandEQ::paramMid, value);
  183. else if (slider == fSliderHigh)
  184. d_setParameterValue(DistrhoPlugin3BandEQ::paramHigh, value);
  185. else if (slider == fSliderMaster)
  186. d_setParameterValue(DistrhoPlugin3BandEQ::paramMaster, value);
  187. }
  188. void DistrhoUI3BandEQ::onDisplay()
  189. {
  190. fImgBackground.draw();
  191. }
  192. // -------------------------------------------------
  193. UI* createUI()
  194. {
  195. return new DistrhoUI3BandEQ();
  196. }
  197. // -------------------------------------------------
  198. END_NAMESPACE_DISTRHO