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.5KB

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