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.

240 lines
7.4KB

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