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.

286 lines
8.9KB

  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(270);
  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(270);
  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(270);
  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(270);
  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(270);
  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(270);
  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(270);
  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