1 #ifndef mackie_surface_h
2 #define mackie_surface_h
7 #include "midi++/types.h"
9 #include "control_protocol/types.h"
13 #include "jog_wheel.h"
25 namespace ArdourSurface {
27 class MackieControlProtocol;
32 class MackieButtonHandler;
34 class MackieMidiBuilder;
42 class Surface : public PBD::ScopedConnectionList
45 Surface (MackieControlProtocol&, const std::string& name, uint32_t number, surface_type_t stype);
48 surface_type_t type() const { return _stype; }
49 uint32_t number() const { return _number; }
50 const std::string& name() { return _name; }
54 bool active() const { return _active; }
56 typedef std::vector<Control*> Controls;
59 std::map<int,Fader*> faders;
60 std::map<int,Pot*> pots;
61 std::map<int,Button*> buttons; // index is device-DEPENDENT
62 std::map<int,Led*> leds;
63 std::map<int,Meter*> meters;
64 std::map<int,Control*> controls_by_device_independent_id;
66 Mackie::JogWheel* jog_wheel() const { return _jog_wheel; }
67 Fader* master_fader() const { return _master_fader; }
69 /// The collection of all numbered strips.
70 typedef std::vector<Strip*> Strips;
73 uint32_t n_strips (bool with_locked_strips = true) const;
74 Strip* nth_strip (uint32_t n) const;
76 bool route_is_locked_to_strip (boost::shared_ptr<ARDOUR::Route>) const;
78 /// This collection owns the groups
79 typedef std::map<std::string,Group*> Groups;
82 SurfacePort& port() const { return *_port; }
84 void map_routes (const std::vector<boost::shared_ptr<ARDOUR::Route> >& routes);
86 const MidiByteArray& sysex_hdr() const;
88 void periodic (uint64_t now_usecs);
90 void hui_heartbeat ();
92 void handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t, uint32_t channel_id);
93 void handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes*);
94 void handle_midi_note_on_message (MIDI::Parser&, MIDI::EventTwoBytes*);
96 /// Connect the any signal from the parser to handle_midi_any
97 /// unless it's already connected
98 void connect_to_signals ();
100 /// write a sysex message
101 void write_sysex (const MidiByteArray& mba);
102 void write_sysex (MIDI::byte msg);
103 /// proxy write for port
104 void write (const MidiByteArray&);
106 /// display an indicator of the first switched-in Route. Do nothing by default.
107 void display_bank_start (uint32_t /*current_bank*/);
109 /// called from MackieControlProtocol::zero_all to turn things off
111 void zero_controls ();
113 /// turn off leds around the jog wheel. This is for surfaces that use a pot
114 /// pretending to be a jog wheel.
115 void blank_jog_ring ();
117 void display_timecode (const std::string & /*timecode*/, const std::string & /*timecode_last*/);
119 /// sends MCP "reset" message to surface
122 void recalibrate_faders ();
123 void toggle_backlight ();
124 void set_touch_sensitivity (int);
127 This is used to calculate the clicks per second that define
128 a transport speed of 1.0 for the jog wheel. 100.0 is 10 clicks
129 per second, 50.5 is 5 clicks per second.
131 float scrub_scaling_factor() const;
134 The scaling factor function for speed increase and decrease. At
135 low transport speeds this should return a small value, for high transport
136 speeds, this should return an exponentially larger value. This provides
137 high definition control at low speeds and quick speed changes to/from
140 float scaled_delta (float delta, float current_speed);
142 // display the first 2 chars of the msg in the 2 char display
143 // . is appended to the previous character, so A.B. would
145 void show_two_char_display (const std::string & msg, const std::string & dots = " ");
146 void show_two_char_display (unsigned int value, const std::string & dots = " ");
148 void update_view_mode_display ();
149 void update_flip_mode_display ();
151 void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
153 MackieControlProtocol& mcp() const { return _mcp; }
155 void next_jog_mode ();
156 void set_jog_mode (Mackie::JogWheel::Mode);
158 void notify_metering_state_changed();
161 XMLNode& get_state ();
162 int set_state (const XMLNode&, int version);
167 MackieControlProtocol& _mcp;
169 surface_type_t _stype;
174 Mackie::JogWheel* _jog_wheel;
175 Fader* _master_fader;
176 float _last_master_gain_written;
178 void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
179 MidiByteArray host_connection_query (MidiByteArray& bytes);
180 MidiByteArray host_connection_confirmation (const MidiByteArray& bytes);
182 void init_controls ();
183 void init_strips (uint32_t n);
184 void setup_master ();
185 void master_gain_changed ();