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.
32 //#include "AudioOutputContext.h"
33 #include "JournallingObject.h"
35 class ControllerDialog
;
38 typedef QVector
<Controller
*> ControllerVector
;
41 class Controller
: public Model
, public JournallingObject
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
82 // return whether this controller updates models frequently - used for
83 // determining when to update GUI
84 inline bool frequentUpdates() const
88 case LfoController
: return true;
89 case PeakController
: return true;
96 virtual const QString
& name() const
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
,
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();
123 virtual ControllerDialog
* createDialog( QWidget
* _parent
);
125 virtual void setName( const QString
& _new_name
)
130 bool hasModel( const Model
* m
);
134 // The internal per-controller get-value function
135 virtual float value( int _offset
);
137 float m_currentValue
;
141 ControllerTypes m_type
;
143 static ControllerVector s_controllers
;
145 static unsigned int s_frames
;
149 // The value changed while the mixer isn't running (i.e: MIDI CC)
152 friend class ControllerDialog
;