Ardour  9.0-pre0-384-ga76afae0e9
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 <stdint.h>
24 
25 #include <sigc++/trackable.h>
26 
27 #include "pbd/property_basics.h"
28 #include "pbd/signals.h"
29 #include "pbd/xml++.h"
30 #include "midi++/types.h"
31 
32 #include "ardour/types.h"
33 
34 #include "control_protocol/types.h"
35 
36 #include "controls.h"
37 #include "types.h"
38 #include "jog_wheel.h"
39 
40 namespace MIDI {
41  class Parser;
42 }
43 
44 namespace ARDOUR {
45  class Stripable;
46  class Port;
47 }
48 
49 class MidiByteArray;
50 
51 namespace ArdourSurface { namespace MACKIE_NAMESPACE {
52 
53 class MackieControlProtocol;
54 class MackieButtonHandler;
55 class SurfacePort;
56 class MackieMidiBuilder;
57 class Button;
58 class Meter;
59 class Fader;
60 class Jog;
61 class Pot;
62 class Led;
63 
64 class Surface : public PBD::ScopedConnectionList, public sigc::trackable
65 {
66 public:
67  enum XTouchColors {
68  Off,
69  Red,
76  };
77 
78  Surface (MackieControlProtocol&, const std::string& name, uint32_t number, surface_type_t stype);
79  virtual ~Surface();
80 
81  surface_type_t type() const { return _stype; }
82  uint32_t number() const { return _number; }
83  const std::string& name() { return _name; }
84 
85  void connected ();
86 
87  bool active() const { return _active; }
88 
89  typedef std::vector<Control*> Controls;
91 
92  std::map<int,Fader*> faders;
93  std::map<int,Pot*> pots;
94  std::map<int,Button*> buttons; // index is device-DEPENDENT
95  std::map<int,Led*> leds;
96  std::map<int,Meter*> meters;
97  std::map<int,Control*> controls_by_device_independent_id;
98 
99  MACKIE_NAMESPACE::JogWheel* jog_wheel() const { return _jog_wheel; }
100  Fader* master_fader() const { return _master_fader; }
101 
103  typedef std::vector<Strip*> Strips;
105 
106  uint32_t n_strips (bool with_locked_strips = true) const;
107  Strip* nth_strip (uint32_t n) const;
108 
109  bool stripable_is_locked_to_strip (std::shared_ptr<ARDOUR::Stripable>) const;
110  bool stripable_is_mapped (std::shared_ptr<ARDOUR::Stripable>) const;
111 
113  typedef std::map<std::string,Group*> Groups;
115 
116  SurfacePort& port() const { return *_port; }
117 
118  void map_stripables (const std::vector<std::shared_ptr<ARDOUR::Stripable> >&);
119 
121 
122  const MidiByteArray& sysex_hdr() const;
123 
124  void periodic (PBD::microseconds_t now_usecs);
125  void redisplay (PBD::microseconds_t now_usecs, bool force);
126  void hui_heartbeat ();
127 
131 
135 
137  void write_sysex (const MidiByteArray& mba);
140  void write (const MidiByteArray&);
141 
143  void display_bank_start (uint32_t /*current_bank*/);
144 
146  void zero_all ();
147  void zero_controls ();
148 
151  void blank_jog_ring ();
152 
153  void display_timecode (const std::string & /*timecode*/, const std::string & /*timecode_last*/);
154 
156  void reset ();
157 
161 
167  float scrub_scaling_factor() const;
168 
176  float scaled_delta (float delta, float current_speed);
177 
178  // display the first 2 chars of the msg in the 2 char display
179  // . is appended to the previous character, so A.B. would
180  // be two characters
181  void show_two_char_display (const std::string & msg, const std::string & dots = " ");
182  void show_two_char_display (unsigned int value, const std::string & dots = " ");
183 
184  void update_view_mode_display (bool with_helpful_text);
186 
188 
189  MackieControlProtocol& mcp() const { return _mcp; }
190 
191  void next_jog_mode ();
192  void set_jog_mode (MACKIE_NAMESPACE::JogWheel::Mode);
193 
195  void turn_it_on ();
196 
197  void display_message_for (std::string const& msg, uint64_t msecs);
198 
199  bool connection_handler (std::weak_ptr<ARDOUR::Port>, std::string name1, std::weak_ptr<ARDOUR::Port>, std::string name2, bool);
200 
202 
203  XMLNode& get_state () const;
204  int set_state (const XMLNode&, int version);
205 
206  bool get_qcon_flag() { return is_qcon; }
207 
210 
211  private:
215  uint32_t _number;
216  std::string _name;
217  bool _active;
219  MACKIE_NAMESPACE::JogWheel* _jog_wheel;
225  std::shared_ptr<ARDOUR::Stripable> _master_stripable;
226 
227  std::string pending_display[2];
228  std::string current_display[2];
229 
230  void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
233 
234  void say_hello ();
235  void init_controls ();
236  void init_strips (uint32_t n);
237  void setup_master ();
242  MidiByteArray master_display (uint32_t line_number, const std::string&); // QCon ProX 2nd LCD master label
243  MidiByteArray blank_master_display (uint32_t line_number);
244 
246  InputConnected = 0x1,
247  OutputConnected = 0x2
248  };
249 
251 
252  // QCon Flag
253  bool is_qcon;
254 
255  MidiByteArray display_line (std::string const& msg, int line_num);
257  uint8_t convert_color_to_xtouch_value (uint32_t color) const;
258 
259  public:
260  /* IP MIDI devices need to keep a handle on this and destroy it */
261  GSource* input_source;
262 };
263 
264 }
265 }
266 
267 #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 > > &)
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