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.

278 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 doc/GPL.txt file.
  16. */
  17. #include "DistrhoUINekobi.hpp"
  18. using DGL::Point;
  19. START_NAMESPACE_DISTRHO
  20. // -----------------------------------------------------------------------
  21. DistrhoUINekobi::DistrhoUINekobi()
  22. : UI(),
  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->setStep(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(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. // -----------------------------------------------------------------------
  143. // UI Callbacks
  144. void DistrhoUINekobi::d_uiIdle()
  145. {
  146. if (fNeko.idle())
  147. repaint();
  148. }
  149. // -----------------------------------------------------------------------
  150. // Widget Callbacks
  151. void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int)
  152. {
  153. if (button != fButtonAbout)
  154. return;
  155. fAboutWindow.exec();
  156. }
  157. void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob)
  158. {
  159. if (knob == fKnobTuning)
  160. d_editParameter(DistrhoPluginNekobi::paramTuning, true);
  161. else if (knob == fKnobCutoff)
  162. d_editParameter(DistrhoPluginNekobi::paramCutoff, true);
  163. else if (knob == fKnobResonance)
  164. d_editParameter(DistrhoPluginNekobi::paramResonance, true);
  165. else if (knob == fKnobEnvMod)
  166. d_editParameter(DistrhoPluginNekobi::paramEnvMod, true);
  167. else if (knob == fKnobDecay)
  168. d_editParameter(DistrhoPluginNekobi::paramDecay, true);
  169. else if (knob == fKnobAccent)
  170. d_editParameter(DistrhoPluginNekobi::paramAccent, true);
  171. else if (knob == fKnobVolume)
  172. d_editParameter(DistrhoPluginNekobi::paramVolume, true);
  173. }
  174. void DistrhoUINekobi::imageKnobDragFinished(ImageKnob* knob)
  175. {
  176. if (knob == fKnobTuning)
  177. d_editParameter(DistrhoPluginNekobi::paramTuning, false);
  178. else if (knob == fKnobCutoff)
  179. d_editParameter(DistrhoPluginNekobi::paramCutoff, false);
  180. else if (knob == fKnobResonance)
  181. d_editParameter(DistrhoPluginNekobi::paramResonance, false);
  182. else if (knob == fKnobEnvMod)
  183. d_editParameter(DistrhoPluginNekobi::paramEnvMod, false);
  184. else if (knob == fKnobDecay)
  185. d_editParameter(DistrhoPluginNekobi::paramDecay, false);
  186. else if (knob == fKnobAccent)
  187. d_editParameter(DistrhoPluginNekobi::paramAccent, false);
  188. else if (knob == fKnobVolume)
  189. d_editParameter(DistrhoPluginNekobi::paramVolume, false);
  190. }
  191. void DistrhoUINekobi::imageKnobValueChanged(ImageKnob* knob, float value)
  192. {
  193. if (knob == fKnobTuning)
  194. d_setParameterValue(DistrhoPluginNekobi::paramTuning, value);
  195. else if (knob == fKnobCutoff)
  196. d_setParameterValue(DistrhoPluginNekobi::paramCutoff, value);
  197. else if (knob == fKnobResonance)
  198. d_setParameterValue(DistrhoPluginNekobi::paramResonance, value);
  199. else if (knob == fKnobEnvMod)
  200. d_setParameterValue(DistrhoPluginNekobi::paramEnvMod, value);
  201. else if (knob == fKnobDecay)
  202. d_setParameterValue(DistrhoPluginNekobi::paramDecay, value);
  203. else if (knob == fKnobAccent)
  204. d_setParameterValue(DistrhoPluginNekobi::paramAccent, value);
  205. else if (knob == fKnobVolume)
  206. d_setParameterValue(DistrhoPluginNekobi::paramVolume, value);
  207. }
  208. void DistrhoUINekobi::imageSliderDragStarted(ImageSlider* slider)
  209. {
  210. if (slider != fSliderWaveform)
  211. return;
  212. d_editParameter(DistrhoPluginNekobi::paramWaveform, true);
  213. }
  214. void DistrhoUINekobi::imageSliderDragFinished(ImageSlider* slider)
  215. {
  216. if (slider != fSliderWaveform)
  217. return;
  218. d_editParameter(DistrhoPluginNekobi::paramWaveform, false);
  219. }
  220. void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value)
  221. {
  222. if (slider != fSliderWaveform)
  223. return;
  224. d_setParameterValue(DistrhoPluginNekobi::paramWaveform, value);
  225. }
  226. void DistrhoUINekobi::onDisplay()
  227. {
  228. fImgBackground.draw();
  229. fNeko.draw();
  230. }
  231. // -----------------------------------------------------------------------
  232. UI* createUI()
  233. {
  234. return new DistrhoUINekobi();
  235. }
  236. // -----------------------------------------------------------------------
  237. END_NAMESPACE_DISTRHO