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.

295 lines
9.0KB

  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. // TODO - about png
  30. Image imageAbout(DistrhoArtworkNekobi::aboutButtonHoverData, DistrhoArtworkNekobi::aboutButtonHoverWidth, DistrhoArtworkNekobi::aboutButtonHoverHeight, GL_BGRA);
  31. fAboutWindow.setImage(imageAbout);
  32. // slider
  33. Image sliderImage(DistrhoArtworkNekobi::sliderData, DistrhoArtworkNekobi::sliderWidth, DistrhoArtworkNekobi::sliderHeight);
  34. fSliderWaveform = new ImageSlider(this, sliderImage);
  35. fSliderWaveform->setStartPos(133, 38);
  36. fSliderWaveform->setEndPos(133, 64);
  37. fSliderWaveform->setRange(0.0f, 1.0f);
  38. fSliderWaveform->setValue(0.0f);
  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(42, 45);
  45. fKnobTuning->setRange(-12.0f, 12.0f);
  46. fKnobTuning->setValue(0.0f);
  47. fKnobTuning->setCallback(this);
  48. // knob Cutoff
  49. fKnobCutoff = new ImageKnob(this, knobImage);
  50. fKnobCutoff->setPos(185, 45);
  51. fKnobCutoff->setRange(0.0f, 100.0f);
  52. fKnobCutoff->setValue(25.0f);
  53. fKnobCutoff->setCallback(this);
  54. // knob Resonance
  55. fKnobResonance = new ImageKnob(this, knobImage);
  56. fKnobResonance->setPos(258, 45);
  57. fKnobResonance->setRange(0.0f, 95.0f);
  58. fKnobResonance->setValue(25.0f);
  59. fKnobResonance->setCallback(this);
  60. // knob Env Mod
  61. fKnobEnvMod = new ImageKnob(this, knobImage);
  62. fKnobEnvMod->setPos(330, 45);
  63. fKnobEnvMod->setRange(0.0f, 100.0f);
  64. fKnobEnvMod->setValue(50.0f);
  65. fKnobEnvMod->setCallback(this);
  66. // knob Decay
  67. fKnobDecay = new ImageKnob(this, knobImage);
  68. fKnobDecay->setPos(402, 45);
  69. fKnobDecay->setRange(0.0f, 100.0f);
  70. fKnobDecay->setValue(75.0f);
  71. fKnobDecay->setCallback(this);
  72. // knob Accent
  73. fKnobAccent = new ImageKnob(this, knobImage);
  74. fKnobAccent->setPos(474, 45);
  75. fKnobAccent->setRange(0.0f, 100.0f);
  76. fKnobAccent->setValue(25.0f);
  77. fKnobAccent->setCallback(this);
  78. // knob Volume
  79. fKnobVolume = new ImageKnob(this, knobImage);
  80. fKnobVolume->setPos(546, 45);
  81. fKnobVolume->setRange(0.0f, 100.0f);
  82. fKnobVolume->setValue(75.0f);
  83. fKnobVolume->setCallback(this);
  84. // about button
  85. Image aboutImageNormal(DistrhoArtworkNekobi::aboutButtonNormalData, DistrhoArtworkNekobi::aboutButtonNormalWidth, DistrhoArtworkNekobi::aboutButtonNormalHeight);
  86. Image aboutImageHover(DistrhoArtworkNekobi::aboutButtonHoverData, DistrhoArtworkNekobi::aboutButtonHoverWidth, DistrhoArtworkNekobi::aboutButtonHoverHeight);
  87. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  88. fButtonAbout->setPos(500, 5);
  89. fButtonAbout->setCallback(this);
  90. }
  91. DistrhoUINekobi::~DistrhoUINekobi()
  92. {
  93. delete fSliderWaveform;
  94. delete fKnobTuning;
  95. delete fKnobCutoff;
  96. delete fKnobResonance;
  97. delete fKnobEnvMod;
  98. delete fKnobDecay;
  99. delete fKnobAccent;
  100. delete fKnobVolume;
  101. delete fButtonAbout;
  102. }
  103. // -------------------------------------------------
  104. // DSP Callbacks
  105. void DistrhoUINekobi::d_parameterChanged(uint32_t index, float value)
  106. {
  107. switch (index)
  108. {
  109. case DistrhoPluginNekobi::paramTuning:
  110. fKnobTuning->setValue(value);
  111. break;
  112. case DistrhoPluginNekobi::paramWaveform:
  113. fSliderWaveform->setValue(value);
  114. break;
  115. case DistrhoPluginNekobi::paramCutoff:
  116. fKnobCutoff->setValue(value);
  117. break;
  118. case DistrhoPluginNekobi::paramResonance:
  119. fKnobResonance->setValue(value);
  120. break;
  121. case DistrhoPluginNekobi::paramEnvMod:
  122. fKnobEnvMod->setValue(value);
  123. break;
  124. case DistrhoPluginNekobi::paramDecay:
  125. fKnobDecay->setValue(value);
  126. break;
  127. case DistrhoPluginNekobi::paramAccent:
  128. fKnobAccent->setValue(value);
  129. break;
  130. case DistrhoPluginNekobi::paramVolume:
  131. fKnobVolume->setValue(value);
  132. break;
  133. }
  134. }
  135. void DistrhoUINekobi::d_programChanged(uint32_t index)
  136. {
  137. if (index != 0)
  138. return;
  139. // Default values
  140. fSliderWaveform->setValue(0.0f);
  141. fKnobTuning->setValue(0.0f);
  142. fKnobCutoff->setValue(25.0f);
  143. fKnobResonance->setValue(25.0f);
  144. fKnobEnvMod->setValue(50.0f);
  145. fKnobDecay->setValue(75.0f);
  146. fKnobAccent->setValue(25.0f);
  147. fKnobVolume->setValue(75.0f);
  148. }
  149. void DistrhoUINekobi::d_noteReceived(bool onOff, uint8_t, uint8_t note, uint8_t)
  150. {
  151. return;
  152. (void)onOff;
  153. (void)note;
  154. }
  155. // ---------------------------------------------
  156. // UI Callbacks
  157. void DistrhoUINekobi::d_uiIdle()
  158. {
  159. if (fNeko.idle())
  160. repaint();
  161. }
  162. // -------------------------------------------------
  163. // Widget Callbacks
  164. void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int)
  165. {
  166. if (button != fButtonAbout)
  167. return;
  168. fAboutWindow.exec();
  169. }
  170. void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob)
  171. {
  172. if (knob == fKnobTuning)
  173. d_editParameter(DistrhoPluginNekobi::paramTuning, true);
  174. else if (knob == fKnobCutoff)
  175. d_editParameter(DistrhoPluginNekobi::paramCutoff, true);
  176. else if (knob == fKnobResonance)
  177. d_editParameter(DistrhoPluginNekobi::paramResonance, true);
  178. else if (knob == fKnobEnvMod)
  179. d_editParameter(DistrhoPluginNekobi::paramEnvMod, true);
  180. else if (knob == fKnobDecay)
  181. d_editParameter(DistrhoPluginNekobi::paramDecay, true);
  182. else if (knob == fKnobAccent)
  183. d_editParameter(DistrhoPluginNekobi::paramAccent, true);
  184. else if (knob == fKnobVolume)
  185. d_editParameter(DistrhoPluginNekobi::paramVolume, true);
  186. }
  187. void DistrhoUINekobi::imageKnobDragFinished(ImageKnob* knob)
  188. {
  189. if (knob == fKnobTuning)
  190. d_editParameter(DistrhoPluginNekobi::paramTuning, false);
  191. else if (knob == fKnobCutoff)
  192. d_editParameter(DistrhoPluginNekobi::paramCutoff, false);
  193. else if (knob == fKnobResonance)
  194. d_editParameter(DistrhoPluginNekobi::paramResonance, false);
  195. else if (knob == fKnobEnvMod)
  196. d_editParameter(DistrhoPluginNekobi::paramEnvMod, false);
  197. else if (knob == fKnobDecay)
  198. d_editParameter(DistrhoPluginNekobi::paramDecay, false);
  199. else if (knob == fKnobAccent)
  200. d_editParameter(DistrhoPluginNekobi::paramAccent, false);
  201. else if (knob == fKnobVolume)
  202. d_editParameter(DistrhoPluginNekobi::paramVolume, false);
  203. }
  204. void DistrhoUINekobi::imageKnobValueChanged(ImageKnob* knob, float value)
  205. {
  206. if (knob == fKnobTuning)
  207. d_setParameterValue(DistrhoPluginNekobi::paramTuning, value);
  208. else if (knob == fKnobCutoff)
  209. d_setParameterValue(DistrhoPluginNekobi::paramCutoff, value);
  210. else if (knob == fKnobResonance)
  211. d_setParameterValue(DistrhoPluginNekobi::paramResonance, value);
  212. else if (knob == fKnobEnvMod)
  213. d_setParameterValue(DistrhoPluginNekobi::paramEnvMod, value);
  214. else if (knob == fKnobDecay)
  215. d_setParameterValue(DistrhoPluginNekobi::paramDecay, value);
  216. else if (knob == fKnobAccent)
  217. d_setParameterValue(DistrhoPluginNekobi::paramAccent, value);
  218. else if (knob == fKnobVolume)
  219. d_setParameterValue(DistrhoPluginNekobi::paramVolume, value);
  220. }
  221. void DistrhoUINekobi::imageSliderDragStarted(ImageSlider* slider)
  222. {
  223. if (slider != fSliderWaveform)
  224. return;
  225. d_editParameter(DistrhoPluginNekobi::paramWaveform, true);
  226. }
  227. void DistrhoUINekobi::imageSliderDragFinished(ImageSlider* slider)
  228. {
  229. if (slider != fSliderWaveform)
  230. return;
  231. d_editParameter(DistrhoPluginNekobi::paramWaveform, false);
  232. }
  233. void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value)
  234. {
  235. if (slider != fSliderWaveform)
  236. return;
  237. d_setParameterValue(DistrhoPluginNekobi::paramWaveform, value);
  238. }
  239. void DistrhoUINekobi::onDisplay()
  240. {
  241. fImgBackground.draw();
  242. fNeko.draw();
  243. }
  244. // -------------------------------------------------
  245. UI* createUI()
  246. {
  247. return new DistrhoUINekobi();
  248. }
  249. // -------------------------------------------------
  250. END_NAMESPACE_DISTRHO