LadspaControl.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * LadspaControl.h - model for controlling a LADSPA port
  3. *
  4. * Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. * Copyright (c) 2006-2008 Danny McRae <khjklujn/at/users.sourceforge.net>
  6. *
  7. * This file is part of LMMS - https://lmms.io
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2 of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public
  20. * License along with this program (see COPYING); if not, write to the
  21. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. * Boston, MA 02110-1301 USA.
  23. *
  24. */
  25. #ifndef LADSPA_CONTROL_H
  26. #define LADSPA_CONTROL_H
  27. #include <ladspa.h>
  28. #include "AutomatableModel.h"
  29. #include "TempoSyncKnobModel.h"
  30. #include "ValueBuffer.h"
  31. typedef struct PortDescription port_desc_t;
  32. class LMMS_EXPORT LadspaControl : public Model, public JournallingObject
  33. {
  34. Q_OBJECT
  35. public:
  36. LadspaControl( Model * _parent, port_desc_t * _port,
  37. bool _link = false );
  38. ~LadspaControl();
  39. LADSPA_Data value();
  40. ValueBuffer * valueBuffer();
  41. void setValue( LADSPA_Data _value );
  42. void setLink( bool _state );
  43. void linkControls( LadspaControl * _control );
  44. void unlinkControls( LadspaControl * _control );
  45. inline BoolModel * toggledModel()
  46. {
  47. return &m_toggledModel;
  48. }
  49. inline FloatModel * knobModel()
  50. {
  51. return &m_knobModel;
  52. }
  53. inline TempoSyncKnobModel * tempoSyncKnobModel()
  54. {
  55. return &m_tempoSyncKnobModel;
  56. }
  57. inline port_desc_t * port()
  58. {
  59. return m_port;
  60. }
  61. virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent, const QString & _name );
  62. virtual void loadSettings( const QDomElement & _this, const QString & _name );
  63. inline QString nodeName() const override
  64. {
  65. return "port";
  66. }
  67. signals:
  68. void changed( int _port, LADSPA_Data _value );
  69. void linkChanged( int _port, bool _state );
  70. protected slots:
  71. void ledChanged();
  72. void knobChanged();
  73. void tempoKnobChanged();
  74. void linkStateChanged();
  75. protected:
  76. void saveSettings( QDomDocument& doc, QDomElement& element ) override
  77. {
  78. Q_UNUSED(doc)
  79. Q_UNUSED(element)
  80. }
  81. void loadSettings( const QDomElement& element ) override
  82. {
  83. Q_UNUSED(element)
  84. }
  85. private:
  86. bool m_link;
  87. port_desc_t * m_port;
  88. BoolModel m_linkEnabledModel;
  89. BoolModel m_toggledModel;
  90. FloatModel m_knobModel;
  91. TempoSyncKnobModel m_tempoSyncKnobModel;
  92. friend class LadspaControlView;
  93. } ;
  94. #endif