FP8: use separate bank offsets per MixMode
[ardour.git] / libs / surfaces / faderport8 / fp8_strip.h
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
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.
13  *
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18
19 #ifndef _ardour_surfaces_fp8strip_h_
20 #define _ardour_surfaces_fp8strip_h_
21
22 #include <stdint.h>
23 #include <boost/shared_ptr.hpp>
24
25 #include "pbd/signals.h"
26 #include "pbd/controllable.h"
27
28 #include "fp8_base.h"
29 #include "fp8_button.h"
30
31 namespace ARDOUR {
32         class Stripable;
33         class AutomationControl;
34         class PeakMeter;
35         class ReadOnlyControl;
36 }
37
38 namespace ArdourSurface {
39
40 class FP8Strip
41 {
42 public:
43         FP8Strip (FP8Base& b, uint8_t id);
44         ~FP8Strip ();
45
46         FP8ButtonInterface& solo_button () { return _solo; }
47         FP8ButtonInterface& mute_button () { return _mute; }
48         FP8ButtonInterface& selrec_button () { return _selrec; }
49         FP8ButtonInterface& recarm_button () { return *_selrec.button_shift(); }
50         FP8ButtonInterface& select_button () { return *_selrec.button(); }
51
52         bool midi_touch (bool t);
53         bool midi_fader (float val);
54
55         void initialize (); // call only when connected, sends midi
56
57         void set_select_cb (boost::function<void ()>&);
58
59         enum DisplayMode {
60                 Stripables,
61                 PluginSelect, // no clock display
62                 PluginParam, // param value
63                 SendDisplay, // param value + select-bar
64         };
65
66         void set_periodic_display_mode (DisplayMode m);
67
68         // convenience function to call all set_XXX_controllable
69         void set_stripable (boost::shared_ptr<ARDOUR::Stripable>, bool panmode);
70         void set_text_line (uint8_t, std::string const&, bool inv = false);
71
72         enum CtrlMask {
73                 CTRL_FADER  = 0x001,
74                 CTRL_MUTE   = 0x002,
75                 CTRL_SOLO   = 0x004,
76                 CTRL_REC    = 0x004,
77                 CTRL_PAN    = 0x008,
78                 CTRL_SELECT = 0x010,
79                 CTRL_TEXT0  = 0x100,
80                 CTRL_TEXT1  = 0x200,
81                 CTRL_TEXT2  = 0x400,
82                 CTRL_TEXT3  = 0x800,
83
84                 CTRL_TEXT01 = 0x300,
85                 CTRL_TEXT   = 0xf00,
86                 CTRL_ALL    = 0xfff,
87         };
88
89         void unset_controllables (int which = CTRL_ALL);
90
91         void set_fader_controllable  (boost::shared_ptr<ARDOUR::AutomationControl>);
92         void set_mute_controllable   (boost::shared_ptr<ARDOUR::AutomationControl>);
93         void set_solo_controllable   (boost::shared_ptr<ARDOUR::AutomationControl>);
94         void set_rec_controllable    (boost::shared_ptr<ARDOUR::AutomationControl>);
95         void set_pan_controllable    (boost::shared_ptr<ARDOUR::AutomationControl>);
96         void set_select_controllable (boost::shared_ptr<ARDOUR::AutomationControl>);
97
98 private:
99         FP8Base&  _base;
100         uint8_t   _id;
101         FP8MomentaryButton _solo;
102         FP8MomentaryButton _mute;
103         FP8ARMSensitiveButton _selrec;
104
105         bool _touching;
106
107         PBD::ScopedConnection _base_connection; // periodic
108         PBD::ScopedConnectionList _button_connections;
109
110         std::string _stripable_name;
111
112         boost::shared_ptr<ARDOUR::AutomationControl> _fader_ctrl;
113         boost::shared_ptr<ARDOUR::AutomationControl> _mute_ctrl;
114         boost::shared_ptr<ARDOUR::AutomationControl> _solo_ctrl;
115         boost::shared_ptr<ARDOUR::AutomationControl> _rec_ctrl;
116         boost::shared_ptr<ARDOUR::AutomationControl> _pan_ctrl;
117         boost::shared_ptr<ARDOUR::AutomationControl> _x_select_ctrl;
118
119         PBD::ScopedConnection _fader_connection;
120         PBD::ScopedConnection _mute_connection;
121         PBD::ScopedConnection _solo_connection;
122         PBD::ScopedConnection _rec_connection;
123         PBD::ScopedConnection _pan_connection;
124         PBD::ScopedConnection _x_select_connection;
125
126         boost::shared_ptr<ARDOUR::PeakMeter> _peak_meter;
127         boost::shared_ptr<ARDOUR::ReadOnlyControl> _redux_ctrl;
128
129         void set_x_select_controllable (boost::shared_ptr<ARDOUR::AutomationControl>);
130         boost::function<void ()> _select_plugin_functor;
131
132         void drop_automation_controls ();
133
134         PBD::Controllable::GroupControlDisposition group_mode () const;
135
136         /* notifications, update view */
137         void notify_fader_changed ();
138         void notify_solo_changed ();
139         void notify_mute_changed ();
140         void notify_rec_changed ();
141         void notify_pan_changed ();
142         void notify_x_select_changed ();
143
144         /* actions, update model */
145         void set_mute (bool);
146         void set_solo (bool);
147         void set_select ();
148         void set_recarm ();
149
150         /* periodic poll, update view */
151         void set_strip_name ();
152         void periodic_update_fader ();
153         void periodic_update_meter ();
154         void periodic_update_timecode (uint32_t);
155         void periodic ();
156
157         /* cache */
158         unsigned short _last_fader;
159         uint8_t _last_meter;
160         uint8_t _last_redux;
161         uint8_t _last_barpos;
162
163         /* display */
164         void set_strip_mode (uint8_t, bool clear = false);
165         void set_bar_mode (uint8_t, bool force = false);
166
167         uint8_t _strip_mode;
168         uint8_t _bar_mode;
169         DisplayMode _displaymode;
170         std::string _last_line[4];
171 };
172
173 } /* namespace */
174 #endif /* _ardour_surfaces_fp8strip_h_ */