a030ca556750b041674f4f5f6441bf1d4b4816af
[ardour.git] / libs / surfaces / mackie / strip.h
1 #ifndef __ardour_mackie_control_protocol_strip_h__
2 #define __ardour_mackie_control_protocol_strip_h__
3
4 #include <string>
5 #include <iostream>
6
7 #include "evoral/Parameter.hpp"
8
9 #include "pbd/property_basics.h"
10 #include "pbd/ringbuffer.h"
11 #include "pbd/signals.h"
12
13 #include "ardour/types.h"
14 #include "control_protocol/types.h"
15
16 #include "control_group.h"
17 #include "types.h"
18 #include "mackie_control_protocol.h"
19 #include "midi_byte_array.h"
20 #include "device_info.h"
21
22 namespace ARDOUR {
23         class Route;
24         class Bundle;
25         class ChannelCount;
26 }
27
28 namespace ArdourSurface {
29
30 namespace Mackie {
31
32 class Control;
33 class Surface;
34 class Button;
35 class Pot;
36 class Fader;
37 class Meter;
38 class SurfacePort;
39
40 struct GlobalControlDefinition {
41     const char* name;
42     int id;
43     Control* (*factory)(Surface&, int index, const char* name, Group&);
44     const char* group_name;
45 };
46
47 /**
48         This is the set of controls that make up a strip.
49 */
50 class Strip : public Group
51 {
52 public:
53         Strip (Surface&, const std::string & name, int index, const std::map<Button::ID,StripButtonInfo>&);
54         ~Strip();
55
56         boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
57
58         void add (Control & control);
59         int index() const { return _index; } // zero based
60         Surface* surface() const { return _surface; }
61
62         void set_route (boost::shared_ptr<ARDOUR::Route>, bool with_messages = true);
63
64         // call all signal handlers manually
65         void notify_all ();
66
67         void handle_button (Button&, ButtonState bs);
68         void handle_fader (Fader&, float position);
69         void handle_fader_touch (Fader&, bool touch_on);
70         void handle_pot (Pot&, float delta);
71
72         void periodic (ARDOUR::microseconds_t now_usecs);
73         void redisplay (ARDOUR::microseconds_t now_usecs);
74
75         MidiByteArray display (uint32_t line_number, const std::string&);
76         MidiByteArray blank_display (uint32_t line_number);
77
78         void zero ();
79
80         void potmode_changed (bool notify=false);
81         void subview_mode_changed ();
82
83         void lock_controls ();
84         void unlock_controls ();
85         bool locked() const { return _controls_locked; }
86
87         void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
88
89         void notify_metering_state_changed();
90
91         void block_screen_display_for (uint32_t msecs);
92         void block_vpot_mode_display_for (uint32_t msecs);
93
94 private:
95         Button*  _solo;
96         Button*  _recenable;
97         Button*  _mute;
98         Button*  _select;
99         Button*  _vselect;
100         Button*  _fader_touch;
101         Pot*     _vpot;
102         Fader*   _fader;
103         Meter*   _meter;
104         int      _index;
105         Surface* _surface;
106         bool     _controls_locked;
107         bool     _transport_is_rolling;
108         bool     _metering_active;
109         uint64_t _block_vpot_mode_redisplay_until;
110         uint64_t _block_screen_redisplay_until;
111         boost::shared_ptr<ARDOUR::Route> _route;
112         PBD::ScopedConnectionList route_connections;
113         PBD::ScopedConnectionList subview_connections;
114         PBD::ScopedConnectionList send_connections;
115         int       eq_band;
116
117         ARDOUR::AutomationType  _pan_mode;
118         ARDOUR::AutomationType  _trim_mode;
119         ARDOUR::AutomationType  vpot_parameter;
120
121         float _last_gain_position_written;
122         float _last_pan_azi_position_written;
123         float _last_pan_width_position_written;
124         float _last_trim_position_written;
125         uint32_t _current_send;
126
127         void notify_solo_changed ();
128         void notify_mute_changed ();
129         void notify_record_enable_changed ();
130         void notify_gain_changed (bool force_update = true);
131         void notify_property_changed (const PBD::PropertyChange&);
132         void notify_panner_azi_changed (bool force_update = true);
133         void notify_panner_width_changed (bool force_update = true);
134         void notify_active_changed ();
135         void notify_route_deleted ();
136         void notify_trim_changed (bool force_update = true);
137         void notify_phase_changed (bool force_update = true);
138         void notify_processor_changed (bool force_update = true);
139         void update_automation ();
140         void update_meter ();
141         std::string vpot_mode_string ();
142
143         boost::shared_ptr<ARDOUR::AutomationControl> mb_pan_controllable;
144
145         void return_to_vpot_mode_display ();
146
147         struct RedisplayRequest {
148                 ARDOUR::AutomationType type;
149                 float val;
150         };
151
152         RingBuffer<RedisplayRequest> redisplay_requests;
153
154         void do_parameter_display (ARDOUR::AutomationType, float val);
155         void queue_parameter_display (ARDOUR::AutomationType, float val);
156
157         void select_event (Button&, ButtonState);
158         void vselect_event (Button&, ButtonState);
159         void fader_touch_event (Button&, ButtonState);
160
161         std::vector<ARDOUR::AutomationType> possible_pot_parameters;
162         std::vector<ARDOUR::AutomationType> possible_trim_parameters;
163         void next_pot_mode ();
164         void set_vpot_parameter (ARDOUR::AutomationType);
165         void show_route_name ();
166
167         void reset_saved_values ();
168
169         bool is_midi_track () const;
170
171         typedef std::map<ARDOUR::AutomationType,Control*> ControlParameterMap;
172         ControlParameterMap control_by_parameter;
173
174         void notify_eq_change (ARDOUR::AutomationType, uint32_t band, bool force);
175         void setup_eq_vpot (boost::shared_ptr<ARDOUR::Route>);
176
177         void notify_dyn_change (ARDOUR::AutomationType, bool force);
178         void setup_dyn_vpot (boost::shared_ptr<ARDOUR::Route>);
179 };
180
181 }
182 }
183
184 #endif /* __ardour_mackie_control_protocol_strip_h__ */