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.

ZamSynthUI.hpp 2.9KB

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