PeakController.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * PeakController.h - peak-controller class
  3. *
  4. * Copyright (c) 2008-2009 Paul Giblock <drfaygo/at/gmail.com>
  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 PEAK_CONTROLLER_H
  25. #define PEAK_CONTROLLER_H
  26. #include "Model.h"
  27. #include "Controller.h"
  28. #include "ControllerDialog.h"
  29. class QWidget;
  30. class PeakControllerEffect;
  31. typedef QVector<PeakControllerEffect *> PeakControllerEffectVector;
  32. class LMMS_EXPORT PeakController : public Controller
  33. {
  34. Q_OBJECT
  35. public:
  36. PeakController( Model * _parent,
  37. PeakControllerEffect *_peak_effect = nullptr );
  38. virtual ~PeakController();
  39. void saveSettings( QDomDocument & _doc, QDomElement & _this ) override;
  40. void loadSettings( const QDomElement & _this ) override;
  41. QString nodeName() const override;
  42. static void initGetControllerBySetting();
  43. static PeakController * getControllerBySetting( const QDomElement & _this );
  44. static PeakControllerEffectVector s_effects;
  45. public slots:
  46. ControllerDialog * createDialog( QWidget * _parent ) override;
  47. void handleDestroyedEffect( );
  48. void updateCoeffs();
  49. protected:
  50. // The internal per-controller get-value function
  51. void updateValueBuffer() override;
  52. PeakControllerEffect * m_peakEffect;
  53. friend class PeakControllerDialog;
  54. private:
  55. float m_currentSample;
  56. //backward compatibility for <= 0.4.15
  57. static int m_getCount;
  58. static int m_loadCount;
  59. static bool m_buggedFile;
  60. float m_attackCoeff;
  61. float m_decayCoeff;
  62. bool m_coeffNeedsUpdate;
  63. } ;
  64. class PeakControllerDialog : public ControllerDialog
  65. {
  66. Q_OBJECT
  67. public:
  68. PeakControllerDialog( Controller * _controller, QWidget * _parent );
  69. virtual ~PeakControllerDialog();
  70. protected:
  71. void contextMenuEvent( QContextMenuEvent * _me ) override;
  72. void paintEvent( QPaintEvent * _pe ) override;
  73. void modelChanged() override;
  74. PeakController * m_peakController;
  75. } ;
  76. #endif