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 26 #ifndef LADSPA_CONTROL_H 27 #define LADSPA_CONTROL_H 28 29 #include <ladspa.h> 30 31 #include "AutomatableModel.h" 32 #include "TempoSyncKnobModel.h" 33 #include "ValueBuffer.h" 34 35 36 typedef struct PortDescription port_desc_t; 37 38 39 class EXPORT LadspaControl : public Model, public JournallingObject 40 { 41 Q_OBJECT 42 public: 43 LadspaControl( Model * _parent, port_desc_t * _port, 44 bool _link = false ); 45 ~LadspaControl(); 46 47 LADSPA_Data value(); 48 ValueBuffer * valueBuffer(); 49 void setValue( LADSPA_Data _value ); 50 void setLink( bool _state ); 51 52 void linkControls( LadspaControl * _control ); 53 void unlinkControls( LadspaControl * _control ); 54 toggledModel()55 inline BoolModel * toggledModel() 56 { 57 return &m_toggledModel; 58 } 59 knobModel()60 inline FloatModel * knobModel() 61 { 62 return &m_knobModel; 63 } 64 tempoSyncKnobModel()65 inline TempoSyncKnobModel * tempoSyncKnobModel() 66 { 67 return &m_tempoSyncKnobModel; 68 } 69 port()70 inline port_desc_t * port() 71 { 72 return m_port; 73 } 74 75 virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent, const QString & _name ); 76 virtual void loadSettings( const QDomElement & _this, const QString & _name ); nodeName()77 inline virtual QString nodeName() const 78 { 79 return "port"; 80 } 81 82 83 signals: 84 void changed( int _port, LADSPA_Data _value ); 85 void linkChanged( int _port, bool _state ); 86 87 88 protected slots: 89 void ledChanged(); 90 void knobChanged(); 91 void tempoKnobChanged(); 92 void linkStateChanged(); 93 94 protected: saveSettings(QDomDocument & doc,QDomElement & element)95 virtual void saveSettings( QDomDocument& doc, QDomElement& element ) 96 { 97 Q_UNUSED(doc) 98 Q_UNUSED(element) 99 } 100 loadSettings(const QDomElement & element)101 virtual void loadSettings( const QDomElement& element ) 102 { 103 Q_UNUSED(element) 104 } 105 106 107 108 private: 109 bool m_link; 110 port_desc_t * m_port; 111 112 BoolModel m_linkEnabledModel; 113 BoolModel m_toggledModel; 114 FloatModel m_knobModel; 115 TempoSyncKnobModel m_tempoSyncKnobModel; 116 117 118 friend class LadspaControlView; 119 120 } ; 121 122 #endif 123