DISTRHO Nekobi
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.

266 lines
8.6KB

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