2 Copyright (C) 2006,2007 John Anderson
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #ifndef mackie_controls_h
19 #define mackie_controls_h
25 #include "mackie_control_exception.h"
33 This is a loose group of controls, eg cursor buttons,
34 transport buttons, functions buttons etc.
39 Group( const std::string & name )
46 virtual bool is_strip() const
51 virtual bool is_master() const
56 virtual void add( Control & control );
58 const std::string & name() const
63 // This is for Surface only
64 void name( const std::string & rhs ) { _name = rhs; }
66 typedef std::vector<Control*> Controls;
67 const Controls & controls() const { return _controls; }
81 This is the set of controls that make up a strip.
83 class Strip : public Group
86 Strip( const std::string & name, int index );
88 virtual bool is_strip() const
93 virtual void add( Control & control );
95 /// This is the index of the strip
96 int index() const { return _index; }
98 /// This is for Surface only
99 void index( int rhs ) { _index = rhs; }
102 Button & recenable();
106 Button & fader_touch();
110 bool has_solo() { return _solo != 0; }
111 bool has_recenable() { return _recenable != 0; }
112 bool has_mute() { return _mute != 0; }
113 bool has_select() { return _select != 0; }
114 bool has_vselect() { return _vselect != 0; }
115 bool has_fader_touch() { return _fader_touch != 0; }
116 bool has_vpot() { return _vpot != 0; }
117 bool has_gain() { return _gain != 0; }
125 Button * _fader_touch;
131 class MasterStrip : public Strip
134 MasterStrip( const std::string & name, int index )
135 : Strip( name, index )
139 virtual bool is_master() const
148 The base class for controls on the surface. They deliberately
149 don't know the midi protocol for updating them.
154 enum type_t { type_fader, type_button, type_pot, type_led, type_led_ring };
156 Control( int id, int ordinal, std::string name, Group & group )
157 : _id( id ), _ordinal( ordinal ), _name( name ), _group( group )
161 virtual ~Control() {}
163 virtual const Led & led() const
165 throw MackieControlException( "no led available" );
168 /// The midi id of the control
174 /// The 1-based number of the control
180 const std::string & name() const
185 const Group & group() const
190 const Strip & strip() const
192 return dynamic_cast<const Strip&>( _group );
197 return dynamic_cast<Strip&>( _group );
200 virtual bool accepts_feedback() const
205 virtual type_t type() const = 0;
214 std::ostream & operator << ( std::ostream & os, const Control & control );
216 class Fader : public Control
219 Fader( int id, int ordinal, std::string name, Group & group )
220 : Control( id, ordinal, name, group )
225 bool touch() const { return _touch; }
227 void touch( bool yn ) { _touch = yn; }
229 virtual type_t type() const { return type_fader; }
235 class Led : public Control
238 Led( int id, int ordinal, std::string name, Group & group )
239 : Control( id, ordinal, name, group )
243 virtual const Led & led() const { return *this; }
245 virtual type_t type() const { return type_led; }
248 class Button : public Control
251 Button( int id, int ordinal, std::string name, Group & group )
252 : Control( id, ordinal, name, group )
253 , _led( id, ordinal, name + "_led", group )
257 virtual const Led & led() const
262 virtual type_t type() const { return type_button; };
268 class LedRing : public Led
271 LedRing( int id, int ordinal, std::string name, Group & group )
272 : Led( id, ordinal, name, group )
276 virtual type_t type() const { return type_led_ring; }
279 class Pot : public Control
282 Pot( int id, int ordinal, std::string name, Group & group )
283 : Control( id, ordinal, name, group )
284 , _led_ring( id, ordinal, name + "_ring", group )
288 virtual type_t type() const { return type_pot; }
290 virtual const LedRing & led_ring() const