RemoteVstPlugin: fixed too short arrays for preset names
[lmms.git] / include / Controller.h
blob129c44c1842064dcad33a49226e07ae4d122374c
1 /*
2 * Controller.h - declaration of class controller, which provides a
3 * standard for all controllers and controller plugins
5 * Copyright (c) 2008-2009 Paul Giblock <pgllama/at/gmail.com>
7 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
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.
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.
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.
26 #ifndef _CONTROLLER_H
27 #define _CONTROLLER_H
29 #include "engine.h"
30 #include "Mixer.h"
31 #include "Model.h"
32 //#include "AudioOutputContext.h"
33 #include "JournallingObject.h"
35 class ControllerDialog;
36 class Controller;
38 typedef QVector<Controller *> ControllerVector;
41 class Controller : public Model, public JournallingObject
43 Q_OBJECT
44 public:
45 enum ControllerTypes
47 DummyController,
48 LfoController,
49 MidiController,
50 PeakController,
52 XYController,
53 EquationController
55 NumControllerTypes
56 } ;
58 Controller( ControllerTypes _type, Model * _parent,
59 const QString & _display_name );
61 virtual ~Controller();
63 virtual float currentValue( int _offset );
65 inline bool isSampleExact() const
67 return m_sampleExact /*||
68 engine::mixer()->audioOutputContext()->
69 qualitySettings().sampleExactControllers()*/;
72 void setSampleExact( bool _exact )
74 m_sampleExact = _exact;
77 inline ControllerTypes type() const
79 return m_type;
82 // return whether this controller updates models frequently - used for
83 // determining when to update GUI
84 inline bool frequentUpdates() const
86 switch( m_type )
88 case LfoController: return true;
89 case PeakController: return true;
90 default:
91 break;
93 return false;
96 virtual const QString & name() const
98 return m_name;
102 virtual void saveSettings( QDomDocument & _doc, QDomElement & _this );
103 virtual void loadSettings( const QDomElement & _this );
104 virtual QString nodeName() const;
106 static Controller * create( ControllerTypes _tt, Model * _parent );
107 static Controller * create( const QDomElement & _this,
108 Model * _parent );
110 inline static float fittedValue( float _val )
112 return tLimit<float>( _val, 0.0f, 1.0f );
115 static unsigned int runningFrames();
116 static float runningTime();
118 static void triggerFrameCounter();
119 static void resetFrameCounter();
122 public slots:
123 virtual ControllerDialog * createDialog( QWidget * _parent );
125 virtual void setName( const QString & _new_name )
127 m_name = _new_name;
130 bool hasModel( const Model * m );
133 protected:
134 // The internal per-controller get-value function
135 virtual float value( int _offset );
137 float m_currentValue;
138 bool m_sampleExact;
140 QString m_name;
141 ControllerTypes m_type;
143 static ControllerVector s_controllers;
145 static unsigned int s_frames;
148 signals:
149 // The value changed while the mixer isn't running (i.e: MIDI CC)
150 void valueChanged();
152 friend class ControllerDialog;
156 #endif