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.

134 lines
3.8KB

  1. /*
  2. * DISTRHO PingPongPan Plugin, based on PingPongPan 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 "DistrhoPluginPingPongPan.hpp"
  17. #include "DistrhoUIPingPongPan.hpp"
  18. START_NAMESPACE_DISTRHO
  19. namespace Art = DistrhoArtworkPingPongPan;
  20. // -----------------------------------------------------------------------
  21. DistrhoUIPingPongPan::DistrhoUIPingPongPan()
  22. : UI(Art::backgroundWidth, Art::backgroundHeight),
  23. fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR),
  24. fAboutWindow(this)
  25. {
  26. // about
  27. Image imageAbout(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR);
  28. fAboutWindow.setImage(imageAbout);
  29. // knobs
  30. Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight);
  31. // knob Low-Mid
  32. fKnobFreq = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  33. fKnobFreq->setId(DistrhoPluginPingPongPan::paramFreq);
  34. fKnobFreq->setAbsolutePos(60, 58);
  35. fKnobFreq->setRange(0.0f, 100.0f);
  36. fKnobFreq->setDefault(50.0f);
  37. fKnobFreq->setRotationAngle(270);
  38. fKnobFreq->setCallback(this);
  39. // knob Mid-High
  40. fKnobWidth = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  41. fKnobWidth->setId(DistrhoPluginPingPongPan::paramWidth);
  42. fKnobWidth->setAbsolutePos(182, 58);
  43. fKnobWidth->setRange(0.0f, 100.0f);
  44. fKnobWidth->setDefault(75.0f);
  45. fKnobWidth->setRotationAngle(270);
  46. fKnobWidth->setCallback(this);
  47. // about button
  48. Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight);
  49. Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight);
  50. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  51. fButtonAbout->setAbsolutePos(183, 8);
  52. fButtonAbout->setCallback(this);
  53. // set default values
  54. programLoaded(0);
  55. }
  56. // -----------------------------------------------------------------------
  57. // DSP Callbacks
  58. void DistrhoUIPingPongPan::parameterChanged(uint32_t index, float value)
  59. {
  60. switch (index)
  61. {
  62. case DistrhoPluginPingPongPan::paramFreq:
  63. fKnobFreq->setValue(value);
  64. break;
  65. case DistrhoPluginPingPongPan::paramWidth:
  66. fKnobWidth->setValue(value);
  67. break;
  68. }
  69. }
  70. void DistrhoUIPingPongPan::programLoaded(uint32_t index)
  71. {
  72. if (index != 0)
  73. return;
  74. // Default values
  75. fKnobFreq->setValue(50.0f);
  76. fKnobWidth->setValue(75.0f);
  77. }
  78. // -----------------------------------------------------------------------
  79. // Widget Callbacks
  80. void DistrhoUIPingPongPan::imageButtonClicked(ImageButton* button, int)
  81. {
  82. if (button != fButtonAbout)
  83. return;
  84. fAboutWindow.exec();
  85. }
  86. void DistrhoUIPingPongPan::imageKnobDragStarted(ImageKnob* knob)
  87. {
  88. editParameter(knob->getId(), true);
  89. }
  90. void DistrhoUIPingPongPan::imageKnobDragFinished(ImageKnob* knob)
  91. {
  92. editParameter(knob->getId(), false);
  93. }
  94. void DistrhoUIPingPongPan::imageKnobValueChanged(ImageKnob* knob, float value)
  95. {
  96. setParameterValue(knob->getId(), value);
  97. }
  98. void DistrhoUIPingPongPan::onDisplay()
  99. {
  100. fImgBackground.draw();
  101. }
  102. // -----------------------------------------------------------------------
  103. UI* createUI()
  104. {
  105. return new DistrhoUIPingPongPan();
  106. }
  107. // -----------------------------------------------------------------------
  108. END_NAMESPACE_DISTRHO