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.

DistrhoUI3BandEQ.cpp 6.5KB

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