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.

DistrhoUI3BandSplitter.cpp 7.9KB

11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * DISTRHO 3BandSplitter Plugin, based on 3BandSplitter 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 "DistrhoUI3BandSplitter.hpp"
  17. START_NAMESPACE_DISTRHO
  18. // -----------------------------------------------------------------------
  19. DistrhoUI3BandSplitter::DistrhoUI3BandSplitter()
  20. : OpenGLUI(),
  21. fAboutWindow(this)
  22. {
  23. // background
  24. fImgBackground = Image(DistrhoArtwork3BandSplitter::backgroundData, DistrhoArtwork3BandSplitter::backgroundWidth, DistrhoArtwork3BandSplitter::backgroundHeight, GL_BGR);
  25. // about
  26. Image imageAbout(DistrhoArtwork3BandSplitter::aboutData, DistrhoArtwork3BandSplitter::aboutWidth, DistrhoArtwork3BandSplitter::aboutHeight, GL_BGR);
  27. fAboutWindow.setImage(imageAbout);
  28. // sliders
  29. Image sliderImage(DistrhoArtwork3BandSplitter::sliderData, DistrhoArtwork3BandSplitter::sliderWidth, DistrhoArtwork3BandSplitter::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(DistrhoArtwork3BandSplitter::knobData, DistrhoArtwork3BandSplitter::knobWidth, DistrhoArtwork3BandSplitter::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(DistrhoArtwork3BandSplitter::aboutButtonNormalData, DistrhoArtwork3BandSplitter::aboutButtonNormalWidth, DistrhoArtwork3BandSplitter::aboutButtonNormalHeight);
  75. Image aboutImageHover(DistrhoArtwork3BandSplitter::aboutButtonHoverData, DistrhoArtwork3BandSplitter::aboutButtonHoverWidth, DistrhoArtwork3BandSplitter::aboutButtonHoverHeight);
  76. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  77. fButtonAbout->setPos(264, 300);
  78. fButtonAbout->setCallback(this);
  79. }
  80. DistrhoUI3BandSplitter::~DistrhoUI3BandSplitter()
  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 DistrhoUI3BandSplitter::d_parameterChanged(uint32_t index, float value)
  93. {
  94. switch (index)
  95. {
  96. case DistrhoPlugin3BandSplitter::paramLow:
  97. fSliderLow->setValue(value);
  98. break;
  99. case DistrhoPlugin3BandSplitter::paramMid:
  100. fSliderMid->setValue(value);
  101. break;
  102. case DistrhoPlugin3BandSplitter::paramHigh:
  103. fSliderHigh->setValue(value);
  104. break;
  105. case DistrhoPlugin3BandSplitter::paramMaster:
  106. fSliderMaster->setValue(value);
  107. break;
  108. case DistrhoPlugin3BandSplitter::paramLowMidFreq:
  109. fKnobLowMid->setValue(value);
  110. break;
  111. case DistrhoPlugin3BandSplitter::paramMidHighFreq:
  112. fKnobMidHigh->setValue(value);
  113. break;
  114. }
  115. }
  116. void DistrhoUI3BandSplitter::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 DistrhoUI3BandSplitter::imageButtonClicked(ImageButton* button, int)
  131. {
  132. if (button != fButtonAbout)
  133. return;
  134. fAboutWindow.exec();
  135. }
  136. void DistrhoUI3BandSplitter::imageKnobDragStarted(ImageKnob* knob)
  137. {
  138. if (knob == fKnobLowMid)
  139. d_editParameter(DistrhoPlugin3BandSplitter::paramLowMidFreq, true);
  140. else if (knob == fKnobMidHigh)
  141. d_editParameter(DistrhoPlugin3BandSplitter::paramMidHighFreq, true);
  142. }
  143. void DistrhoUI3BandSplitter::imageKnobDragFinished(ImageKnob* knob)
  144. {
  145. if (knob == fKnobLowMid)
  146. d_editParameter(DistrhoPlugin3BandSplitter::paramLowMidFreq, false);
  147. else if (knob == fKnobMidHigh)
  148. d_editParameter(DistrhoPlugin3BandSplitter::paramMidHighFreq, false);
  149. }
  150. void DistrhoUI3BandSplitter::imageKnobValueChanged(ImageKnob* knob, float value)
  151. {
  152. if (knob == fKnobLowMid)
  153. d_setParameterValue(DistrhoPlugin3BandSplitter::paramLowMidFreq, value);
  154. else if (knob == fKnobMidHigh)
  155. d_setParameterValue(DistrhoPlugin3BandSplitter::paramMidHighFreq, value);
  156. }
  157. void DistrhoUI3BandSplitter::imageSliderDragStarted(ImageSlider* slider)
  158. {
  159. if (slider == fSliderLow)
  160. d_editParameter(DistrhoPlugin3BandSplitter::paramLow, true);
  161. else if (slider == fSliderMid)
  162. d_editParameter(DistrhoPlugin3BandSplitter::paramMid, true);
  163. else if (slider == fSliderHigh)
  164. d_editParameter(DistrhoPlugin3BandSplitter::paramHigh, true);
  165. else if (slider == fSliderMaster)
  166. d_editParameter(DistrhoPlugin3BandSplitter::paramMaster, true);
  167. }
  168. void DistrhoUI3BandSplitter::imageSliderDragFinished(ImageSlider* slider)
  169. {
  170. if (slider == fSliderLow)
  171. d_editParameter(DistrhoPlugin3BandSplitter::paramLow, false);
  172. else if (slider == fSliderMid)
  173. d_editParameter(DistrhoPlugin3BandSplitter::paramMid, false);
  174. else if (slider == fSliderHigh)
  175. d_editParameter(DistrhoPlugin3BandSplitter::paramHigh, false);
  176. else if (slider == fSliderMaster)
  177. d_editParameter(DistrhoPlugin3BandSplitter::paramMaster, false);
  178. }
  179. void DistrhoUI3BandSplitter::imageSliderValueChanged(ImageSlider* slider, float value)
  180. {
  181. if (slider == fSliderLow)
  182. d_setParameterValue(DistrhoPlugin3BandSplitter::paramLow, value);
  183. else if (slider == fSliderMid)
  184. d_setParameterValue(DistrhoPlugin3BandSplitter::paramMid, value);
  185. else if (slider == fSliderHigh)
  186. d_setParameterValue(DistrhoPlugin3BandSplitter::paramHigh, value);
  187. else if (slider == fSliderMaster)
  188. d_setParameterValue(DistrhoPlugin3BandSplitter::paramMaster, value);
  189. }
  190. void DistrhoUI3BandSplitter::onDisplay()
  191. {
  192. fImgBackground.draw();
  193. }
  194. // -----------------------------------------------------------------------
  195. UI* createUI()
  196. {
  197. return new DistrhoUI3BandSplitter();
  198. }
  199. // -----------------------------------------------------------------------
  200. END_NAMESPACE_DISTRHO