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

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others.
  3. * Copyright (C) 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 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 GPL.txt file
  16. */
  17. #include "DistrhoUINekobi.hpp"
  18. #include "dgl/ImageAboutWindow.hpp"
  19. START_NAMESPACE_DISTRHO
  20. // -------------------------------------------------
  21. DistrhoUINekobi::DistrhoUINekobi()
  22. : OpenGLUI(),
  23. fAboutWindow(this)
  24. {
  25. // FIXME
  26. fNeko.setTimerSpeed(4);
  27. // background
  28. fImgBackground = Image(DistrhoArtworkNekobi::backgroundData, DistrhoArtworkNekobi::backgroundWidth, DistrhoArtworkNekobi::backgroundHeight, GL_BGR);
  29. Image imageAbout(DistrhoArtworkNekobi::aboutData, DistrhoArtworkNekobi::aboutWidth, DistrhoArtworkNekobi::aboutHeight, GL_BGR);
  30. fAboutWindow.setImage(imageAbout);
  31. // slider
  32. Image sliderImage(DistrhoArtworkNekobi::sliderData, DistrhoArtworkNekobi::sliderWidth, DistrhoArtworkNekobi::sliderHeight);
  33. fSliderWaveform = new ImageSlider(this, sliderImage);
  34. fSliderWaveform->setStartPos(133, 40);
  35. fSliderWaveform->setEndPos(133, 60);
  36. fSliderWaveform->setRange(0.0f, 1.0f);
  37. fSliderWaveform->setValue(0.0f);
  38. fSliderWaveform->setIsSwitch(true);
  39. fSliderWaveform->setCallback(this);
  40. // knobs
  41. Image knobImage(DistrhoArtworkNekobi::knobData, DistrhoArtworkNekobi::knobWidth, DistrhoArtworkNekobi::knobHeight);
  42. // knob Tuning
  43. fKnobTuning = new ImageKnob(this, knobImage);
  44. fKnobTuning->setPos(41, 43);
  45. fKnobTuning->setRange(-12.0f, 12.0f);
  46. fKnobTuning->setValue(0.0f);
  47. fKnobTuning->setRotationAngle(305);
  48. fKnobTuning->setCallback(this);
  49. // knob Cutoff
  50. fKnobCutoff = new ImageKnob(this, knobImage);
  51. fKnobCutoff->setPos(185, 43);
  52. fKnobCutoff->setRange(0.0f, 100.0f);
  53. fKnobCutoff->setValue(25.0f);
  54. fKnobCutoff->setRotationAngle(305);
  55. fKnobCutoff->setCallback(this);
  56. // knob Resonance
  57. fKnobResonance = new ImageKnob(this, knobImage);
  58. fKnobResonance->setPos(257, 43);
  59. fKnobResonance->setRange(0.0f, 95.0f);
  60. fKnobResonance->setValue(25.0f);
  61. fKnobResonance->setRotationAngle(305);
  62. fKnobResonance->setCallback(this);
  63. // knob Env Mod
  64. fKnobEnvMod = new ImageKnob(this, knobImage);
  65. fKnobEnvMod->setPos(329, 43);
  66. fKnobEnvMod->setRange(0.0f, 100.0f);
  67. fKnobEnvMod->setValue(50.0f);
  68. fKnobEnvMod->setRotationAngle(305);
  69. fKnobEnvMod->setCallback(this);
  70. // knob Decay
  71. fKnobDecay = new ImageKnob(this, knobImage);
  72. fKnobDecay->setPos(400, 43);
  73. fKnobDecay->setRange(0.0f, 100.0f);
  74. fKnobDecay->setValue(75.0f);
  75. fKnobDecay->setRotationAngle(305);
  76. fKnobDecay->setCallback(this);
  77. // knob Accent
  78. fKnobAccent = new ImageKnob(this, knobImage);
  79. fKnobAccent->setPos(473, 43);
  80. fKnobAccent->setRange(0.0f, 100.0f);
  81. fKnobAccent->setValue(25.0f);
  82. fKnobAccent->setRotationAngle(305);
  83. fKnobAccent->setCallback(this);
  84. // knob Volume
  85. fKnobVolume = new ImageKnob(this, knobImage);
  86. fKnobVolume->setPos(545, 43);
  87. fKnobVolume->setRange(0.0f, 100.0f);
  88. fKnobVolume->setValue(75.0f);
  89. fKnobVolume->setRotationAngle(305);
  90. fKnobVolume->setCallback(this);
  91. // about button
  92. Image aboutImageNormal(DistrhoArtworkNekobi::aboutButtonNormalData, DistrhoArtworkNekobi::aboutButtonNormalWidth, DistrhoArtworkNekobi::aboutButtonNormalHeight);
  93. Image aboutImageHover(DistrhoArtworkNekobi::aboutButtonHoverData, DistrhoArtworkNekobi::aboutButtonHoverWidth, DistrhoArtworkNekobi::aboutButtonHoverHeight);
  94. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  95. fButtonAbout->setPos(505, 5);
  96. fButtonAbout->setCallback(this);
  97. }
  98. DistrhoUINekobi::~DistrhoUINekobi()
  99. {
  100. delete fSliderWaveform;
  101. delete fKnobTuning;
  102. delete fKnobCutoff;
  103. delete fKnobResonance;
  104. delete fKnobEnvMod;
  105. delete fKnobDecay;
  106. delete fKnobAccent;
  107. delete fKnobVolume;
  108. delete fButtonAbout;
  109. }
  110. // -------------------------------------------------
  111. // DSP Callbacks
  112. void DistrhoUINekobi::d_parameterChanged(uint32_t index, float value)
  113. {
  114. switch (index)
  115. {
  116. case DistrhoPluginNekobi::paramTuning:
  117. fKnobTuning->setValue(value);
  118. break;
  119. case DistrhoPluginNekobi::paramWaveform:
  120. fSliderWaveform->setValue(value);
  121. break;
  122. case DistrhoPluginNekobi::paramCutoff:
  123. fKnobCutoff->setValue(value);
  124. break;
  125. case DistrhoPluginNekobi::paramResonance:
  126. fKnobResonance->setValue(value);
  127. break;
  128. case DistrhoPluginNekobi::paramEnvMod:
  129. fKnobEnvMod->setValue(value);
  130. break;
  131. case DistrhoPluginNekobi::paramDecay:
  132. fKnobDecay->setValue(value);
  133. break;
  134. case DistrhoPluginNekobi::paramAccent:
  135. fKnobAccent->setValue(value);
  136. break;
  137. case DistrhoPluginNekobi::paramVolume:
  138. fKnobVolume->setValue(value);
  139. break;
  140. }
  141. }
  142. void DistrhoUINekobi::d_noteReceived(bool onOff, uint8_t, uint8_t note, uint8_t)
  143. {
  144. return;
  145. (void)onOff;
  146. (void)note;
  147. }
  148. // ---------------------------------------------
  149. // UI Callbacks
  150. void DistrhoUINekobi::d_uiIdle()
  151. {
  152. if (fNeko.idle())
  153. repaint();
  154. }
  155. // -------------------------------------------------
  156. // Widget Callbacks
  157. void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int)
  158. {
  159. if (button != fButtonAbout)
  160. return;
  161. fAboutWindow.exec();
  162. }
  163. void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob)
  164. {
  165. if (knob == fKnobTuning)
  166. d_editParameter(DistrhoPluginNekobi::paramTuning, true);
  167. else if (knob == fKnobCutoff)
  168. d_editParameter(DistrhoPluginNekobi::paramCutoff, true);
  169. else if (knob == fKnobResonance)
  170. d_editParameter(DistrhoPluginNekobi::paramResonance, true);
  171. else if (knob == fKnobEnvMod)
  172. d_editParameter(DistrhoPluginNekobi::paramEnvMod, true);
  173. else if (knob == fKnobDecay)
  174. d_editParameter(DistrhoPluginNekobi::paramDecay, true);
  175. else if (knob == fKnobAccent)
  176. d_editParameter(DistrhoPluginNekobi::paramAccent, true);
  177. else if (knob == fKnobVolume)
  178. d_editParameter(DistrhoPluginNekobi::paramVolume, true);
  179. }
  180. void DistrhoUINekobi::imageKnobDragFinished(ImageKnob* knob)
  181. {
  182. if (knob == fKnobTuning)
  183. d_editParameter(DistrhoPluginNekobi::paramTuning, false);
  184. else if (knob == fKnobCutoff)
  185. d_editParameter(DistrhoPluginNekobi::paramCutoff, false);
  186. else if (knob == fKnobResonance)
  187. d_editParameter(DistrhoPluginNekobi::paramResonance, false);
  188. else if (knob == fKnobEnvMod)
  189. d_editParameter(DistrhoPluginNekobi::paramEnvMod, false);
  190. else if (knob == fKnobDecay)
  191. d_editParameter(DistrhoPluginNekobi::paramDecay, false);
  192. else if (knob == fKnobAccent)
  193. d_editParameter(DistrhoPluginNekobi::paramAccent, false);
  194. else if (knob == fKnobVolume)
  195. d_editParameter(DistrhoPluginNekobi::paramVolume, false);
  196. }
  197. void DistrhoUINekobi::imageKnobValueChanged(ImageKnob* knob, float value)
  198. {
  199. if (knob == fKnobTuning)
  200. d_setParameterValue(DistrhoPluginNekobi::paramTuning, value);
  201. else if (knob == fKnobCutoff)
  202. d_setParameterValue(DistrhoPluginNekobi::paramCutoff, value);
  203. else if (knob == fKnobResonance)
  204. d_setParameterValue(DistrhoPluginNekobi::paramResonance, value);
  205. else if (knob == fKnobEnvMod)
  206. d_setParameterValue(DistrhoPluginNekobi::paramEnvMod, value);
  207. else if (knob == fKnobDecay)
  208. d_setParameterValue(DistrhoPluginNekobi::paramDecay, value);
  209. else if (knob == fKnobAccent)
  210. d_setParameterValue(DistrhoPluginNekobi::paramAccent, value);
  211. else if (knob == fKnobVolume)
  212. d_setParameterValue(DistrhoPluginNekobi::paramVolume, value);
  213. }
  214. void DistrhoUINekobi::imageSliderDragStarted(ImageSlider* slider)
  215. {
  216. if (slider != fSliderWaveform)
  217. return;
  218. d_editParameter(DistrhoPluginNekobi::paramWaveform, true);
  219. }
  220. void DistrhoUINekobi::imageSliderDragFinished(ImageSlider* slider)
  221. {
  222. if (slider != fSliderWaveform)
  223. return;
  224. d_editParameter(DistrhoPluginNekobi::paramWaveform, false);
  225. }
  226. void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value)
  227. {
  228. if (slider != fSliderWaveform)
  229. return;
  230. d_setParameterValue(DistrhoPluginNekobi::paramWaveform, value);
  231. }
  232. void DistrhoUINekobi::onDisplay()
  233. {
  234. fImgBackground.draw();
  235. fNeko.draw();
  236. }
  237. // -------------------------------------------------
  238. UI* createUI()
  239. {
  240. return new DistrhoUINekobi();
  241. }
  242. // -------------------------------------------------
  243. END_NAMESPACE_DISTRHO