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.5KB

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