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.

214 lines
6.5KB

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