VisualizationWidget.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * VisualizationWidget.h - widget for visualization of sound-data
  3. *
  4. * Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of"the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef _VISUALIZATION_WIDGET
  25. #define _VISUALIZATION_WIDGET
  26. #include <QWidget>
  27. #include <QPixmap>
  28. #include "lmms_basics.h"
  29. class VisualizationWidget : public QWidget
  30. {
  31. Q_OBJECT
  32. public:
  33. Q_PROPERTY( QColor normalColor READ normalColor WRITE setNormalColor )
  34. Q_PROPERTY( QColor warningColor READ warningColor WRITE setWarningColor )
  35. Q_PROPERTY( QColor clippingColor READ clippingColor WRITE setClippingColor )
  36. enum visualizationTypes
  37. {
  38. Simple // add more here
  39. } ;
  40. VisualizationWidget( const QPixmap & _bg, QWidget * _parent,
  41. visualizationTypes _vtype = Simple );
  42. virtual ~VisualizationWidget();
  43. void setActive( bool _active );
  44. QColor const & normalColor() const;
  45. void setNormalColor(QColor const & normalColor);
  46. QColor const & warningColor() const;
  47. void setWarningColor(QColor const & warningColor);
  48. QColor const & clippingColor() const;
  49. void setClippingColor(QColor const & clippingColor);
  50. protected:
  51. void paintEvent( QPaintEvent * _pe ) override;
  52. void mousePressEvent( QMouseEvent * _me ) override;
  53. protected slots:
  54. void updateAudioBuffer( const surroundSampleFrame * buffer );
  55. private:
  56. QColor const & determineLineColor(float level) const;
  57. private:
  58. QPixmap s_background;
  59. QPointF * m_points;
  60. sampleFrame * m_buffer;
  61. bool m_active;
  62. QColor m_normalColor;
  63. QColor m_warningColor;
  64. QColor m_clippingColor;
  65. } ;
  66. #endif