Oscilloscope.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Oscilloscope.h
  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 _OSCILLOSCOPE
  25. #define _OSCILLOSCOPE
  26. #include <QWidget>
  27. #include <QPixmap>
  28. #include "lmms_basics.h"
  29. class Oscilloscope : 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. Oscilloscope( QWidget * _parent );
  37. virtual ~Oscilloscope();
  38. void setActive( bool _active );
  39. QColor const & normalColor() const;
  40. void setNormalColor(QColor const & normalColor);
  41. QColor const & warningColor() const;
  42. void setWarningColor(QColor const & warningColor);
  43. QColor const & clippingColor() const;
  44. void setClippingColor(QColor const & clippingColor);
  45. protected:
  46. void paintEvent( QPaintEvent * _pe ) override;
  47. void mousePressEvent( QMouseEvent * _me ) override;
  48. protected slots:
  49. void updateAudioBuffer( const surroundSampleFrame * buffer );
  50. private:
  51. QColor const & determineLineColor(float level) const;
  52. private:
  53. QPixmap m_background;
  54. QPointF * m_points;
  55. sampleFrame * m_buffer;
  56. bool m_active;
  57. QColor m_normalColor;
  58. QColor m_warningColor;
  59. QColor m_clippingColor;
  60. } ;
  61. #endif