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.

280 lines
8.2KB

  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. {
  24. Window* win = getParent();
  25. fNeko.setTimerSpeed(4);
  26. // background
  27. fImgBackground = Image(DistrhoArtworkNekobi::backgroundData, DistrhoArtworkNekobi::backgroundWidth, DistrhoArtworkNekobi::backgroundHeight, GL_BGR);
  28. // slider
  29. Image sliderImage(DistrhoArtworkNekobi::sliderData, DistrhoArtworkNekobi::sliderWidth, DistrhoArtworkNekobi::sliderHeight);
  30. fSliderWaveform = new ImageSlider(win, sliderImage);
  31. fSliderWaveform->setStartPos(135, 39);
  32. fSliderWaveform->setEndPos(135, 65);
  33. fSliderWaveform->setRange(0.0f, 1.0f);
  34. fSliderWaveform->setValue(0.0f);
  35. fSliderWaveform->setCallback(this);
  36. // knobs
  37. Image knobImage(DistrhoArtworkNekobi::knobData, DistrhoArtworkNekobi::knobWidth, DistrhoArtworkNekobi::knobHeight);
  38. // knob Tuning
  39. fKnobTuning = new ImageKnob(win, knobImage);
  40. fKnobTuning->setPos(44, 46);
  41. fKnobTuning->setRange(-12.0f, 12.0f);
  42. fKnobTuning->setValue(0.0f);
  43. fKnobTuning->setCallback(this);
  44. // knob Cutoff
  45. fKnobCutoff = new ImageKnob(win, knobImage);
  46. fKnobCutoff->setPos(187, 46);
  47. fKnobCutoff->setRange(0.0f, 100.0f);
  48. fKnobCutoff->setValue(25.0f);
  49. fKnobCutoff->setCallback(this);
  50. // knob Resonance
  51. fKnobResonance = new ImageKnob(win, knobImage);
  52. fKnobResonance->setPos(260, 46);
  53. fKnobResonance->setRange(0.0f, 95.0f);
  54. fKnobResonance->setValue(25.0f);
  55. fKnobResonance->setCallback(this);
  56. // knob Env Mod
  57. fKnobEnvMod = new ImageKnob(win, knobImage);
  58. fKnobEnvMod->setPos(332, 46);
  59. fKnobEnvMod->setRange(0.0f, 100.0f);
  60. fKnobEnvMod->setValue(50.0f);
  61. fKnobEnvMod->setCallback(this);
  62. // knob Decay
  63. fKnobDecay = new ImageKnob(win, knobImage);
  64. fKnobDecay->setPos(404, 46);
  65. fKnobDecay->setRange(0.0f, 100.0f);
  66. fKnobDecay->setValue(75.0f);
  67. fKnobDecay->setCallback(this);
  68. // knob Accent
  69. fKnobAccent = new ImageKnob(win, knobImage);
  70. fKnobAccent->setPos(476, 46);
  71. fKnobAccent->setRange(0.0f, 100.0f);
  72. fKnobAccent->setValue(25.0f);
  73. fKnobAccent->setCallback(this);
  74. // knob Volume
  75. fKnobVolume = new ImageKnob(win, knobImage);
  76. fKnobVolume->setPos(548, 46);
  77. fKnobVolume->setRange(0.0f, 100.0f);
  78. fKnobVolume->setValue(75.0f);
  79. fKnobVolume->setCallback(this);
  80. }
  81. DistrhoUINekobi::~DistrhoUINekobi()
  82. {
  83. delete fSliderWaveform;
  84. delete fKnobTuning;
  85. delete fKnobCutoff;
  86. delete fKnobResonance;
  87. delete fKnobEnvMod;
  88. delete fKnobDecay;
  89. delete fKnobAccent;
  90. delete fKnobVolume;
  91. }
  92. // -------------------------------------------------
  93. // DSP Callbacks
  94. void DistrhoUINekobi::d_parameterChanged(uint32_t index, float value)
  95. {
  96. switch (index)
  97. {
  98. case DistrhoPluginNekobi::paramTuning:
  99. fKnobTuning->setValue(value);
  100. break;
  101. case DistrhoPluginNekobi::paramWaveform:
  102. fSliderWaveform->setValue(value);
  103. break;
  104. case DistrhoPluginNekobi::paramCutoff:
  105. fKnobCutoff->setValue(value);
  106. break;
  107. case DistrhoPluginNekobi::paramResonance:
  108. fKnobResonance->setValue(value);
  109. break;
  110. case DistrhoPluginNekobi::paramEnvMod:
  111. fKnobEnvMod->setValue(value);
  112. break;
  113. case DistrhoPluginNekobi::paramDecay:
  114. fKnobDecay->setValue(value);
  115. break;
  116. case DistrhoPluginNekobi::paramAccent:
  117. fKnobAccent->setValue(value);
  118. break;
  119. case DistrhoPluginNekobi::paramVolume:
  120. fKnobVolume->setValue(value);
  121. break;
  122. }
  123. }
  124. void DistrhoUINekobi::d_programChanged(uint32_t index)
  125. {
  126. if (index != 0)
  127. return;
  128. // Default values
  129. fSliderWaveform->setValue(0.0f);
  130. fKnobTuning->setValue(0.0f);
  131. fKnobCutoff->setValue(25.0f);
  132. fKnobResonance->setValue(25.0f);
  133. fKnobEnvMod->setValue(50.0f);
  134. fKnobDecay->setValue(75.0f);
  135. fKnobAccent->setValue(25.0f);
  136. fKnobVolume->setValue(50.0f);
  137. }
  138. void DistrhoUINekobi::d_noteReceived(bool onOff, uint8_t, uint8_t note, uint8_t)
  139. {
  140. return;
  141. (void)onOff;
  142. (void)note;
  143. }
  144. // ---------------------------------------------
  145. // UI Callbacks
  146. void DistrhoUINekobi::d_uiIdle()
  147. {
  148. if (fNeko.idle())
  149. repaint();
  150. }
  151. // -------------------------------------------------
  152. // Widget Callbacks
  153. void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int)
  154. {
  155. (void)button;
  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