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.

230 lines
7.6KB

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