Ardour  9.0-pre0-582-g084a23a80d
surfaces/mackie/types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2007 John Anderson
3  * Copyright (C) 2008-2015 Paul Davis <paul@linuxaudiosystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 #ifndef mackie_types_h
20 #define mackie_types_h
21 
22 #include <iostream>
23 
24 #ifdef UF8
25 # define MACKIE_NAMESPACE NS_UF8
26 #else
27 # define MACKIE_NAMESPACE NS_MCU
28 #endif
29 
30 namespace ArdourSurface { namespace MACKIE_NAMESPACE {
31 
33  mcu,
34  ext,
35 };
36 
41 class LedState
42 {
43 public:
44  enum state_t { none, off, flashing, on };
45  LedState() : _state (none) {}
46  LedState (bool yn): _state (yn ? on : off) {}
47  LedState (state_t state): _state (state) {}
48 
49  LedState& operator= (state_t s) { _state = s; return *this; }
50 
51  bool operator == (const LedState & other) const
52  {
53  return state() == other.state();
54  }
55 
56  bool operator != (const LedState & other) const
57  {
58  return state() != other.state();
59  }
60 
61  state_t state() const { return _state; }
62 
63 private:
65 };
66 
67 extern LedState on;
68 extern LedState off;
69 extern LedState flashing;
70 extern LedState none;
71 
72 enum ButtonState { neither = -1, release = 0, press = 1 };
73 
79 {
80  ControlState(): pos(0.0), sign(0), delta(0.0), ticks(0), led_state(off), button_state(neither) {}
81 
82  ControlState (LedState ls): pos(0.0), delta(0.0), led_state(ls), button_state(neither) {}
83 
84  // Note that this sets both pos and delta to the flt value
85  ControlState (LedState ls, float flt): pos(flt), delta(flt), ticks(0), led_state(ls), button_state(neither) {}
86  ControlState (float flt): pos(flt), delta(flt), ticks(0), led_state(none), button_state(neither) {}
87  ControlState (float flt, unsigned int tcks): pos(flt), delta(flt), ticks(tcks), led_state(none), button_state(neither) {}
88  ControlState (ButtonState bs): pos(0.0), delta(0.0), ticks(0), led_state(none), button_state(bs) {}
89 
91  float pos;
92 
94  int sign;
95 
97  float delta;
98 
100  unsigned int ticks;
101 
104 };
105 
106 std::ostream & operator << (std::ostream &, const ControlState &);
107 
108 class Control;
109 class Fader;
110 class Button;
111 class Strip;
112 class Group;
113 class Pot;
114 class Led;
115 
116 }
117 }
118 
119 #endif
std::ostream & operator<<(std::ostream &, const ControlState &)
bool operator==(const ProcessorSelection &a, const ProcessorSelection &b)
ControlState(float flt, unsigned int tcks)
unsigned int ticks
For pots. Unsigned number of ticks. Usually between 1 and 16.
float delta
For pots. Signed value of total movement. Between 0 and 1.
float pos
For faders. Between 0 and 1.
int sign
For pots. Sign. Either -1 or 1;.
#define MACKIE_NAMESPACE