Ardour  8.7-14-g57a6773833
fp8_strip.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 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 <cstdint>
23 #include <memory>
24 
25 #include "pbd/signals.h"
26 #include "pbd/controllable.h"
27 
28 #include "fp8_base.h"
29 #include "fp8_button.h"
30 
31 #ifdef FADERPORT16
32 # define N_STRIPS 16
33 #elif defined FADERPORT2
34 # define N_STRIPS 1
35 #else
36 # define N_STRIPS 8
37 #endif
38 
39 namespace ARDOUR {
40  class Stripable;
41  class AutomationControl;
42  class PeakMeter;
43  class ReadOnlyControl;
44 }
45 
46 namespace ArdourSurface { namespace FP_NAMESPACE {
47 
48 class FP8Strip
49 {
50 public:
51  FP8Strip (FP8Base& b, uint8_t id);
53 
54  enum CtrlElement {
62  BarMode
63  };
64 
65  static uint8_t midi_ctrl_id (CtrlElement type, uint8_t id);
66 
67  FP8ButtonInterface& solo_button () { return _solo; }
68  FP8ButtonInterface& mute_button () { return _mute; }
69  FP8ButtonInterface& selrec_button () { return _selrec; }
70  FP8ButtonInterface& recarm_button () { return *_selrec.button_shift(); }
71  FP8ButtonInterface& select_button () { return *_selrec.button(); }
72 
73  void set_select_button_color (uint32_t color) {
74  if ((color & 0xffffff00) == 0) {
75  select_button ().set_color (0xffffffff);
76  } else {
77  select_button ().set_color (color);
78  }
79  }
80 
81  bool midi_touch (bool t);
82  bool midi_fader (float val);
83 
84  void initialize (); // call only when connected, sends midi
85 
86  void set_select_cb (boost::function<void ()>&);
87 
88  enum DisplayMode {
90  PluginSelect, // no clock display
91  PluginParam, // param value
92  SendDisplay, // param value + select-bar
93  };
94 
96 
97  // convenience function to call all set_XXX_controllable
98  void set_stripable (std::shared_ptr<ARDOUR::Stripable>, bool panmode);
99  void set_text_line (uint8_t, std::string const&, bool inv = false);
100 
101  enum CtrlMask {
102  CTRL_FADER = 0x001,
103  CTRL_MUTE = 0x002,
104  CTRL_SOLO = 0x004,
105  CTRL_REC = 0x004,
106  CTRL_PAN = 0x008,
107  CTRL_SELECT = 0x010,
108  CTRL_TEXT0 = 0x100,
109  CTRL_TEXT1 = 0x200,
110  CTRL_TEXT2 = 0x400,
111  CTRL_TEXT3 = 0x800,
112 
113  CTRL_TEXT01 = 0x300,
114  CTRL_TEXT = 0xf00,
115  CTRL_ALL = 0xfff,
116  };
117 
118  void unset_controllables (int which = CTRL_ALL);
119 
120  void set_fader_controllable (std::shared_ptr<ARDOUR::AutomationControl>);
121  void set_mute_controllable (std::shared_ptr<ARDOUR::AutomationControl>);
122  void set_solo_controllable (std::shared_ptr<ARDOUR::AutomationControl>);
123  void set_rec_controllable (std::shared_ptr<ARDOUR::AutomationControl>);
124  void set_pan_controllable (std::shared_ptr<ARDOUR::AutomationControl>);
125  void set_select_controllable (std::shared_ptr<ARDOUR::AutomationControl>);
126 
127 private:
129  uint8_t _id;
133 
134  bool _touching;
135 
138 
139  std::string _stripable_name;
140 
141  std::shared_ptr<ARDOUR::AutomationControl> _fader_ctrl;
142  std::shared_ptr<ARDOUR::AutomationControl> _mute_ctrl;
143  std::shared_ptr<ARDOUR::AutomationControl> _solo_ctrl;
144  std::shared_ptr<ARDOUR::AutomationControl> _rec_ctrl;
145  std::shared_ptr<ARDOUR::AutomationControl> _pan_ctrl;
146  std::shared_ptr<ARDOUR::AutomationControl> _x_select_ctrl;
147 
154 
155  std::shared_ptr<ARDOUR::PeakMeter> _peak_meter;
156  std::shared_ptr<ARDOUR::ReadOnlyControl> _redux_ctrl;
157 
158  void set_x_select_controllable (std::shared_ptr<ARDOUR::AutomationControl>);
159  boost::function<void ()> _select_plugin_functor;
160 
162 
164 
165  /* notifications, update view */
172 
173  /* actions, update model */
174  void set_mute (bool);
175  void set_solo (bool);
176  void set_select ();
177  void set_recarm ();
178 
179  /* periodic poll, update view */
180  void set_strip_name ();
183  void periodic_update_timecode (uint32_t);
184  void periodic ();
185 
186  /* cache */
187  unsigned short _last_fader;
188  uint8_t _last_meter;
189  uint8_t _last_redux;
190  uint8_t _last_barpos;
191 
192  /* display */
193  void set_strip_mode (uint8_t, bool clear = false);
194  void set_bar_mode (uint8_t, bool force = false);
195 
196  uint8_t _strip_mode;
197  uint8_t _bar_mode;
199  std::string _last_line[4];
200 };
201 
202 } } /* namespace */
203 #endif /* _ardour_surfaces_fp8strip_h_ */
void periodic_update_timecode(uint32_t)
FP8Strip(FP8Base &b, uint8_t id)
FP8ButtonInterface & recarm_button()
Definition: fp8_strip.h:70
FP8MomentaryButton _mute
Definition: fp8_strip.h:131
void set_select_cb(boost::function< void()> &)
boost::function< void()> _select_plugin_functor
Definition: fp8_strip.h:159
void set_x_select_controllable(std::shared_ptr< ARDOUR::AutomationControl >)
PBD::Controllable::GroupControlDisposition group_mode() const
std::shared_ptr< ARDOUR::ReadOnlyControl > _redux_ctrl
Definition: fp8_strip.h:156
FP8ButtonInterface & select_button()
Definition: fp8_strip.h:71
FP8ButtonInterface & mute_button()
Definition: fp8_strip.h:68
void set_select_button_color(uint32_t color)
Definition: fp8_strip.h:73
void set_periodic_display_mode(DisplayMode m)
FP8MomentaryButton _solo
Definition: fp8_strip.h:130
FP8ARMSensitiveButton _selrec
Definition: fp8_strip.h:132
PBD::ScopedConnection _pan_connection
Definition: fp8_strip.h:152
std::shared_ptr< ARDOUR::AutomationControl > _solo_ctrl
Definition: fp8_strip.h:143
PBD::ScopedConnection _fader_connection
Definition: fp8_strip.h:148
unsigned short _last_fader
Definition: fp8_strip.h:187
void set_fader_controllable(std::shared_ptr< ARDOUR::AutomationControl >)
void set_pan_controllable(std::shared_ptr< ARDOUR::AutomationControl >)
PBD::ScopedConnectionList _button_connections
Definition: fp8_strip.h:137
void set_mute_controllable(std::shared_ptr< ARDOUR::AutomationControl >)
void set_text_line(uint8_t, std::string const &, bool inv=false)
void set_strip_mode(uint8_t, bool clear=false)
PBD::ScopedConnection _solo_connection
Definition: fp8_strip.h:150
PBD::ScopedConnection _x_select_connection
Definition: fp8_strip.h:153
void set_select_controllable(std::shared_ptr< ARDOUR::AutomationControl >)
std::shared_ptr< ARDOUR::AutomationControl > _pan_ctrl
Definition: fp8_strip.h:145
PBD::ScopedConnection _base_connection
Definition: fp8_strip.h:136
std::shared_ptr< ARDOUR::AutomationControl > _x_select_ctrl
Definition: fp8_strip.h:146
FP8ButtonInterface & selrec_button()
Definition: fp8_strip.h:69
std::shared_ptr< ARDOUR::AutomationControl > _fader_ctrl
Definition: fp8_strip.h:141
PBD::ScopedConnection _mute_connection
Definition: fp8_strip.h:149
static uint8_t midi_ctrl_id(CtrlElement type, uint8_t id)
void set_stripable(std::shared_ptr< ARDOUR::Stripable >, bool panmode)
void set_rec_controllable(std::shared_ptr< ARDOUR::AutomationControl >)
std::shared_ptr< ARDOUR::AutomationControl > _mute_ctrl
Definition: fp8_strip.h:142
std::shared_ptr< ARDOUR::PeakMeter > _peak_meter
Definition: fp8_strip.h:155
PBD::ScopedConnection _rec_connection
Definition: fp8_strip.h:151
FP8ButtonInterface & solo_button()
Definition: fp8_strip.h:67
std::shared_ptr< ARDOUR::AutomationControl > _rec_ctrl
Definition: fp8_strip.h:144
void set_solo_controllable(std::shared_ptr< ARDOUR::AutomationControl >)
void unset_controllables(int which=CTRL_ALL)
void set_bar_mode(uint8_t, bool force=false)
#define FP_NAMESPACE
Definition: fp8_base.h:32
PBD::PropertyDescriptor< uint32_t > color