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.

208 lines
6.4KB

  1. /*
  2. * DISTRHO 3BandEQ Plugin, based on 3BandEQ 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 "DistrhoPlugin3BandEQ.hpp"
  17. #include "DistrhoUI3BandEQ.hpp"
  18. using DGL::Point;
  19. START_NAMESPACE_DISTRHO
  20. // -----------------------------------------------------------------------
  21. DistrhoUI3BandEQ::DistrhoUI3BandEQ()
  22. : UI(),
  23. fAboutWindow(this)
  24. {
  25. // set UI size
  26. setSize(DistrhoArtwork3BandEQ::backgroundWidth, DistrhoArtwork3BandEQ::backgroundHeight);
  27. // background
  28. fImgBackground = Image(DistrhoArtwork3BandEQ::backgroundData, DistrhoArtwork3BandEQ::backgroundWidth, DistrhoArtwork3BandEQ::backgroundHeight, GL_BGR);
  29. // about
  30. Image aboutImage(DistrhoArtwork3BandEQ::aboutData, DistrhoArtwork3BandEQ::aboutWidth, DistrhoArtwork3BandEQ::aboutHeight, GL_BGR);
  31. fAboutWindow.setImage(aboutImage);
  32. // sliders
  33. Image sliderImage(DistrhoArtwork3BandEQ::sliderData, DistrhoArtwork3BandEQ::sliderWidth, DistrhoArtwork3BandEQ::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(DistrhoPlugin3BandEQ::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(DistrhoPlugin3BandEQ::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(DistrhoPlugin3BandEQ::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(DistrhoPlugin3BandEQ::paramMaster);
  63. fSliderMaster->setStartPos(sliderPosStart);
  64. fSliderMaster->setEndPos(sliderPosEnd);
  65. // knobs
  66. Image knobImage(DistrhoArtwork3BandEQ::knobData, DistrhoArtwork3BandEQ::knobWidth, DistrhoArtwork3BandEQ::knobHeight);
  67. // knob Low-Mid
  68. fKnobLowMid = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  69. fKnobLowMid->setId(DistrhoPlugin3BandEQ::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(DistrhoPlugin3BandEQ::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(DistrhoArtwork3BandEQ::aboutButtonNormalData, DistrhoArtwork3BandEQ::aboutButtonNormalWidth, DistrhoArtwork3BandEQ::aboutButtonNormalHeight);
  85. Image aboutImageHover(DistrhoArtwork3BandEQ::aboutButtonHoverData, DistrhoArtwork3BandEQ::aboutButtonHoverWidth, DistrhoArtwork3BandEQ::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 DistrhoUI3BandEQ::d_parameterChanged(uint32_t index, float value)
  95. {
  96. switch (index)
  97. {
  98. case DistrhoPlugin3BandEQ::paramLow:
  99. fSliderLow->setValue(value);
  100. break;
  101. case DistrhoPlugin3BandEQ::paramMid:
  102. fSliderMid->setValue(value);
  103. break;
  104. case DistrhoPlugin3BandEQ::paramHigh:
  105. fSliderHigh->setValue(value);
  106. break;
  107. case DistrhoPlugin3BandEQ::paramMaster:
  108. fSliderMaster->setValue(value);
  109. break;
  110. case DistrhoPlugin3BandEQ::paramLowMidFreq:
  111. fKnobLowMid->setValue(value);
  112. break;
  113. case DistrhoPlugin3BandEQ::paramMidHighFreq:
  114. fKnobMidHigh->setValue(value);
  115. break;
  116. }
  117. }
  118. void DistrhoUI3BandEQ::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 DistrhoUI3BandEQ::imageButtonClicked(ImageButton* button, int)
  133. {
  134. if (button != fButtonAbout)
  135. return;
  136. fAboutWindow.exec();
  137. }
  138. void DistrhoUI3BandEQ::imageKnobDragStarted(ImageKnob* knob)
  139. {
  140. d_editParameter(knob->getId(), true);
  141. }
  142. void DistrhoUI3BandEQ::imageKnobDragFinished(ImageKnob* knob)
  143. {
  144. d_editParameter(knob->getId(), false);
  145. }
  146. void DistrhoUI3BandEQ::imageKnobValueChanged(ImageKnob* knob, float value)
  147. {
  148. d_setParameterValue(knob->getId(), value);
  149. }
  150. void DistrhoUI3BandEQ::imageSliderDragStarted(ImageSlider* slider)
  151. {
  152. d_editParameter(slider->getId(), true);
  153. }
  154. void DistrhoUI3BandEQ::imageSliderDragFinished(ImageSlider* slider)
  155. {
  156. d_editParameter(slider->getId(), false);
  157. }
  158. void DistrhoUI3BandEQ::imageSliderValueChanged(ImageSlider* slider, float value)
  159. {
  160. d_setParameterValue(slider->getId(), value);
  161. }
  162. void DistrhoUI3BandEQ::onDisplay()
  163. {
  164. fImgBackground.draw();
  165. }
  166. // -----------------------------------------------------------------------
  167. UI* createUI()
  168. {
  169. return new DistrhoUI3BandEQ();
  170. }
  171. // -----------------------------------------------------------------------
  172. END_NAMESPACE_DISTRHO