Oscilloscope.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_H
  25. #define OSCILLOSCOPE_H
  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 clippingColor READ clippingColor WRITE setClippingColor )
  35. Oscilloscope( QWidget * _parent );
  36. virtual ~Oscilloscope();
  37. void setActive( bool _active );
  38. QColor const & normalColor() const;
  39. void setNormalColor(QColor const & normalColor);
  40. QColor const & clippingColor() const;
  41. void setClippingColor(QColor const & clippingColor);
  42. protected:
  43. void paintEvent( QPaintEvent * _pe ) override;
  44. void mousePressEvent( QMouseEvent * _me ) override;
  45. protected slots:
  46. void updateAudioBuffer( const surroundSampleFrame * buffer );
  47. private:
  48. QColor const & determineLineColor(float level) const;
  49. private:
  50. QPixmap m_background;
  51. QPointF * m_points;
  52. sampleFrame * m_buffer;
  53. bool m_active;
  54. QColor m_normalColor;
  55. QColor m_clippingColor;
  56. } ;
  57. #endif // OSCILLOSCOPE_H