Collection of DPF-based plugins for packaging
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.

239 lines
7.4KB

  1. /*
  2. * DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others.
  3. * Copyright (C) 2013-2021 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. namespace Art = DistrhoArtworkNekobi;
  21. // -----------------------------------------------------------------------
  22. DistrhoUINekobi::DistrhoUINekobi()
  23. : UI(Art::backgroundWidth, Art::backgroundHeight, true),
  24. fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, kImageFormatBGR),
  25. fAboutWindow(this)
  26. {
  27. // about
  28. Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, kImageFormatBGR);
  29. fAboutWindow.setImage(aboutImage);
  30. // slider
  31. Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight, kImageFormatBGRA);
  32. fSliderWaveform = new ImageSlider(this, sliderImage);
  33. fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform);
  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(Art::knobData, Art::knobWidth, Art::knobHeight, kImageFormatBGRA);
  42. // knob Tuning
  43. fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  44. fKnobTuning->setId(DistrhoPluginNekobi::paramTuning);
  45. fKnobTuning->setAbsolutePos(41, 43);
  46. fKnobTuning->setRange(-12.0f, 12.0f);
  47. fKnobTuning->setDefault(0.0f);
  48. fKnobTuning->setValue(0.0f);
  49. fKnobTuning->setRotationAngle(305);
  50. fKnobTuning->setCallback(this);
  51. // knob Cutoff
  52. fKnobCutoff = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  53. fKnobCutoff->setId(DistrhoPluginNekobi::paramCutoff);
  54. fKnobCutoff->setAbsolutePos(185, 43);
  55. fKnobCutoff->setRange(0.0f, 100.0f);
  56. fKnobCutoff->setDefault(25.0f);
  57. fKnobCutoff->setValue(25.0f);
  58. fKnobCutoff->setRotationAngle(305);
  59. fKnobCutoff->setCallback(this);
  60. // knob Resonance
  61. fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  62. fKnobResonance->setId(DistrhoPluginNekobi::paramResonance);
  63. fKnobResonance->setAbsolutePos(257, 43);
  64. fKnobResonance->setRange(0.0f, 95.0f);
  65. fKnobResonance->setDefault(25.0f);
  66. fKnobResonance->setValue(25.0f);
  67. fKnobResonance->setRotationAngle(305);
  68. fKnobResonance->setCallback(this);
  69. // knob Env Mod
  70. fKnobEnvMod = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  71. fKnobEnvMod->setId(DistrhoPluginNekobi::paramEnvMod);
  72. fKnobEnvMod->setAbsolutePos(329, 43);
  73. fKnobEnvMod->setRange(0.0f, 100.0f);
  74. fKnobEnvMod->setDefault(50.0f);
  75. fKnobEnvMod->setValue(50.0f);
  76. fKnobEnvMod->setRotationAngle(305);
  77. fKnobEnvMod->setCallback(this);
  78. // knob Decay
  79. fKnobDecay = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  80. fKnobDecay->setId(DistrhoPluginNekobi::paramDecay);
  81. fKnobDecay->setAbsolutePos(400, 43);
  82. fKnobDecay->setRange(0.0f, 100.0f);
  83. fKnobDecay->setDefault(75.0f);
  84. fKnobDecay->setValue(75.0f);
  85. fKnobDecay->setRotationAngle(305);
  86. fKnobDecay->setCallback(this);
  87. // knob Accent
  88. fKnobAccent = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  89. fKnobAccent->setId(DistrhoPluginNekobi::paramAccent);
  90. fKnobAccent->setAbsolutePos(473, 43);
  91. fKnobAccent->setRange(0.0f, 100.0f);
  92. fKnobAccent->setDefault(25.0f);
  93. fKnobAccent->setValue(25.0f);
  94. fKnobAccent->setRotationAngle(305);
  95. fKnobAccent->setCallback(this);
  96. // knob Volume
  97. fKnobVolume = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  98. fKnobVolume->setId(DistrhoPluginNekobi::paramVolume);
  99. fKnobVolume->setAbsolutePos(545, 43);
  100. fKnobVolume->setRange(0.0f, 100.0f);
  101. fKnobVolume->setDefault(75.0f);
  102. fKnobVolume->setValue(75.0f);
  103. fKnobVolume->setRotationAngle(305);
  104. fKnobVolume->setCallback(this);
  105. // about button
  106. Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight, kImageFormatBGRA);
  107. Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight, kImageFormatBGRA);
  108. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  109. fButtonAbout->setAbsolutePos(505, 5);
  110. fButtonAbout->setCallback(this);
  111. // neko animation
  112. addIdleCallback(this, 120);
  113. }
  114. DistrhoUINekobi::~DistrhoUINekobi()
  115. {
  116. removeIdleCallback(this);
  117. }
  118. // -----------------------------------------------------------------------
  119. // DSP Callbacks
  120. void DistrhoUINekobi::parameterChanged(uint32_t index, float value)
  121. {
  122. switch (index)
  123. {
  124. case DistrhoPluginNekobi::paramTuning:
  125. fKnobTuning->setValue(value);
  126. break;
  127. case DistrhoPluginNekobi::paramWaveform:
  128. fSliderWaveform->setValue(value);
  129. break;
  130. case DistrhoPluginNekobi::paramCutoff:
  131. fKnobCutoff->setValue(value);
  132. break;
  133. case DistrhoPluginNekobi::paramResonance:
  134. fKnobResonance->setValue(value);
  135. break;
  136. case DistrhoPluginNekobi::paramEnvMod:
  137. fKnobEnvMod->setValue(value);
  138. break;
  139. case DistrhoPluginNekobi::paramDecay:
  140. fKnobDecay->setValue(value);
  141. break;
  142. case DistrhoPluginNekobi::paramAccent:
  143. fKnobAccent->setValue(value);
  144. break;
  145. case DistrhoPluginNekobi::paramVolume:
  146. fKnobVolume->setValue(value);
  147. break;
  148. }
  149. }
  150. // -----------------------------------------------------------------------
  151. // Widget Callbacks
  152. void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int)
  153. {
  154. if (button != fButtonAbout)
  155. return;
  156. fAboutWindow.runAsModal();
  157. }
  158. void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob)
  159. {
  160. editParameter(knob->getId(), true);
  161. }
  162. void DistrhoUINekobi::imageKnobDragFinished(ImageKnob* knob)
  163. {
  164. editParameter(knob->getId(), false);
  165. }
  166. void DistrhoUINekobi::imageKnobValueChanged(ImageKnob* knob, float value)
  167. {
  168. setParameterValue(knob->getId(), value);
  169. }
  170. void DistrhoUINekobi::imageSliderDragStarted(ImageSlider* slider)
  171. {
  172. editParameter(slider->getId(), true);
  173. }
  174. void DistrhoUINekobi::imageSliderDragFinished(ImageSlider* slider)
  175. {
  176. editParameter(slider->getId(), false);
  177. }
  178. void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value)
  179. {
  180. setParameterValue(slider->getId(), value);
  181. }
  182. void DistrhoUINekobi::onDisplay()
  183. {
  184. const GraphicsContext& context(getGraphicsContext());
  185. fImgBackground.draw(context);
  186. fNeko.draw(context);
  187. }
  188. // -----------------------------------------------------------------------
  189. // Other Callbacks
  190. void DistrhoUINekobi::idleCallback()
  191. {
  192. if (fNeko.idle())
  193. repaint();
  194. }
  195. // -----------------------------------------------------------------------
  196. UI* createUI()
  197. {
  198. return new DistrhoUINekobi();
  199. }
  200. // -----------------------------------------------------------------------
  201. END_NAMESPACE_DISTRHO