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.

235 lines
7.5KB

  1. /*
  2. * DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others.
  3. * Copyright (C) 2013-2015 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. START_NAMESPACE_DISTRHO
  20. // -----------------------------------------------------------------------
  21. DistrhoUINekobi::DistrhoUINekobi()
  22. : UI(),
  23. fAboutWindow(this)
  24. {
  25. // FIXME
  26. fNeko.setTimerSpeed(5);
  27. // set UI size
  28. setSize(DistrhoArtworkNekobi::backgroundWidth, DistrhoArtworkNekobi::backgroundHeight);
  29. // background
  30. fImgBackground = Image(DistrhoArtworkNekobi::backgroundData, DistrhoArtworkNekobi::backgroundWidth, DistrhoArtworkNekobi::backgroundHeight, GL_BGR);
  31. // about
  32. Image aboutImage(DistrhoArtworkNekobi::aboutData, DistrhoArtworkNekobi::aboutWidth, DistrhoArtworkNekobi::aboutHeight, GL_BGR);
  33. fAboutWindow.setImage(aboutImage);
  34. // slider
  35. Image sliderImage(DistrhoArtworkNekobi::sliderData, DistrhoArtworkNekobi::sliderWidth, DistrhoArtworkNekobi::sliderHeight);
  36. fSliderWaveform = new ImageSlider(this, sliderImage);
  37. fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform);
  38. fSliderWaveform->setStartPos(133, 40);
  39. fSliderWaveform->setEndPos(133, 60);
  40. fSliderWaveform->setRange(0.0f, 1.0f);
  41. fSliderWaveform->setStep(1.0f);
  42. fSliderWaveform->setValue(0.0f);
  43. fSliderWaveform->setCallback(this);
  44. // knobs
  45. Image knobImage(DistrhoArtworkNekobi::knobData, DistrhoArtworkNekobi::knobWidth, DistrhoArtworkNekobi::knobHeight);
  46. // knob Tuning
  47. fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  48. fKnobTuning->setId(DistrhoPluginNekobi::paramTuning);
  49. fKnobTuning->setAbsolutePos(41, 43);
  50. fKnobTuning->setRange(-12.0f, 12.0f);
  51. fKnobTuning->setDefault(0.0f);
  52. fKnobTuning->setValue(0.0f);
  53. fKnobTuning->setRotationAngle(305);
  54. fKnobTuning->setCallback(this);
  55. // knob Cutoff
  56. fKnobCutoff = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  57. fKnobCutoff->setId(DistrhoPluginNekobi::paramCutoff);
  58. fKnobCutoff->setAbsolutePos(185, 43);
  59. fKnobCutoff->setRange(0.0f, 100.0f);
  60. fKnobCutoff->setDefault(25.0f);
  61. fKnobCutoff->setValue(25.0f);
  62. fKnobCutoff->setRotationAngle(305);
  63. fKnobCutoff->setCallback(this);
  64. // knob Resonance
  65. fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  66. fKnobResonance->setId(DistrhoPluginNekobi::paramResonance);
  67. fKnobResonance->setAbsolutePos(257, 43);
  68. fKnobResonance->setRange(0.0f, 95.0f);
  69. fKnobResonance->setDefault(25.0f);
  70. fKnobResonance->setValue(25.0f);
  71. fKnobResonance->setRotationAngle(305);
  72. fKnobResonance->setCallback(this);
  73. // knob Env Mod
  74. fKnobEnvMod = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  75. fKnobEnvMod->setId(DistrhoPluginNekobi::paramEnvMod);
  76. fKnobEnvMod->setAbsolutePos(329, 43);
  77. fKnobEnvMod->setRange(0.0f, 100.0f);
  78. fKnobEnvMod->setDefault(50.0f);
  79. fKnobEnvMod->setValue(50.0f);
  80. fKnobEnvMod->setRotationAngle(305);
  81. fKnobEnvMod->setCallback(this);
  82. // knob Decay
  83. fKnobDecay = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  84. fKnobDecay->setId(DistrhoPluginNekobi::paramDecay);
  85. fKnobDecay->setAbsolutePos(400, 43);
  86. fKnobDecay->setRange(0.0f, 100.0f);
  87. fKnobDecay->setDefault(75.0f);
  88. fKnobDecay->setValue(75.0f);
  89. fKnobDecay->setRotationAngle(305);
  90. fKnobDecay->setCallback(this);
  91. // knob Accent
  92. fKnobAccent = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  93. fKnobAccent->setId(DistrhoPluginNekobi::paramAccent);
  94. fKnobAccent->setAbsolutePos(473, 43);
  95. fKnobAccent->setRange(0.0f, 100.0f);
  96. fKnobAccent->setDefault(25.0f);
  97. fKnobAccent->setValue(25.0f);
  98. fKnobAccent->setRotationAngle(305);
  99. fKnobAccent->setCallback(this);
  100. // knob Volume
  101. fKnobVolume = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  102. fKnobVolume->setId(DistrhoPluginNekobi::paramVolume);
  103. fKnobVolume->setAbsolutePos(545, 43);
  104. fKnobVolume->setRange(0.0f, 100.0f);
  105. fKnobVolume->setDefault(75.0f);
  106. fKnobVolume->setValue(75.0f);
  107. fKnobVolume->setRotationAngle(305);
  108. fKnobVolume->setCallback(this);
  109. // about button
  110. Image aboutImageNormal(DistrhoArtworkNekobi::aboutButtonNormalData, DistrhoArtworkNekobi::aboutButtonNormalWidth, DistrhoArtworkNekobi::aboutButtonNormalHeight);
  111. Image aboutImageHover(DistrhoArtworkNekobi::aboutButtonHoverData, DistrhoArtworkNekobi::aboutButtonHoverWidth, DistrhoArtworkNekobi::aboutButtonHoverHeight);
  112. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  113. fButtonAbout->setAbsolutePos(505, 5);
  114. fButtonAbout->setCallback(this);
  115. }
  116. // -----------------------------------------------------------------------
  117. // DSP Callbacks
  118. void DistrhoUINekobi::d_parameterChanged(uint32_t index, float value)
  119. {
  120. switch (index)
  121. {
  122. case DistrhoPluginNekobi::paramTuning:
  123. fKnobTuning->setValue(value);
  124. break;
  125. case DistrhoPluginNekobi::paramWaveform:
  126. fSliderWaveform->setValue(value);
  127. break;
  128. case DistrhoPluginNekobi::paramCutoff:
  129. fKnobCutoff->setValue(value);
  130. break;
  131. case DistrhoPluginNekobi::paramResonance:
  132. fKnobResonance->setValue(value);
  133. break;
  134. case DistrhoPluginNekobi::paramEnvMod:
  135. fKnobEnvMod->setValue(value);
  136. break;
  137. case DistrhoPluginNekobi::paramDecay:
  138. fKnobDecay->setValue(value);
  139. break;
  140. case DistrhoPluginNekobi::paramAccent:
  141. fKnobAccent->setValue(value);
  142. break;
  143. case DistrhoPluginNekobi::paramVolume:
  144. fKnobVolume->setValue(value);
  145. break;
  146. }
  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. d_editParameter(knob->getId(), true);
  166. }
  167. void DistrhoUINekobi::imageKnobDragFinished(ImageKnob* knob)
  168. {
  169. d_editParameter(knob->getId(), false);
  170. }
  171. void DistrhoUINekobi::imageKnobValueChanged(ImageKnob* knob, float value)
  172. {
  173. d_setParameterValue(knob->getId(), value);
  174. }
  175. void DistrhoUINekobi::imageSliderDragStarted(ImageSlider* slider)
  176. {
  177. d_editParameter(slider->getId(), true);
  178. }
  179. void DistrhoUINekobi::imageSliderDragFinished(ImageSlider* slider)
  180. {
  181. d_editParameter(slider->getId(), false);
  182. }
  183. void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value)
  184. {
  185. d_setParameterValue(slider->getId(), value);
  186. }
  187. void DistrhoUINekobi::onDisplay()
  188. {
  189. fImgBackground.draw();
  190. fNeko.draw();
  191. }
  192. // -----------------------------------------------------------------------
  193. UI* createUI()
  194. {
  195. return new DistrhoUINekobi();
  196. }
  197. // -----------------------------------------------------------------------
  198. END_NAMESPACE_DISTRHO