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.

237 lines
7.9KB

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