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.

206 lines
6.6KB

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