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"
24 class MackieControlProtocol;
29 class MackieButtonHandler;
31 class MackieMidiBuilder;
39 class Surface : public PBD::ScopedConnectionList
42 Surface (MackieControlProtocol&, const std::string& name, uint32_t number, surface_type_t stype);
45 surface_type_t type() const { return _stype; }
46 uint32_t number() const { return _number; }
47 const std::string& name() { return _name; }
51 bool active() const { return _active; }
54 typedef std::vector<Control*> Controls;
57 std::map<int,Fader*> faders;
58 std::map<int,Pot*> pots;
59 std::map<int,Button*> buttons; // index is device-DEPENDENT
60 std::map<int,Led*> leds;
61 std::map<int,Meter*> meters;
62 std::map<int,Control*> controls_by_device_independent_id;
64 Mackie::JogWheel* jog_wheel() const { return _jog_wheel; }
65 Fader* master_fader() const { return _master_fader; }
67 /// The collection of all numbered strips.
68 typedef std::vector<Strip*> Strips;
71 uint32_t n_strips (bool with_locked_strips = true) const;
72 Strip* nth_strip (uint32_t n) const;
74 bool route_is_locked_to_strip (boost::shared_ptr<ARDOUR::Route>) const;
76 /// This collection owns the groups
77 typedef std::map<std::string,Group*> Groups;
80 SurfacePort& port() const { return *_port; }
82 void map_routes (const std::vector<boost::shared_ptr<ARDOUR::Route> >& routes);
84 const MidiByteArray& sysex_hdr() const;
86 void periodic (uint64_t now_usecs);
88 void handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t, uint32_t channel_id);
89 void handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes*);
90 void handle_midi_note_on_message (MIDI::Parser&, MIDI::EventTwoBytes*);
92 /// Connect the any signal from the parser to handle_midi_any
93 /// unless it's already connected
94 void connect_to_signals ();
96 /// write a sysex message
97 void write_sysex (const MidiByteArray& mba);
98 void write_sysex (MIDI::byte msg);
99 /// proxy write for port
100 void write (const MidiByteArray&);
102 /// display an indicator of the first switched-in Route. Do nothing by default.
103 void display_bank_start (uint32_t /*current_bank*/);
105 /// called from MackieControlProtocol::zero_all to turn things off
107 void zero_controls ();
109 /// turn off leds around the jog wheel. This is for surfaces that use a pot
110 /// pretending to be a jog wheel.
111 void blank_jog_ring ();
113 void display_timecode (const std::string & /*timecode*/, const std::string & /*timecode_last*/);
116 This is used to calculate the clicks per second that define
117 a transport speed of 1.0 for the jog wheel. 100.0 is 10 clicks
118 per second, 50.5 is 5 clicks per second.
120 float scrub_scaling_factor() const;
123 The scaling factor function for speed increase and decrease. At
124 low transport speeds this should return a small value, for high transport
125 speeds, this should return an exponentially larger value. This provides
126 high definition control at low speeds and quick speed changes to/from
129 float scaled_delta (float delta, float current_speed);
131 // display the first 2 chars of the msg in the 2 char display
132 // . is appended to the previous character, so A.B. would
134 void show_two_char_display (const std::string & msg, const std::string & dots = " ");
135 void show_two_char_display (unsigned int value, const std::string & dots = " ");
137 void update_view_mode_display ();
138 void update_flip_mode_display ();
140 void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
142 MackieControlProtocol& mcp() const { return _mcp; }
144 void next_jog_mode ();
145 void set_jog_mode (Mackie::JogWheel::Mode);
147 void notify_metering_state_changed();
150 XMLNode& get_state ();
151 int set_state (const XMLNode&, int version);
156 MackieControlProtocol& _mcp;
158 surface_type_t _stype;
163 Mackie::JogWheel* _jog_wheel;
164 Fader* _master_fader;
165 float _last_master_gain_written;
167 void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
168 MidiByteArray host_connection_query (MidiByteArray& bytes);
169 MidiByteArray host_connection_confirmation (const MidiByteArray& bytes);
171 void init_controls ();
172 void init_strips (uint32_t n);
173 void setup_master ();
174 void master_gain_changed ();