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 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. fAboutWindow(this)
  24. {
  25. setSize(WobbleJuiceArtwork::backgroundWidth, WobbleJuiceArtwork::backgroundHeight);
  26. // background
  27. fImgBackground = Image(WobbleJuiceArtwork::backgroundData, WobbleJuiceArtwork::backgroundWidth, WobbleJuiceArtwork::backgroundHeight, GL_BGR);
  28. // about
  29. Image aboutImage(WobbleJuiceArtwork::aboutData, WobbleJuiceArtwork::aboutWidth, WobbleJuiceArtwork::aboutHeight, GL_BGR);
  30. fAboutWindow.setImage(aboutImage);
  31. // knobs
  32. Image knobImage(WobbleJuiceArtwork::knobData, WobbleJuiceArtwork::knobWidth, WobbleJuiceArtwork::knobHeight);
  33. // knob Division
  34. fKnobDivision = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  35. fKnobDivision->setId(WobbleJuicePlugin::paramDivision);
  36. fKnobDivision->setAbsolutePos(222, 74);
  37. fKnobDivision->setRotationAngle(270);
  38. fKnobDivision->setRange(1.0f, 16.0f);
  39. fKnobDivision->setDefault(4.0f);
  40. fKnobDivision->setStep(1.0f);
  41. fKnobDivision->setCallback(this);
  42. // knob Resonance
  43. fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  44. fKnobResonance->setId(WobbleJuicePlugin::paramReso);
  45. fKnobResonance->setAbsolutePos(222, 199);
  46. fKnobResonance->setRotationAngle(270);
  47. fKnobResonance->setRange(0.0f, 0.2f);
  48. fKnobResonance->setDefault(0.1f);
  49. fKnobResonance->setCallback(this);
  50. // knob Range
  51. fKnobRange = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  52. fKnobRange->setId(WobbleJuicePlugin::paramRange);
  53. fKnobRange->setAbsolutePos(77, 199);
  54. fKnobRange->setRotationAngle(270);
  55. fKnobRange->setRange(500.0f, 16000.0f);
  56. fKnobRange->setDefault(16000.0f);
  57. fKnobRange->setCallback(this);
  58. // knob Phase
  59. fKnobPhase = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  60. fKnobPhase->setId(WobbleJuicePlugin::paramPhase);
  61. fKnobPhase->setAbsolutePos(362, 74);
  62. fKnobPhase->setRotationAngle(270);
  63. fKnobPhase->setRange(-1.0f, 1.0f);
  64. fKnobPhase->setDefault(0.0f);
  65. fKnobPhase->setCallback(this);
  66. // knob Wave
  67. fKnobWave = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  68. fKnobWave->setId(WobbleJuicePlugin::paramWave);
  69. fKnobWave->setAbsolutePos(77, 74);
  70. fKnobWave->setRotationAngle(270);
  71. fKnobWave->setRange(1.0f, 4.0f);
  72. fKnobWave->setDefault(2.0f);
  73. fKnobWave->setCallback(this);
  74. // knob Drive
  75. fKnobDrive = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  76. fKnobDrive->setId(WobbleJuicePlugin::paramDrive);
  77. fKnobDrive->setAbsolutePos(362, 199);
  78. fKnobDrive->setRotationAngle(270);
  79. fKnobDrive->setRange(0.0f, 1.0f);
  80. fKnobDrive->setDefault(0.5f);
  81. fKnobDrive->setCallback(this);
  82. // about button
  83. Image aboutImageNormal(WobbleJuiceArtwork::aboutButtonNormalData, WobbleJuiceArtwork::aboutButtonNormalWidth, WobbleJuiceArtwork::aboutButtonNormalHeight);
  84. Image aboutImageHover(WobbleJuiceArtwork::aboutButtonHoverData, WobbleJuiceArtwork::aboutButtonHoverWidth, WobbleJuiceArtwork::aboutButtonHoverHeight);
  85. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  86. fButtonAbout->setAbsolutePos(390, 20);
  87. fButtonAbout->setCallback(this);
  88. // set default values
  89. d_programChanged(0);
  90. }
  91. // -----------------------------------------------------------------------
  92. // DSP Callbacks
  93. void WobbleJuiceUI::d_parameterChanged(uint32_t index, float value)
  94. {
  95. switch (index)
  96. {
  97. case WobbleJuicePlugin::paramDivision:
  98. fKnobDivision->setValue(value);
  99. break;
  100. case WobbleJuicePlugin::paramReso:
  101. fKnobResonance->setValue(value);
  102. break;
  103. case WobbleJuicePlugin::paramRange:
  104. fKnobRange->setValue(value);
  105. break;
  106. case WobbleJuicePlugin::paramPhase:
  107. fKnobPhase->setValue(value);
  108. break;
  109. case WobbleJuicePlugin::paramWave:
  110. fKnobWave->setValue(value);
  111. break;
  112. case WobbleJuicePlugin::paramDrive:
  113. fKnobDrive->setValue(value);
  114. break;
  115. }
  116. }
  117. void WobbleJuiceUI::d_programChanged(uint32_t index)
  118. {
  119. if (index != 0)
  120. return;
  121. // Default values
  122. fKnobDivision->setValue(4.0f);
  123. fKnobResonance->setValue(0.1f);
  124. fKnobRange->setValue(16000.0f);
  125. fKnobPhase->setValue(0.0f);
  126. fKnobWave->setValue(2.0f);
  127. fKnobDrive->setValue(0.5f);
  128. }
  129. // -----------------------------------------------------------------------
  130. // Widget Callbacks
  131. void WobbleJuiceUI::imageButtonClicked(ImageButton* button, int)
  132. {
  133. if (button != fButtonAbout)
  134. return;
  135. fAboutWindow.exec();
  136. }
  137. void WobbleJuiceUI::imageKnobDragStarted(ImageKnob* knob)
  138. {
  139. d_editParameter(knob->getId(), true);
  140. }
  141. void WobbleJuiceUI::imageKnobDragFinished(ImageKnob* knob)
  142. {
  143. d_editParameter(knob->getId(), false);
  144. }
  145. void WobbleJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value)
  146. {
  147. d_setParameterValue(knob->getId(), value);
  148. }
  149. void WobbleJuiceUI::onDisplay()
  150. {
  151. fImgBackground.draw();
  152. }
  153. // -----------------------------------------------------------------------
  154. UI* createUI()
  155. {
  156. return new WobbleJuiceUI();
  157. }
  158. // -----------------------------------------------------------------------
  159. END_NAMESPACE_DISTRHO