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.

108 lines
3.0KB

  1. /*
  2. * ZamSynth polyphonic synthesiser
  3. * Copyright (C) 2014 Damien Zammit <damien@zamaudio.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 doc/GPL.txt file.
  16. */
  17. #ifndef ZAMSYNTHUI_HPP_INCLUDED
  18. #define ZAMSYNTHUI_HPP_INCLUDED
  19. #include "DistrhoUI.hpp"
  20. #include "Geometry.hpp"
  21. #include "ImageKnob.hpp"
  22. #include "ImageButton.hpp"
  23. #include "ImageToggle.hpp"
  24. #include "ZamSynthArtwork.hpp"
  25. #include "ZamSynthPlugin.hpp"
  26. using DGL::Image;
  27. using DGL::ImageKnob;
  28. using DGL::ImageButton;
  29. using DGL::ImageToggle;
  30. #define AREAHEIGHT 250
  31. START_NAMESPACE_DISTRHO
  32. // -----------------------------------------------------------------------
  33. class ZamSynthUI : public UI,
  34. public ImageKnob::Callback,
  35. public ImageButton::Callback,
  36. public ImageToggle::Callback
  37. {
  38. public:
  39. ZamSynthUI();
  40. ~ZamSynthUI() override;
  41. protected:
  42. // -------------------------------------------------------------------
  43. // Information
  44. unsigned int d_getWidth() const noexcept override
  45. {
  46. return ZamSynthArtwork::zamsynthWidth;
  47. }
  48. unsigned int d_getHeight() const noexcept override
  49. {
  50. return ZamSynthArtwork::zamsynthHeight;
  51. }
  52. void gaussiansmooth(float* smoothed, float* xs, float* ys, int n, int radius);
  53. // -------------------------------------------------------------------
  54. // DSP Callbacks
  55. void d_parameterChanged(uint32_t index, float value) override;
  56. void d_programChanged(uint32_t index) override;
  57. void d_stateChanged(const char*, const char*) override;
  58. // -------------------------------------------------------------------
  59. // Widget Callbacks
  60. void imageKnobDragStarted(ImageKnob* knob) override;
  61. void imageKnobDragFinished(ImageKnob* knob) override;
  62. void imageKnobValueChanged(ImageKnob* knob, float value) override;
  63. void imageButtonClicked(ImageButton* button, int) override;
  64. void imageToggleClicked(ImageToggle* toggle, int) override;
  65. void onDisplay() override;
  66. bool onMouse(int, bool, int, int) override;
  67. bool onMotion(int, int) override;
  68. private:
  69. Image fImgBackground;
  70. ImageKnob* fKnobGain;
  71. ImageKnob* fKnobSpeed;
  72. ImageButton* fButtonSmooth;
  73. ImageToggle* fToggleGraph;
  74. float wave_y[AREAHEIGHT];
  75. float env_y[AREAHEIGHT];
  76. bool fGraph;
  77. bool fDragging;
  78. bool fDragValid;
  79. DGL::Rectangle<int> fCanvasArea;
  80. };
  81. // -----------------------------------------------------------------------
  82. END_NAMESPACE_DISTRHO
  83. #endif // ZAMSYNTHUI_HPP_INCLUDED