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.

162 lines
4.2KB

  1. /*
  2. * Vector Juice Plugin
  3. * Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
  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 doc/GPL.txt file.
  16. */
  17. #ifndef GROOVEJUICEUI_HPP_INCLUDED
  18. #define GROOVEJUICEUI_HPP_INCLUDED
  19. #include "DistrhoUI.hpp"
  20. #include "Geometry.hpp"
  21. #include "ImageAboutWindow.hpp"
  22. #include "ImageButton.hpp"
  23. #include "ImageKnob.hpp"
  24. #include "ImageSlider.hpp"
  25. #include "GrooveJuiceArtwork.hpp"
  26. #include "GrooveJuicePlugin.hpp"
  27. using DGL::Image;
  28. using DGL::ImageAboutWindow;
  29. using DGL::ImageButton;
  30. using DGL::ImageKnob;
  31. using DGL::ImageSlider;
  32. using DGL::Rectangle;
  33. START_NAMESPACE_DISTRHO
  34. // -----------------------------------------------------------------------
  35. class GrooveJuiceUI : public UI,
  36. public ImageButton::Callback,
  37. public ImageKnob::Callback,
  38. public ImageSlider::Callback
  39. {
  40. public:
  41. GrooveJuiceUI();
  42. ~GrooveJuiceUI() override;
  43. protected:
  44. // -------------------------------------------------------------------
  45. // Information
  46. unsigned int d_getWidth() const noexcept override
  47. {
  48. return GrooveJuiceArtwork::backgroundWidth;
  49. }
  50. unsigned int d_getHeight() const noexcept override
  51. {
  52. return GrooveJuiceArtwork::backgroundHeight;
  53. }
  54. // -------------------------------------------------------------------
  55. // DSP Callbacks
  56. void d_parameterChanged(uint32_t index, float value) override;
  57. void d_programChanged(uint32_t index) override;
  58. // -------------------------------------------------------------------
  59. // Widget Callbacks
  60. void imageButtonClicked(ImageButton* button, int) override;
  61. void imageKnobDragStarted(ImageKnob* knob) override;
  62. void imageKnobDragFinished(ImageKnob* knob) override;
  63. void imageKnobValueChanged(ImageKnob* knob, float value) override;
  64. void imageSliderDragStarted(ImageSlider* slider) override;
  65. void imageSliderDragFinished(ImageSlider* slider) override;
  66. void imageSliderValueChanged(ImageSlider* slider, float value) override;
  67. void onDisplay() override;
  68. bool onMouse(int button, bool press, int x, int y) override;
  69. bool onMotion(int x, int y) override;
  70. private:
  71. float paramX, paramY;
  72. Image fImgBackground;
  73. Image fImgRoundlet;
  74. Image fImgOrbit;
  75. Image fImgSubOrbit;
  76. ImageAboutWindow fAboutWindow;
  77. //knobs
  78. ImageKnob* fKnobOrbitSpeedX;
  79. ImageKnob* fKnobOrbitSpeedY;
  80. ImageKnob* fKnobOrbitSizeX;
  81. ImageKnob* fKnobOrbitSizeY;
  82. ImageKnob* fKnobSubOrbitSpeed;
  83. ImageKnob* fKnobSubOrbitSize;
  84. ImageKnob* fKnobSubOrbitSmooth;
  85. ImageKnob* fKnobsSynth[8];
  86. int page;
  87. struct square {
  88. float timer;
  89. float maxTimer;
  90. int x;
  91. int y;
  92. int size;
  93. } squares[8][8];
  94. //sliders
  95. ImageSlider* fSliderOrbitWaveX;
  96. ImageSlider* fSliderOrbitWaveY;
  97. ImageSlider* fSliderOrbitPhaseX;
  98. ImageSlider* fSliderOrbitPhaseY;
  99. ImageButton* fButtonAbout;
  100. ImageButton* fButtonRandomize;
  101. ImageButton* fButtonsPage[8];
  102. int tabOX;
  103. int tabOY;
  104. int tabW;
  105. int tabH;
  106. float tabPosX;
  107. float tabTargetPosX;
  108. int tabMarginX;
  109. float getRandom() {
  110. return static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
  111. }
  112. // needed for XY canvas handling
  113. bool fDragging;
  114. bool fDragValid;
  115. int fLastX;
  116. int fLastY;
  117. Rectangle<int> fCanvasArea;
  118. float orbitX, orbitY, subOrbitX, subOrbitY;
  119. float synthData[8][8]; //as per gui, [param][page]
  120. float synthSound[8];
  121. bool isWithinSquare(float x, float y, float sX, float sY) {
  122. if (x>=sX && x<sX+0.125)
  123. if (y>=sY && y<sY+0.125)
  124. return true;
  125. return false;
  126. };
  127. };
  128. // -----------------------------------------------------------------------
  129. END_NAMESPACE_DISTRHO
  130. #endif // GROOVEJUICEUI_HPP_INCLUDED