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.

223 lines
7.2KB

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