b4515def6551fd7e82460026a42d9d28f3fb2a81
[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/signals.h"
11
12 #include "ardour/types.h"
13 #include "control_protocol/types.h"
14
15 #include "control_group.h"
16 #include "types.h"
17 #include "midi_byte_array.h"
18 #include "device_info.h"
19
20 namespace ARDOUR {
21         class Route;
22         class Bundle;
23         class ChannelCount;
24 }
25
26 namespace ArdourSurface {
27
28 namespace Mackie {
29
30 class Control;
31 class Surface;
32 class Button;
33 class Pot;
34 class Fader;
35 class Meter;
36 class SurfacePort;
37
38 struct GlobalControlDefinition {
39     const char* name;
40     int id;
41     Control* (*factory)(Surface&, int index, const char* name, Group&);
42     const char* group_name;
43 };
44
45 /**
46         This is the set of controls that make up a strip.
47 */
48 class Strip : public Group
49 {
50 public:
51         Strip (Surface&, const std::string & name, int index, const std::map<Button::ID,StripButtonInfo>&);
52         ~Strip();
53
54         boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
55
56         void add (Control & control);
57         int index() const { return _index; } // zero based
58         
59         void set_route (boost::shared_ptr<ARDOUR::Route>, bool with_messages = true);
60
61         // call all signal handlers manually
62         void notify_all();
63
64         void handle_button (Button&, ButtonState bs);
65         void handle_fader (Fader&, float position);
66         void handle_fader_touch (Fader&, bool touch_on);
67         void handle_pot (Pot&, float delta);
68
69         void periodic (uint64_t now_usecs);
70
71         MidiByteArray display (uint32_t line_number, const std::string&);
72         MidiByteArray blank_display (uint32_t line_number);
73
74         void zero ();
75
76         void flip_mode_changed (bool notify=false);
77
78         void lock_controls ();
79         void unlock_controls ();
80         bool locked() const { return _controls_locked; }
81
82         void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
83   
84         void notify_metering_state_changed();
85
86 private:
87         Button*  _solo;
88         Button*  _recenable;
89         Button*  _mute;
90         Button*  _select;
91         Button*  _vselect;
92         Button*  _fader_touch;
93         Pot*     _vpot;
94         Fader*   _fader;
95         Meter*   _meter;
96         int      _index;
97         Surface* _surface;
98         bool     _controls_locked;
99         bool     _transport_is_rolling;
100         bool     _metering_active;
101         uint64_t _reset_display_at;
102         boost::shared_ptr<ARDOUR::Route> _route;
103         PBD::ScopedConnectionList route_connections;
104
105         float _last_gain_position_written;
106         float _last_pan_azi_position_written;
107         float _last_pan_width_position_written;
108
109         void notify_solo_changed ();
110         void notify_mute_changed ();
111         void notify_record_enable_changed ();
112         void notify_gain_changed (bool force_update = true);
113         void notify_property_changed (const PBD::PropertyChange&);
114         void notify_panner_azi_changed (bool force_update = true);
115         void notify_panner_width_changed (bool force_update = true);
116         void notify_active_changed ();
117         void notify_route_deleted ();
118         
119         void update_automation ();
120         void update_meter ();
121
122         std::string vpot_mode_string () const;
123
124         void queue_display_reset (uint32_t msecs);
125         void clear_display_reset ();
126         void reset_display ();
127         void do_parameter_display (ARDOUR::AutomationType, float val);
128         
129         typedef std::map<std::string,boost::shared_ptr<ARDOUR::Bundle> > BundleMap;
130         BundleMap input_bundles;
131         BundleMap output_bundles;
132
133         void build_input_list (const ARDOUR::ChanCount&);
134         void build_output_list (const ARDOUR::ChanCount&);
135         void maybe_add_to_bundle_map (BundleMap& bm, boost::shared_ptr<ARDOUR::Bundle>, bool for_input, const ARDOUR::ChanCount&);
136
137         void select_event (Button&, ButtonState);
138         void vselect_event (Button&, ButtonState);
139         void fader_touch_event (Button&, ButtonState);
140
141         std::vector<Evoral::Parameter> possible_pot_parameters;
142         void next_pot_mode ();
143         void set_vpot_parameter (Evoral::Parameter);
144
145         void reset_saved_values ();
146
147         std::map<Evoral::Parameter,Control*> control_by_parameter;
148 };
149
150 }
151 }
152
153 #endif /* __ardour_mackie_control_protocol_strip_h__ */