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.

DistrhoUIStereoEnhancer.cpp 5.3KB

10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * DISTRHO StereoEnhancer Plugin, based on StereoEnhancer by Michael Gruhn
  3. * Copyright (C) 2012-2013 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 doc/LGPL.txt file.
  15. */
  16. #include "DistrhoUIStereoEnhancer.hpp"
  17. using DGL::Point;
  18. START_NAMESPACE_DISTRHO
  19. // -----------------------------------------------------------------------
  20. DistrhoUIStereoEnhancer::DistrhoUIStereoEnhancer()
  21. : UI(),
  22. fAboutWindow(this)
  23. {
  24. // background
  25. fImgBackground = Image(DistrhoArtworkStereoEnhancer::backgroundData, DistrhoArtworkStereoEnhancer::backgroundWidth, DistrhoArtworkStereoEnhancer::backgroundHeight, GL_BGR);
  26. Image imageAbout(DistrhoArtworkStereoEnhancer::aboutData, DistrhoArtworkStereoEnhancer::aboutWidth, DistrhoArtworkStereoEnhancer::aboutHeight, GL_BGR);
  27. fAboutWindow.setImage(imageAbout);
  28. // knobs
  29. Image knobImage(DistrhoArtworkStereoEnhancer::knobData, DistrhoArtworkStereoEnhancer::knobWidth, DistrhoArtworkStereoEnhancer::knobHeight);
  30. fKnobWidthLows = new ImageKnob(this, knobImage);
  31. fKnobWidthLows->setPos(140, 35);
  32. fKnobWidthLows->setRange(0.0f, 200.0f);
  33. fKnobWidthLows->setValue(100.0f);
  34. fKnobWidthLows->setCallback(this);
  35. fKnobWidthHighs = new ImageKnob(this, knobImage);
  36. fKnobWidthHighs->setPos(362, 35);
  37. fKnobWidthHighs->setRange(0.0f, 200.0f);
  38. fKnobWidthHighs->setValue(100.0f);
  39. fKnobWidthHighs->setCallback(this);
  40. fKnobCrossover = new ImageKnob(this, knobImage);
  41. fKnobCrossover->setPos(253, 35);
  42. fKnobCrossover->setRange(0.0f, 100.0f);
  43. fKnobCrossover->setValue(27.51604f);
  44. fKnobCrossover->setCallback(this);
  45. // about button
  46. Image aboutImageNormal(DistrhoArtworkStereoEnhancer::aboutButtonNormalData, DistrhoArtworkStereoEnhancer::aboutButtonNormalWidth, DistrhoArtworkStereoEnhancer::aboutButtonNormalHeight);
  47. Image aboutImageHover(DistrhoArtworkStereoEnhancer::aboutButtonHoverData, DistrhoArtworkStereoEnhancer::aboutButtonHoverWidth, DistrhoArtworkStereoEnhancer::aboutButtonHoverHeight);
  48. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  49. fButtonAbout->setPos(346, 3);
  50. fButtonAbout->setCallback(this);
  51. }
  52. DistrhoUIStereoEnhancer::~DistrhoUIStereoEnhancer()
  53. {
  54. delete fKnobWidthLows;
  55. delete fKnobWidthHighs;
  56. delete fKnobCrossover;
  57. delete fButtonAbout;
  58. }
  59. // -----------------------------------------------------------------------
  60. // DSP Callbacks
  61. void DistrhoUIStereoEnhancer::d_parameterChanged(uint32_t index, float value)
  62. {
  63. switch (index)
  64. {
  65. case DistrhoPluginStereoEnhancer::paramWidthLows:
  66. fKnobWidthLows->setValue(value);
  67. break;
  68. case DistrhoPluginStereoEnhancer::paramWidthHighs:
  69. fKnobWidthHighs->setValue(value);
  70. break;
  71. case DistrhoPluginStereoEnhancer::paramCrossover:
  72. fKnobCrossover->setValue(value);
  73. break;
  74. }
  75. }
  76. void DistrhoUIStereoEnhancer::d_programChanged(uint32_t index)
  77. {
  78. if (index != 0)
  79. return;
  80. // Default values
  81. fKnobWidthLows->setValue(100.0f);
  82. fKnobWidthHighs->setValue(100.0f);
  83. fKnobCrossover->setValue(27.51604f);
  84. }
  85. // -----------------------------------------------------------------------
  86. // Widget Callbacks
  87. void DistrhoUIStereoEnhancer::imageButtonClicked(ImageButton* button, int)
  88. {
  89. if (button != fButtonAbout)
  90. return;
  91. fAboutWindow.exec();
  92. }
  93. void DistrhoUIStereoEnhancer::imageKnobDragStarted(ImageKnob* knob)
  94. {
  95. if (knob == fKnobWidthLows)
  96. d_editParameter(DistrhoPluginStereoEnhancer::paramWidthLows, true);
  97. else if (knob == fKnobWidthHighs)
  98. d_editParameter(DistrhoPluginStereoEnhancer::paramWidthHighs, true);
  99. else if (knob == fKnobCrossover)
  100. d_editParameter(DistrhoPluginStereoEnhancer::paramCrossover, true);
  101. }
  102. void DistrhoUIStereoEnhancer::imageKnobDragFinished(ImageKnob* knob)
  103. {
  104. if (knob == fKnobWidthLows)
  105. d_editParameter(DistrhoPluginStereoEnhancer::paramWidthLows, false);
  106. else if (knob == fKnobWidthHighs)
  107. d_editParameter(DistrhoPluginStereoEnhancer::paramWidthHighs, false);
  108. else if (knob == fKnobCrossover)
  109. d_editParameter(DistrhoPluginStereoEnhancer::paramCrossover, false);
  110. }
  111. void DistrhoUIStereoEnhancer::imageKnobValueChanged(ImageKnob* knob, float value)
  112. {
  113. if (knob == fKnobWidthLows)
  114. d_setParameterValue(DistrhoPluginStereoEnhancer::paramWidthLows, value);
  115. else if (knob == fKnobWidthHighs)
  116. d_setParameterValue(DistrhoPluginStereoEnhancer::paramWidthHighs, value);
  117. else if (knob == fKnobCrossover)
  118. d_setParameterValue(DistrhoPluginStereoEnhancer::paramCrossover, value);
  119. }
  120. void DistrhoUIStereoEnhancer::onDisplay()
  121. {
  122. fImgBackground.draw();
  123. }
  124. // -----------------------------------------------------------------------
  125. UI* createUI()
  126. {
  127. return new DistrhoUIStereoEnhancer();
  128. }
  129. // -----------------------------------------------------------------------
  130. END_NAMESPACE_DISTRHO