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.

DistrhoUINekobi.cpp 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /*
  2. * DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others.
  3. * Copyright (C) 2013-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 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 LICENSE file.
  16. */
  17. #include "DistrhoPluginNekobi.hpp"
  18. #include "DistrhoUINekobi.hpp"
  19. START_NAMESPACE_DISTRHO
  20. namespace Art = DistrhoArtworkNekobi;
  21. // -----------------------------------------------------------------------
  22. DistrhoUINekobi::DistrhoUINekobi()
  23. : UI(Art::backgroundWidth, Art::backgroundHeight),
  24. fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR),
  25. fAboutWindow(this)
  26. {
  27. // FIXME
  28. fNeko.setTimerSpeed(5);
  29. // about
  30. Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR);
  31. fAboutWindow.setImage(aboutImage);
  32. // slider
  33. Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight);
  34. fSliderWaveform = new ImageSlider(this, sliderImage);
  35. fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform);
  36. fSliderWaveform->setStartPos(133, 40);
  37. fSliderWaveform->setEndPos(133, 60);
  38. fSliderWaveform->setRange(0.0f, 1.0f);
  39. fSliderWaveform->setStep(1.0f);
  40. fSliderWaveform->setValue(0.0f);
  41. fSliderWaveform->setCallback(this);
  42. // knobs
  43. Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight);
  44. // knob Tuning
  45. fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  46. fKnobTuning->setId(DistrhoPluginNekobi::paramTuning);
  47. fKnobTuning->setAbsolutePos(41, 43);
  48. fKnobTuning->setRange(-12.0f, 12.0f);
  49. fKnobTuning->setDefault(0.0f);
  50. fKnobTuning->setValue(0.0f);
  51. fKnobTuning->setRotationAngle(305);
  52. fKnobTuning->setCallback(this);
  53. // knob Cutoff
  54. fKnobCutoff = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  55. fKnobCutoff->setId(DistrhoPluginNekobi::paramCutoff);
  56. fKnobCutoff->setAbsolutePos(185, 43);
  57. fKnobCutoff->setRange(0.0f, 100.0f);
  58. fKnobCutoff->setDefault(25.0f);
  59. fKnobCutoff->setValue(25.0f);
  60. fKnobCutoff->setRotationAngle(305);
  61. fKnobCutoff->setCallback(this);
  62. // knob Resonance
  63. fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  64. fKnobResonance->setId(DistrhoPluginNekobi::paramResonance);
  65. fKnobResonance->setAbsolutePos(257, 43);
  66. fKnobResonance->setRange(0.0f, 95.0f);
  67. fKnobResonance->setDefault(25.0f);
  68. fKnobResonance->setValue(25.0f);
  69. fKnobResonance->setRotationAngle(305);
  70. fKnobResonance->setCallback(this);
  71. // knob Env Mod
  72. fKnobEnvMod = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  73. fKnobEnvMod->setId(DistrhoPluginNekobi::paramEnvMod);
  74. fKnobEnvMod->setAbsolutePos(329, 43);
  75. fKnobEnvMod->setRange(0.0f, 100.0f);
  76. fKnobEnvMod->setDefault(50.0f);
  77. fKnobEnvMod->setValue(50.0f);
  78. fKnobEnvMod->setRotationAngle(305);
  79. fKnobEnvMod->setCallback(this);
  80. // knob Decay
  81. fKnobDecay = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  82. fKnobDecay->setId(DistrhoPluginNekobi::paramDecay);
  83. fKnobDecay->setAbsolutePos(400, 43);
  84. fKnobDecay->setRange(0.0f, 100.0f);
  85. fKnobDecay->setDefault(75.0f);
  86. fKnobDecay->setValue(75.0f);
  87. fKnobDecay->setRotationAngle(305);
  88. fKnobDecay->setCallback(this);
  89. // knob Accent
  90. fKnobAccent = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  91. fKnobAccent->setId(DistrhoPluginNekobi::paramAccent);
  92. fKnobAccent->setAbsolutePos(473, 43);
  93. fKnobAccent->setRange(0.0f, 100.0f);
  94. fKnobAccent->setDefault(25.0f);
  95. fKnobAccent->setValue(25.0f);
  96. fKnobAccent->setRotationAngle(305);
  97. fKnobAccent->setCallback(this);
  98. // knob Volume
  99. fKnobVolume = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  100. fKnobVolume->setId(DistrhoPluginNekobi::paramVolume);
  101. fKnobVolume->setAbsolutePos(545, 43);
  102. fKnobVolume->setRange(0.0f, 100.0f);
  103. fKnobVolume->setDefault(75.0f);
  104. fKnobVolume->setValue(75.0f);
  105. fKnobVolume->setRotationAngle(305);
  106. fKnobVolume->setCallback(this);
  107. // about button
  108. Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight);
  109. Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight);
  110. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  111. fButtonAbout->setAbsolutePos(505, 5);
  112. fButtonAbout->setCallback(this);
  113. }
  114. // -----------------------------------------------------------------------
  115. // DSP Callbacks
  116. void DistrhoUINekobi::parameterChanged(uint32_t index, float value)
  117. {
  118. switch (index)
  119. {
  120. case DistrhoPluginNekobi::paramTuning:
  121. fKnobTuning->setValue(value);
  122. break;
  123. case DistrhoPluginNekobi::paramWaveform:
  124. fSliderWaveform->setValue(value);
  125. break;
  126. case DistrhoPluginNekobi::paramCutoff:
  127. fKnobCutoff->setValue(value);
  128. break;
  129. case DistrhoPluginNekobi::paramResonance:
  130. fKnobResonance->setValue(value);
  131. break;
  132. case DistrhoPluginNekobi::paramEnvMod:
  133. fKnobEnvMod->setValue(value);
  134. break;
  135. case DistrhoPluginNekobi::paramDecay:
  136. fKnobDecay->setValue(value);
  137. break;
  138. case DistrhoPluginNekobi::paramAccent:
  139. fKnobAccent->setValue(value);
  140. break;
  141. case DistrhoPluginNekobi::paramVolume:
  142. fKnobVolume->setValue(value);
  143. break;
  144. }
  145. }
  146. // -----------------------------------------------------------------------
  147. // UI Callbacks
  148. void DistrhoUINekobi::uiIdle()
  149. {
  150. if (fNeko.idle())
  151. repaint();
  152. }
  153. // -----------------------------------------------------------------------
  154. // Widget Callbacks
  155. void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int)
  156. {
  157. if (button != fButtonAbout)
  158. return;
  159. fAboutWindow.exec();
  160. }
  161. void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob)
  162. {
  163. editParameter(knob->getId(), true);
  164. }
  165. void DistrhoUINekobi::imageKnobDragFinished(ImageKnob* knob)
  166. {
  167. editParameter(knob->getId(), false);
  168. }
  169. void DistrhoUINekobi::imageKnobValueChanged(ImageKnob* knob, float value)
  170. {
  171. setParameterValue(knob->getId(), value);
  172. }
  173. void DistrhoUINekobi::imageSliderDragStarted(ImageSlider* slider)
  174. {
  175. editParameter(slider->getId(), true);
  176. }
  177. void DistrhoUINekobi::imageSliderDragFinished(ImageSlider* slider)
  178. {
  179. editParameter(slider->getId(), false);
  180. }
  181. void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value)
  182. {
  183. setParameterValue(slider->getId(), value);
  184. }
  185. void DistrhoUINekobi::onDisplay()
  186. {
  187. fImgBackground.draw();
  188. fNeko.draw();
  189. }
  190. // -----------------------------------------------------------------------
  191. UI* createUI()
  192. {
  193. return new DistrhoUINekobi();
  194. }
  195. // -----------------------------------------------------------------------
  196. END_NAMESPACE_DISTRHO