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.

131 lines
4.1KB

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