Ardour  9.0-pre0-384-ga76afae0e9
us2400/surface.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Ben Loftis <ben@harrisonconsoles.com>
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 us2400_surface_h
20 #define us2400_surface_h
21 
22 #include <stdint.h>
23 
24 #include <sigc++/trackable.h>
25 
26 #include "pbd/signals.h"
27 #include "pbd/xml++.h"
28 #include "midi++/types.h"
29 
30 #include "ardour/types.h"
31 
32 #include "control_protocol/types.h"
33 
34 #include "controls.h"
35 #include "types.h"
36 #include "jog_wheel.h"
37 
38 namespace MIDI {
39  class Parser;
40 }
41 
42 namespace ARDOUR {
43  class Stripable;
44  class Port;
45 }
46 
47 class MidiByteArray;
48 
49 namespace ArdourSurface {
50 
51 class US2400Protocol;
52 
53 namespace US2400
54 {
55 
56 class MackieButtonHandler;
57 class SurfacePort;
58 class MackieMidiBuilder;
59 class Button;
60 class Meter;
61 class Fader;
62 class Jog;
63 class Pot;
64 class Led;
65 
66 class Surface : public PBD::ScopedConnectionList, public sigc::trackable
67 {
68 public:
69  Surface (US2400Protocol&, const std::string& name, uint32_t number, surface_type_t stype);
70  virtual ~Surface();
71 
72  surface_type_t type() const { return _stype; }
73  uint32_t number() const { return _number; }
74  const std::string& name() { return _name; }
75 
76  void connected ();
77 
78  bool active() const { return _active; }
79 
80  typedef std::vector<Control*> Controls;
82 
83  std::map<int,Fader*> faders;
84  std::map<int,Pot*> pots;
85  std::map<int,Button*> buttons; // index is device-DEPENDENT
86  std::map<int,Led*> leds;
87  std::map<int,Meter*> meters;
88  std::map<int,Control*> controls_by_device_independent_id;
89 
90  US2400::JogWheel* jog_wheel() const { return _jog_wheel; }
91  Fader* master_fader() const { return _master_fader; }
92 
94  typedef std::vector<Strip*> Strips;
96 
97  uint32_t n_strips (bool with_locked_strips = true) const;
98  Strip* nth_strip (uint32_t n) const;
99 
100  bool stripable_is_locked_to_strip (std::shared_ptr<ARDOUR::Stripable>) const;
101  bool stripable_is_mapped (std::shared_ptr<ARDOUR::Stripable>) const;
102 
104  typedef std::map<std::string,Group*> Groups;
106 
107  SurfacePort& port() const { return *_port; }
108 
109  void map_stripables (const std::vector<std::shared_ptr<ARDOUR::Stripable> >&);
110 
112 
113  const MidiByteArray& sysex_hdr() const;
114 
115  void periodic (PBD::microseconds_t now_usecs);
116  void redisplay (PBD::microseconds_t now_usecs, bool force);
117  void hui_heartbeat ();
118 
122 
126 
128  void write_sysex (const MidiByteArray& mba);
131  void write (const MidiByteArray&);
132 
134  void display_bank_start (uint32_t /*current_bank*/);
135 
137  void zero_all ();
138  void zero_controls ();
139 
142  void blank_jog_ring ();
143 
145  void reset ();
146 
150 
156  float scrub_scaling_factor() const;
157 
165  float scaled_delta (float delta, float current_speed);
166 
168 
169  US2400Protocol& mcp() const { return _mcp; }
170 
171  void next_jog_mode ();
173 
175  void turn_it_on ();
176 
177  bool connection_handler (std::weak_ptr<ARDOUR::Port>, std::string name1, std::weak_ptr<ARDOUR::Port>, std::string name2, bool);
178 
180 
181  XMLNode& get_state () const;
182  int set_state (const XMLNode&, int version);
183 
184  private:
188  uint32_t _number;
189  std::string _name;
190  bool _active;
197 
198  void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
201 
202  void say_hello ();
203  void init_controls ();
204  void init_strips (uint32_t n);
205  void setup_master ();
207 
210  OutputConnected = 0x2
211  };
212 
214 
215  public:
216  /* IP MIDI devices need to keep a handle on this and destroy it */
217  GSource* input_source;
218 };
219 
220 }
221 }
222 
223 #endif
std::vector< Control * > Controls
Strip * nth_strip(uint32_t n) const
std::map< int, Control * > controls_by_device_independent_id
void write(const MidiByteArray &)
proxy write for port
US2400Protocol & mcp() const
void handle_midi_sysex(MIDI::Parser &, MIDI::byte *, size_t count)
std::map< int, Pot * > pots
uint32_t n_strips(bool with_locked_strips=true) const
Surface(US2400Protocol &, const std::string &name, uint32_t number, surface_type_t stype)
void map_stripables(const std::vector< std::shared_ptr< ARDOUR::Stripable > > &)
bool connection_handler(std::weak_ptr< ARDOUR::Port >, std::string name1, std::weak_ptr< ARDOUR::Port >, std::string name2, bool)
std::map< int, Button * > buttons
bool stripable_is_mapped(std::shared_ptr< ARDOUR::Stripable >) const
std::map< int, Meter * > meters
bool stripable_is_locked_to_strip(std::shared_ptr< ARDOUR::Stripable >) const
void periodic(PBD::microseconds_t now_usecs)
std::vector< Strip * > Strips
The collection of all numbered strips.
void set_jog_mode(US2400::JogWheel::Mode)
float scaled_delta(float delta, float current_speed)
void display_bank_start(uint32_t)
display an indicator of the first switched-in Route. Do nothing by default.
PBD::ScopedConnection master_connection
std::map< int, Led * > leds
std::map< int, Fader * > faders
const std::string & name()
void redisplay(PBD::microseconds_t now_usecs, bool force)
void reset()
sends MCP "reset" message to surface
const MidiByteArray & sysex_hdr() const
surface_type_t type() const
MidiByteArray host_connection_confirmation(const MidiByteArray &bytes)
void handle_midi_note_on_message(MIDI::Parser &, MIDI::EventTwoBytes *)
void write_sysex(MIDI::byte msg)
SurfacePort & port() const
void zero_all()
called from US2400Protocol::zero_all to turn things off
void write_sysex(const MidiByteArray &mba)
write a sysex message
int set_state(const XMLNode &, int version)
std::map< std::string, Group * > Groups
This collection owns the groups.
MidiByteArray host_connection_query(MidiByteArray &bytes)
void handle_midi_pitchbend_message(MIDI::Parser &, MIDI::pitchbend_t, uint32_t channel_id)
void handle_midi_controller_message(MIDI::Parser &, MIDI::EventTwoBytes *)
US2400::JogWheel * jog_wheel() const
Definition: xml++.h:114
unsigned short pitchbend_t
DebugBits US2400
int64_t microseconds_t
Definition: microseconds.h:28
minimum disk read bytes