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