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.

74 lines
1.8KB

  1. /*
  2. * Digital Peak Meter, a custom Qt4 widget
  3. * Copyright (C) 2011-2012 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * 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 COPYING 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. void displayMeter(int meter, float level);
  34. void setChannels(int channels);
  35. void setColor(Color color);
  36. void setOrientation(Orientation orientation);
  37. void setRefreshRate(int rate);
  38. void setSmoothRelease(int value);
  39. QSize minimumSizeHint() const;
  40. QSize sizeHint() const;
  41. protected:
  42. void updateSizes();
  43. void paintEvent(QPaintEvent* event);
  44. void resizeEvent(QResizeEvent* event);
  45. private:
  46. int m_channels;
  47. int m_smoothMultiplier;
  48. int m_width, m_height, m_sizeMeter;
  49. Orientation m_orientation;
  50. QColor m_colorBackground;
  51. QLinearGradient m_gradientMeter;
  52. QColor m_colorBase;
  53. QColor m_colorBaseT;
  54. QList<float> m_channelsData;
  55. QList<float> m_lastValueData;
  56. QTimer m_paintTimer;
  57. };
  58. #endif // DIGITALPEAKMETER_HPP