Ardour  9.0-rc1-21-gd5464b39db
mackie/surface.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2007 John Anderson
3  * Copyright (C) 2012-2015 Paul Davis <paul@linuxaudiosystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef mackie_surface_h
21 #define mackie_surface_h
22 
23 #include <array>
24 #include <stdint.h>
25 
26 #include <sigc++/trackable.h>
27 
28 #include "pbd/property_basics.h"
29 #include "pbd/signals.h"
30 #include "pbd/xml++.h"
31 #include "midi++/types.h"
32 
33 #include "ardour/types.h"
34 
35 #include "control_protocol/types.h"
36 
37 #include "controls.h"
38 #include "types.h"
39 #include "jog_wheel.h"
40 
41 namespace MIDI {
42  class Parser;
43 }
44 
45 namespace ARDOUR {
46  class Stripable;
47  class Port;
48 }
49 
50 class MidiByteArray;
51 
52 namespace ArdourSurface { namespace MACKIE_NAMESPACE {
53 
54 class MackieControlProtocol;
55 class MackieButtonHandler;
56 class SurfacePort;
57 class MackieMidiBuilder;
58 class Button;
59 class Meter;
60 class Fader;
61 class Jog;
62 class Pot;
63 class Led;
64 
65 class Surface : public PBD::ScopedConnectionList, public sigc::trackable
66 {
67 public:
68  enum XTouchColors {
69  Off,
70  Red,
77  };
78 
79  Surface (MackieControlProtocol&, const std::string& name, uint32_t number, surface_type_t stype);
80  virtual ~Surface();
81 
82  surface_type_t type() const { return _stype; }
83  uint32_t number() const { return _number; }
84  const std::string& name() { return _name; }
85 
86  void connected ();
87 
88  bool active() const { return _active; }
89 
90  typedef std::vector<Control*> Controls;
92 
93  std::map<int,Fader*> faders;
94  std::map<int,Pot*> pots;
95  std::map<int,Button*> buttons; // index is device-DEPENDENT
96  std::map<int,Led*> leds;
97  std::map<int,Meter*> meters;
98  std::map<int,Control*> controls_by_device_independent_id;
99 
100  MACKIE_NAMESPACE::JogWheel* jog_wheel() const { return _jog_wheel; }
101  Fader* master_fader() const { return _master_fader; }
102 
104  typedef std::vector<Strip*> Strips;
106 
107  uint32_t n_strips (bool with_locked_strips = true) const;
108  Strip* nth_strip (uint32_t n) const;
109 
110  bool stripable_is_locked_to_strip (std::shared_ptr<ARDOUR::Stripable>) const;
111  bool stripable_is_mapped (std::shared_ptr<ARDOUR::Stripable>) const;
112 
114  typedef std::map<std::string,Group*> Groups;
116 
117  SurfacePort& port() const { return *_port; }
118 
119  void map_stripables (const std::vector<std::shared_ptr<ARDOUR::Stripable> >&);
120 
122 
123  const MidiByteArray& sysex_hdr() const;
124 
125  void periodic (PBD::microseconds_t now_usecs);
126  void redisplay (PBD::microseconds_t now_usecs, bool force);
127  void hui_heartbeat ();
128 
132 
136 
138  void write_sysex (const MidiByteArray& mba);
141  void write (const MidiByteArray&);
142 
144  void display_bank_start (uint32_t /*current_bank*/);
145 
147  void zero_all ();
148  void zero_controls ();
149 
152  void blank_jog_ring ();
153 
154  void display_timecode (const std::string & /*timecode*/, const std::string & /*timecode_last*/);
155 
157  void reset ();
158 
162 
168  float scrub_scaling_factor() const;
169 
177  float scaled_delta (float delta, float current_speed);
178 
179  // display the first 2 chars of the msg in the 2 char display
180  // . is appended to the previous character, so A.B. would
181  // be two characters
182  void show_two_char_display (const std::string & msg, const std::string & dots = " ");
183  void show_two_char_display (unsigned int value, const std::string & dots = " ");
184 
185  void update_view_mode_display (bool with_helpful_text);
187 
189 
190  MackieControlProtocol& mcp() const { return _mcp; }
191 
192  void next_jog_mode ();
193  void set_jog_mode (MACKIE_NAMESPACE::JogWheel::Mode);
194 
196  void turn_it_on ();
197 
198  void display_message_for (std::string const& msg, uint64_t msecs);
199 
200  bool connection_handler (std::weak_ptr<ARDOUR::Port>, std::string name1, std::weak_ptr<ARDOUR::Port>, std::string name2, bool);
201 
203 
204  XMLNode& get_state () const;
205  int set_state (const XMLNode&, int version);
206 
207  bool get_qcon_flag() { return is_qcon; }
208 
209  bool get_v1_flag() { return is_v1m; }
210  bool get_p1m_flag() { return is_p1m; }
211  bool get_p1nano_flag() { return is_p1nano; }
212 
213  void force_icon_rgb_update() { _pending_icon_rgb.fill(0xFF); }
214 
217 
218  private:
222  uint32_t _number;
223  std::string _name;
224  bool _active;
226  MACKIE_NAMESPACE::JogWheel* _jog_wheel;
232  std::shared_ptr<ARDOUR::Stripable> _master_stripable;
233 
234  std::string pending_display[2];
235  std::string current_display[2];
236 
237  // iCON P1-M / V1-M RGB — same pattern as master display
238  std::array<uint8_t, 24> _pending_icon_rgb{};
239  std::array<uint8_t, 24> _current_icon_rgb{};
240 
241  void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
244 
245  void say_hello ();
246  void init_controls ();
247  void init_strips (uint32_t n);
248  void setup_master ();
253  MidiByteArray master_display (uint32_t line_number, const std::string&); // QCon ProX 2nd LCD master label
254  MidiByteArray blank_master_display (uint32_t line_number);
255 
257  InputConnected = 0x1,
258  OutputConnected = 0x2
259  };
260 
262 
263  // QCon Flag
264  bool is_qcon;
265 
266  MidiByteArray display_line (std::string const& msg, int line_num);
268  uint8_t convert_color_to_xtouch_value (uint32_t color) const;
269 
270  // iCON Flags
271  bool is_v1m;
272  bool is_p1m;
273  bool is_p1nano;
274 
276  MidiByteArray display_colors_on_p1m_v1m (const std::array<uint8_t, 24>& rgb_values) const;
277  std::array<uint8_t, 24> _solid_icon_rgb{}; // stores the real solid colors
278  bool _blink_state = false; // true = full brightness, false = dim/off
279  uint64_t _last_blink_toggle = 0;
280 
281  public:
282  /* IP MIDI devices need to keep a handle on this and destroy it */
283  GSource* input_source;
284 };
285 
286 }
287 }
288 
289 #endif
std::map< int, Control * > controls_by_device_independent_id
const MidiByteArray & sysex_hdr() const
void reset()
sends MCP "reset" message to surface
MackieControlProtocol & mcp() const
void master_property_changed(const PBD::PropertyChange &)
void display_bank_start(uint32_t)
display an indicator of the first switched-in Route. Do nothing by default.
void handle_midi_sysex(MIDI::Parser &, MIDI::byte *, size_t count)
void periodic(PBD::microseconds_t now_usecs)
std::map< int, Led * > leds
void display_timecode(const std::string &, const std::string &)
PBD::ScopedConnection master_connection
MidiByteArray host_connection_confirmation(const MidiByteArray &bytes)
void handle_midi_note_on_message(MIDI::Parser &, MIDI::EventTwoBytes *)
Strip * nth_strip(uint32_t n) const
MidiByteArray display_colors_on_xtouch(const XTouchColors color_values[]) const
MidiByteArray host_connection_query(MidiByteArray &bytes)
uint32_t n_strips(bool with_locked_strips=true) const
bool connection_handler(std::weak_ptr< ARDOUR::Port >, std::string name1, std::weak_ptr< ARDOUR::Port >, std::string name2, bool)
bool stripable_is_mapped(std::shared_ptr< ARDOUR::Stripable >) const
Surface(MackieControlProtocol &, const std::string &name, uint32_t number, surface_type_t stype)
std::shared_ptr< ARDOUR::Stripable > _master_stripable
MidiByteArray blank_master_display(uint32_t line_number)
SurfacePort & port() const
bool stripable_is_locked_to_strip(std::shared_ptr< ARDOUR::Stripable >) const
std::vector< Control * > Controls
int set_state(const XMLNode &, int version)
std::map< int, Meter * > meters
surface_type_t type() const
uint8_t convert_color_to_xtouch_value(uint32_t color) const
std::map< int, Pot * > pots
MackieControlProtocol & _mcp
void write(const MidiByteArray &)
proxy write for port
void map_stripables(const std::vector< std::shared_ptr< ARDOUR::Stripable > > &)
MidiByteArray display_colors_on_p1m_v1m(const std::array< uint8_t, 24 > &rgb_values) const
void write_sysex(MIDI::byte msg)
std::vector< Strip * > Strips
The collection of all numbered strips.
NS_MCU ::JogWheel * _jog_wheel
const std::string & name()
void write_sysex(const MidiByteArray &mba)
write a sysex message
void show_two_char_display(const std::string &msg, const std::string &dots=" ")
void set_jog_mode(NS_MCU ::JogWheel::Mode)
std::map< int, Button * > buttons
float scaled_delta(float delta, float current_speed)
std::map< int, Fader * > faders
void handle_midi_controller_message(MIDI::Parser &, MIDI::EventTwoBytes *)
MidiByteArray master_display(uint32_t line_number, const std::string &)
void zero_all()
called from MackieControlProtocol::zero_all to turn things off
std::map< std::string, Group * > Groups
This collection owns the groups.
void update_view_mode_display(bool with_helpful_text)
void display_message_for(std::string const &msg, uint64_t msecs)
void handle_midi_pitchbend_message(MIDI::Parser &, MIDI::pitchbend_t, uint32_t channel_id)
void redisplay(PBD::microseconds_t now_usecs, bool force)
NS_MCU ::JogWheel * jog_wheel() const
MidiByteArray display_line(std::string const &msg, int line_num)
void show_two_char_display(unsigned int value, const std::string &dots=" ")
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
PBD::PropertyDescriptor< uint32_t > color
unsigned short pitchbend_t
int64_t microseconds_t
Definition: microseconds.h:28
minimum disk read bytes
#define MACKIE_NAMESPACE