MCP: a fistful of improvements. probably best to just try it and see what it broken...
[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 "pbd/property_basics.h"
8 #include "pbd/signals.h"
9
10 #include "ardour/types.h"
11 #include "control_protocol/types.h"
12
13 #include "control_group.h"
14 #include "types.h"
15 #include "midi_byte_array.h"
16 #include "device_info.h"
17
18 namespace ARDOUR {
19         class Route;
20         class Bundle;
21         class ChannelCount;
22 }
23
24 namespace Mackie {
25
26 class Control;
27 class Surface;
28 class Button;
29 class Pot;
30 class Fader;
31 class Meter;
32 class SurfacePort;
33
34 struct StripControlDefinition {
35     const char* name;
36     uint32_t base_id;
37     Control* (*factory)(Surface&, int index, const char* name, Group&);
38 };
39
40 struct GlobalControlDefinition {
41     const char* name;
42     uint32_t 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         
61         void set_route (boost::shared_ptr<ARDOUR::Route>, bool with_messages = true);
62
63         // call all signal handlers manually
64         void notify_all();
65
66         void handle_button (Button&, ButtonState bs);
67         void handle_fader (Fader&, float position);
68         void handle_pot (Pot&, float delta);
69
70         void periodic (uint64_t now_usecs);
71
72         MidiByteArray display (uint32_t line_number, const std::string&);
73         MidiByteArray blank_display (uint32_t line_number);
74
75         void zero ();
76
77         void flip_mode_changed (bool notify=false);
78
79         void lock_controls ();
80         void unlock_controls ();
81         
82         MidiByteArray gui_selection_changed (ARDOUR::RouteNotificationListPtr);
83
84 private:
85         enum PotMode {
86                 Gain,
87                 PanAzimuth,
88                 PanWidth,
89                 PanElevation,
90                 PanFrontBack,
91                 PanLFE,
92                 Input,
93                 Output,
94                 Send1,
95                 Send2,
96                 Send3,
97                 Send4,
98                 Send5,
99                 Send6,
100                 Send7,
101                 Send8,
102         };
103                 
104         Button*  _solo;
105         Button*  _recenable;
106         Button*  _mute;
107         Button*  _select;
108         Button*  _vselect;
109         Button*  _fader_touch;
110         Pot*     _vpot;
111         PotMode  _vpot_mode;
112         PotMode  _preflip_vpot_mode;
113         Fader*   _fader;
114         Meter*   _meter;
115         int      _index;
116         Surface* _surface;
117         bool     _controls_locked;
118         uint64_t _reset_display_at;
119         boost::shared_ptr<ARDOUR::Route> _route;
120         PBD::ScopedConnectionList route_connections;
121
122         float _last_gain_position_written;
123         float _last_pan_position_written;
124
125         void notify_solo_changed ();
126         void notify_mute_changed ();
127         void notify_record_enable_changed ();
128         void notify_gain_changed (bool force_update = true);
129         void notify_property_changed (const PBD::PropertyChange&);
130         void notify_panner_azi_changed (bool force_update = true);
131         void notify_panner_width_changed (bool force_update = true);
132         void notify_active_changed ();
133         void notify_route_deleted ();
134         
135         void update_automation ();
136         void update_meter ();
137
138         std::string vpot_mode_string () const;
139
140         void queue_display_reset (uint32_t msecs);
141         void clear_display_reset ();
142         void reset_display ();
143         void do_parameter_display (ARDOUR::AutomationType, float val);
144         
145         typedef std::map<std::string,boost::shared_ptr<ARDOUR::Bundle> > BundleMap;
146         BundleMap input_bundles;
147         BundleMap output_bundles;
148
149         void build_input_list (const ARDOUR::ChanCount&);
150         void build_output_list (const ARDOUR::ChanCount&);
151         void maybe_add_to_bundle_map (BundleMap& bm, boost::shared_ptr<ARDOUR::Bundle>, bool for_input, const ARDOUR::ChanCount&);
152
153         void select_event (Button&, ButtonState);
154         void vselect_event (Button&, ButtonState);
155         void fader_touch_event (Button&, ButtonState);
156
157         std::vector<PotMode> current_pot_modes;
158         void next_pot_mode ();
159         void set_vpot_mode (PotMode);
160 };
161
162 }
163
164 #endif /* __ardour_mackie_control_protocol_strip_h__ */