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.

WobbleJuiceUI.cpp 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * Wobble Juice Plugin
  3. * Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "WobbleJuicePlugin.hpp"
  18. #include "WobbleJuiceUI.hpp"
  19. START_NAMESPACE_DISTRHO
  20. // -----------------------------------------------------------------------
  21. WobbleJuiceUI::WobbleJuiceUI()
  22. : UI()
  23. #ifndef DISTRHO_OS_MAC
  24. , fAboutWindow(this)
  25. #endif
  26. {
  27. setSize(WobbleJuiceArtwork::backgroundWidth, WobbleJuiceArtwork::backgroundHeight);
  28. // background
  29. fImgBackground = Image(WobbleJuiceArtwork::backgroundData, WobbleJuiceArtwork::backgroundWidth, WobbleJuiceArtwork::backgroundHeight, GL_BGR);
  30. #ifndef DISTRHO_OS_MAC
  31. // about
  32. Image aboutImage(WobbleJuiceArtwork::aboutData, WobbleJuiceArtwork::aboutWidth, WobbleJuiceArtwork::aboutHeight, GL_BGR);
  33. fAboutWindow.setImage(aboutImage);
  34. #endif
  35. // knobs
  36. Image knobImage(WobbleJuiceArtwork::knobData, WobbleJuiceArtwork::knobWidth, WobbleJuiceArtwork::knobHeight);
  37. // knob Division
  38. fKnobDivision = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  39. fKnobDivision->setId(WobbleJuicePlugin::paramDivision);
  40. fKnobDivision->setAbsolutePos(222, 74);
  41. fKnobDivision->setRotationAngle(270);
  42. fKnobDivision->setRange(1.0f, 16.0f);
  43. fKnobDivision->setDefault(4.0f);
  44. fKnobDivision->setStep(1.0f);
  45. fKnobDivision->setCallback(this);
  46. // knob Resonance
  47. fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  48. fKnobResonance->setId(WobbleJuicePlugin::paramReso);
  49. fKnobResonance->setAbsolutePos(222, 199);
  50. fKnobResonance->setRotationAngle(270);
  51. fKnobResonance->setRange(0.0f, 0.2f);
  52. fKnobResonance->setDefault(0.1f);
  53. fKnobResonance->setCallback(this);
  54. // knob Range
  55. fKnobRange = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  56. fKnobRange->setId(WobbleJuicePlugin::paramRange);
  57. fKnobRange->setAbsolutePos(77, 199);
  58. fKnobRange->setRotationAngle(270);
  59. fKnobRange->setRange(500.0f, 16000.0f);
  60. fKnobRange->setDefault(16000.0f);
  61. fKnobRange->setCallback(this);
  62. // knob Phase
  63. fKnobPhase = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  64. fKnobPhase->setId(WobbleJuicePlugin::paramPhase);
  65. fKnobPhase->setAbsolutePos(362, 74);
  66. fKnobPhase->setRotationAngle(270);
  67. fKnobPhase->setRange(-1.0f, 1.0f);
  68. fKnobPhase->setDefault(0.0f);
  69. fKnobPhase->setCallback(this);
  70. // knob Wave
  71. fKnobWave = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  72. fKnobWave->setId(WobbleJuicePlugin::paramWave);
  73. fKnobWave->setAbsolutePos(77, 74);
  74. fKnobWave->setRotationAngle(270);
  75. fKnobWave->setRange(1.0f, 4.0f);
  76. fKnobWave->setDefault(2.0f);
  77. fKnobWave->setCallback(this);
  78. // knob Drive
  79. fKnobDrive = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  80. fKnobDrive->setId(WobbleJuicePlugin::paramDrive);
  81. fKnobDrive->setAbsolutePos(362, 199);
  82. fKnobDrive->setRotationAngle(270);
  83. fKnobDrive->setRange(0.0f, 1.0f);
  84. fKnobDrive->setDefault(0.5f);
  85. fKnobDrive->setCallback(this);
  86. // about button
  87. Image aboutImageNormal(WobbleJuiceArtwork::aboutButtonNormalData, WobbleJuiceArtwork::aboutButtonNormalWidth, WobbleJuiceArtwork::aboutButtonNormalHeight);
  88. Image aboutImageHover(WobbleJuiceArtwork::aboutButtonHoverData, WobbleJuiceArtwork::aboutButtonHoverWidth, WobbleJuiceArtwork::aboutButtonHoverHeight);
  89. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  90. fButtonAbout->setAbsolutePos(390, 20);
  91. fButtonAbout->setCallback(this);
  92. // set default values
  93. d_programChanged(0);
  94. }
  95. // -----------------------------------------------------------------------
  96. // DSP Callbacks
  97. void WobbleJuiceUI::d_parameterChanged(uint32_t index, float value)
  98. {
  99. switch (index)
  100. {
  101. case WobbleJuicePlugin::paramDivision:
  102. fKnobDivision->setValue(value);
  103. break;
  104. case WobbleJuicePlugin::paramReso:
  105. fKnobResonance->setValue(value);
  106. break;
  107. case WobbleJuicePlugin::paramRange:
  108. fKnobRange->setValue(value);
  109. break;
  110. case WobbleJuicePlugin::paramPhase:
  111. fKnobPhase->setValue(value);
  112. break;
  113. case WobbleJuicePlugin::paramWave:
  114. fKnobWave->setValue(value);
  115. break;
  116. case WobbleJuicePlugin::paramDrive:
  117. fKnobDrive->setValue(value);
  118. break;
  119. }
  120. }
  121. void WobbleJuiceUI::d_programChanged(uint32_t index)
  122. {
  123. if (index != 0)
  124. return;
  125. // Default values
  126. fKnobDivision->setValue(4.0f);
  127. fKnobResonance->setValue(0.1f);
  128. fKnobRange->setValue(16000.0f);
  129. fKnobPhase->setValue(0.0f);
  130. fKnobWave->setValue(2.0f);
  131. fKnobDrive->setValue(0.5f);
  132. }
  133. // -----------------------------------------------------------------------
  134. // Widget Callbacks
  135. void WobbleJuiceUI::imageButtonClicked(ImageButton* button, int)
  136. {
  137. if (button != fButtonAbout)
  138. return;
  139. #ifndef DISTRHO_OS_MAC
  140. fAboutWindow.exec();
  141. #endif
  142. }
  143. void WobbleJuiceUI::imageKnobDragStarted(ImageKnob* knob)
  144. {
  145. d_editParameter(knob->getId(), true);
  146. }
  147. void WobbleJuiceUI::imageKnobDragFinished(ImageKnob* knob)
  148. {
  149. d_editParameter(knob->getId(), false);
  150. }
  151. void WobbleJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value)
  152. {
  153. d_setParameterValue(knob->getId(), value);
  154. }
  155. void WobbleJuiceUI::onDisplay()
  156. {
  157. fImgBackground.draw();
  158. }
  159. // -----------------------------------------------------------------------
  160. UI* createUI()
  161. {
  162. return new WobbleJuiceUI();
  163. }
  164. // -----------------------------------------------------------------------
  165. END_NAMESPACE_DISTRHO