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 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * DISTRHO 3BandSplitter Plugin, based on 3BandSplitter by Michael Gruhn
  3. * Copyright (C) 2012-2015 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 LICENSE file.
  15. */
  16. #include "DistrhoPlugin3BandSplitter.hpp"
  17. #include "DistrhoUI3BandSplitter.hpp"
  18. using DGL::Point;
  19. START_NAMESPACE_DISTRHO
  20. // -----------------------------------------------------------------------
  21. DistrhoUI3BandSplitter::DistrhoUI3BandSplitter()
  22. : UI(),
  23. fAboutWindow(this)
  24. {
  25. // set UI size
  26. setSize(DistrhoArtwork3BandSplitter::backgroundWidth, DistrhoArtwork3BandSplitter::backgroundHeight);
  27. // background
  28. fImgBackground = Image(DistrhoArtwork3BandSplitter::backgroundData, DistrhoArtwork3BandSplitter::backgroundWidth, DistrhoArtwork3BandSplitter::backgroundHeight, GL_BGR);
  29. // about
  30. Image aboutImage(DistrhoArtwork3BandSplitter::aboutData, DistrhoArtwork3BandSplitter::aboutWidth, DistrhoArtwork3BandSplitter::aboutHeight, GL_BGR);
  31. fAboutWindow.setImage(aboutImage);
  32. // sliders
  33. Image sliderImage(DistrhoArtwork3BandSplitter::sliderData, DistrhoArtwork3BandSplitter::sliderWidth, DistrhoArtwork3BandSplitter::sliderHeight);
  34. Point<int> sliderPosStart(57, 43);
  35. Point<int> sliderPosEnd(57, 43 + 160);
  36. // slider Low
  37. fSliderLow = new ImageSlider(this, sliderImage);
  38. fSliderLow->setId(DistrhoPlugin3BandSplitter::paramLow);
  39. fSliderLow->setInverted(true);
  40. fSliderLow->setStartPos(sliderPosStart);
  41. fSliderLow->setEndPos(sliderPosEnd);
  42. fSliderLow->setRange(-24.0f, 24.0f);
  43. fSliderLow->setCallback(this);
  44. // slider Mid
  45. sliderPosStart.setX(120);
  46. sliderPosEnd.setX(120);
  47. fSliderMid = new ImageSlider(*fSliderLow);
  48. fSliderMid->setId(DistrhoPlugin3BandSplitter::paramMid);
  49. fSliderMid->setStartPos(sliderPosStart);
  50. fSliderMid->setEndPos(sliderPosEnd);
  51. // slider High
  52. sliderPosStart.setX(183);
  53. sliderPosEnd.setX(183);
  54. fSliderHigh = new ImageSlider(*fSliderLow);
  55. fSliderHigh->setId(DistrhoPlugin3BandSplitter::paramHigh);
  56. fSliderHigh->setStartPos(sliderPosStart);
  57. fSliderHigh->setEndPos(sliderPosEnd);
  58. // slider Master
  59. sliderPosStart.setX(287);
  60. sliderPosEnd.setX(287);
  61. fSliderMaster = new ImageSlider(*fSliderLow);
  62. fSliderMaster->setId(DistrhoPlugin3BandSplitter::paramMaster);
  63. fSliderMaster->setStartPos(sliderPosStart);
  64. fSliderMaster->setEndPos(sliderPosEnd);
  65. // knobs
  66. Image knobImage(DistrhoArtwork3BandSplitter::knobData, DistrhoArtwork3BandSplitter::knobWidth, DistrhoArtwork3BandSplitter::knobHeight);
  67. // knob Low-Mid
  68. fKnobLowMid = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  69. fKnobLowMid->setId(DistrhoPlugin3BandSplitter::paramLowMidFreq);
  70. fKnobLowMid->setAbsolutePos(65, 269);
  71. fKnobLowMid->setRange(0.0f, 1000.0f);
  72. fKnobLowMid->setDefault(440.0f);
  73. fKnobLowMid->setRotationAngle(270);
  74. fKnobLowMid->setCallback(this);
  75. // knob Mid-High
  76. fKnobMidHigh = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  77. fKnobMidHigh->setId(DistrhoPlugin3BandSplitter::paramMidHighFreq);
  78. fKnobMidHigh->setAbsolutePos(159, 269);
  79. fKnobMidHigh->setRange(1000.0f, 20000.0f);
  80. fKnobMidHigh->setDefault(1000.0f);
  81. fKnobMidHigh->setRotationAngle(270);
  82. fKnobMidHigh->setCallback(this);
  83. // about button
  84. Image aboutImageNormal(DistrhoArtwork3BandSplitter::aboutButtonNormalData, DistrhoArtwork3BandSplitter::aboutButtonNormalWidth, DistrhoArtwork3BandSplitter::aboutButtonNormalHeight);
  85. Image aboutImageHover(DistrhoArtwork3BandSplitter::aboutButtonHoverData, DistrhoArtwork3BandSplitter::aboutButtonHoverWidth, DistrhoArtwork3BandSplitter::aboutButtonHoverHeight);
  86. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  87. fButtonAbout->setAbsolutePos(264, 300);
  88. fButtonAbout->setCallback(this);
  89. // set default values
  90. d_programChanged(0);
  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. d_editParameter(knob->getId(), true);
  141. }
  142. void DistrhoUI3BandSplitter::imageKnobDragFinished(ImageKnob* knob)
  143. {
  144. d_editParameter(knob->getId(), false);
  145. }
  146. void DistrhoUI3BandSplitter::imageKnobValueChanged(ImageKnob* knob, float value)
  147. {
  148. d_setParameterValue(knob->getId(), value);
  149. }
  150. void DistrhoUI3BandSplitter::imageSliderDragStarted(ImageSlider* slider)
  151. {
  152. d_editParameter(slider->getId(), true);
  153. }
  154. void DistrhoUI3BandSplitter::imageSliderDragFinished(ImageSlider* slider)
  155. {
  156. d_editParameter(slider->getId(), false);
  157. }
  158. void DistrhoUI3BandSplitter::imageSliderValueChanged(ImageSlider* slider, float value)
  159. {
  160. d_setParameterValue(slider->getId(), value);
  161. }
  162. void DistrhoUI3BandSplitter::onDisplay()
  163. {
  164. fImgBackground.draw();
  165. }
  166. // -----------------------------------------------------------------------
  167. UI* createUI()
  168. {
  169. return new DistrhoUI3BandSplitter();
  170. }
  171. // -----------------------------------------------------------------------
  172. END_NAMESPACE_DISTRHO