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.

DistrhoUINekobi.cpp 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. #ifndef DISTRHO_OS_MAC
  24. , fAboutWindow(this)
  25. #endif
  26. {
  27. // FIXME
  28. fNeko.setTimerSpeed(5);
  29. // set UI size
  30. setSize(DistrhoArtworkNekobi::backgroundWidth, DistrhoArtworkNekobi::backgroundHeight);
  31. // background
  32. fImgBackground = Image(DistrhoArtworkNekobi::backgroundData, DistrhoArtworkNekobi::backgroundWidth, DistrhoArtworkNekobi::backgroundHeight, GL_BGR);
  33. #ifndef DISTRHO_OS_MAC
  34. Image aboutImage(DistrhoArtworkNekobi::aboutData, DistrhoArtworkNekobi::aboutWidth, DistrhoArtworkNekobi::aboutHeight, GL_BGR);
  35. fAboutWindow.setImage(aboutImage);
  36. #endif
  37. // slider
  38. Image sliderImage(DistrhoArtworkNekobi::sliderData, DistrhoArtworkNekobi::sliderWidth, DistrhoArtworkNekobi::sliderHeight);
  39. fSliderWaveform = new ImageSlider(this, sliderImage);
  40. fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform);
  41. fSliderWaveform->setStartPos(133, 40);
  42. fSliderWaveform->setEndPos(133, 60);
  43. fSliderWaveform->setRange(0.0f, 1.0f);
  44. fSliderWaveform->setStep(1.0f);
  45. fSliderWaveform->setValue(0.0f);
  46. fSliderWaveform->setCallback(this);
  47. // knobs
  48. Image knobImage(DistrhoArtworkNekobi::knobData, DistrhoArtworkNekobi::knobWidth, DistrhoArtworkNekobi::knobHeight);
  49. // knob Tuning
  50. fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  51. fKnobTuning->setId(DistrhoPluginNekobi::paramTuning);
  52. fKnobTuning->setAbsolutePos(41, 43);
  53. fKnobTuning->setRange(-12.0f, 12.0f);
  54. fKnobTuning->setDefault(0.0f);
  55. fKnobTuning->setValue(0.0f);
  56. fKnobTuning->setRotationAngle(305);
  57. fKnobTuning->setCallback(this);
  58. // knob Cutoff
  59. fKnobCutoff = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  60. fKnobCutoff->setId(DistrhoPluginNekobi::paramCutoff);
  61. fKnobCutoff->setAbsolutePos(185, 43);
  62. fKnobCutoff->setRange(0.0f, 100.0f);
  63. fKnobCutoff->setDefault(25.0f);
  64. fKnobCutoff->setValue(25.0f);
  65. fKnobCutoff->setRotationAngle(305);
  66. fKnobCutoff->setCallback(this);
  67. // knob Resonance
  68. fKnobResonance = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  69. fKnobResonance->setId(DistrhoPluginNekobi::paramResonance);
  70. fKnobResonance->setAbsolutePos(257, 43);
  71. fKnobResonance->setRange(0.0f, 95.0f);
  72. fKnobResonance->setDefault(25.0f);
  73. fKnobResonance->setValue(25.0f);
  74. fKnobResonance->setRotationAngle(305);
  75. fKnobResonance->setCallback(this);
  76. // knob Env Mod
  77. fKnobEnvMod = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  78. fKnobEnvMod->setId(DistrhoPluginNekobi::paramEnvMod);
  79. fKnobEnvMod->setAbsolutePos(329, 43);
  80. fKnobEnvMod->setRange(0.0f, 100.0f);
  81. fKnobEnvMod->setDefault(50.0f);
  82. fKnobEnvMod->setValue(50.0f);
  83. fKnobEnvMod->setRotationAngle(305);
  84. fKnobEnvMod->setCallback(this);
  85. // knob Decay
  86. fKnobDecay = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  87. fKnobDecay->setId(DistrhoPluginNekobi::paramDecay);
  88. fKnobDecay->setAbsolutePos(400, 43);
  89. fKnobDecay->setRange(0.0f, 100.0f);
  90. fKnobDecay->setDefault(75.0f);
  91. fKnobDecay->setValue(75.0f);
  92. fKnobDecay->setRotationAngle(305);
  93. fKnobDecay->setCallback(this);
  94. // knob Accent
  95. fKnobAccent = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  96. fKnobAccent->setId(DistrhoPluginNekobi::paramAccent);
  97. fKnobAccent->setAbsolutePos(473, 43);
  98. fKnobAccent->setRange(0.0f, 100.0f);
  99. fKnobAccent->setDefault(25.0f);
  100. fKnobAccent->setValue(25.0f);
  101. fKnobAccent->setRotationAngle(305);
  102. fKnobAccent->setCallback(this);
  103. // knob Volume
  104. fKnobVolume = new ImageKnob(this, knobImage, ImageKnob::Vertical);
  105. fKnobVolume->setId(DistrhoPluginNekobi::paramVolume);
  106. fKnobVolume->setAbsolutePos(545, 43);
  107. fKnobVolume->setRange(0.0f, 100.0f);
  108. fKnobVolume->setDefault(75.0f);
  109. fKnobVolume->setValue(75.0f);
  110. fKnobVolume->setRotationAngle(305);
  111. fKnobVolume->setCallback(this);
  112. // about button
  113. Image aboutImageNormal(DistrhoArtworkNekobi::aboutButtonNormalData, DistrhoArtworkNekobi::aboutButtonNormalWidth, DistrhoArtworkNekobi::aboutButtonNormalHeight);
  114. Image aboutImageHover(DistrhoArtworkNekobi::aboutButtonHoverData, DistrhoArtworkNekobi::aboutButtonHoverWidth, DistrhoArtworkNekobi::aboutButtonHoverHeight);
  115. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  116. fButtonAbout->setAbsolutePos(505, 5);
  117. fButtonAbout->setCallback(this);
  118. }
  119. // -----------------------------------------------------------------------
  120. // DSP Callbacks
  121. void DistrhoUINekobi::d_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. // UI Callbacks
  153. void DistrhoUINekobi::d_uiIdle()
  154. {
  155. if (fNeko.idle())
  156. repaint();
  157. }
  158. // -----------------------------------------------------------------------
  159. // Widget Callbacks
  160. void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int)
  161. {
  162. if (button != fButtonAbout)
  163. return;
  164. #ifndef DISTRHO_OS_MAC
  165. fAboutWindow.exec();
  166. #endif
  167. }
  168. void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob)
  169. {
  170. d_editParameter(knob->getId(), true);
  171. }
  172. void DistrhoUINekobi::imageKnobDragFinished(ImageKnob* knob)
  173. {
  174. d_editParameter(knob->getId(), false);
  175. }
  176. void DistrhoUINekobi::imageKnobValueChanged(ImageKnob* knob, float value)
  177. {
  178. d_setParameterValue(knob->getId(), value);
  179. }
  180. void DistrhoUINekobi::imageSliderDragStarted(ImageSlider* slider)
  181. {
  182. d_editParameter(slider->getId(), true);
  183. }
  184. void DistrhoUINekobi::imageSliderDragFinished(ImageSlider* slider)
  185. {
  186. d_editParameter(slider->getId(), false);
  187. }
  188. void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value)
  189. {
  190. d_setParameterValue(slider->getId(), value);
  191. }
  192. void DistrhoUINekobi::onDisplay()
  193. {
  194. fImgBackground.draw();
  195. fNeko.draw();
  196. }
  197. // -----------------------------------------------------------------------
  198. UI* createUI()
  199. {
  200. return new DistrhoUINekobi();
  201. }
  202. // -----------------------------------------------------------------------
  203. END_NAMESPACE_DISTRHO