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.

202 lines
6.2KB

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