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.

75 lines
1.8KB

  1. /*
  2. * Digital Peak Meter, a custom Qt4 widget
  3. * Copyright (C) 2011-2013 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 GPL.txt file
  16. */
  17. #ifndef __DIGITALPEAKMETER_HPP__
  18. #define __DIGITALPEAKMETER_HPP__
  19. #include <QtCore/QTimer>
  20. #include <QtGui/QWidget>
  21. class DigitalPeakMeter : public QWidget
  22. {
  23. public:
  24. enum Orientation {
  25. HORIZONTAL = 1,
  26. VERTICAL = 2
  27. };
  28. enum Color {
  29. GREEN = 1,
  30. BLUE = 2
  31. };
  32. DigitalPeakMeter(QWidget* parent);
  33. ~DigitalPeakMeter();
  34. void displayMeter(int meter, float level);
  35. void setChannels(int channels);
  36. void setColor(Color color);
  37. void setOrientation(Orientation orientation);
  38. void setRefreshRate(int rate);
  39. void setSmoothRelease(int value);
  40. QSize minimumSizeHint() const;
  41. QSize sizeHint() const;
  42. protected:
  43. void updateSizes();
  44. void paintEvent(QPaintEvent* event);
  45. void resizeEvent(QResizeEvent* event);
  46. private:
  47. int fChannels;
  48. int fSmoothMultiplier;
  49. int fWidth, fHeight, fSizeMeter;
  50. Orientation fOrientation;
  51. QColor fColorBackground;
  52. QLinearGradient fGradientMeter;
  53. QColor fColorBase;
  54. QColor fColorBaseAlt;
  55. float* fChannelsData;
  56. float* fLastValueData;
  57. QTimer fPaintTimer;
  58. };
  59. #endif // __DIGITALPEAKMETER_HPP__