1 #ifndef mackie_surface_h
2 #define mackie_surface_h
6 #include "midi++/types.h"
8 #include "control_protocol/types.h"
12 #include "jog_wheel.h"
23 class MackieControlProtocol;
28 class MackieButtonHandler;
30 class MackieMidiBuilder;
38 class Surface : public PBD::ScopedConnectionList
41 Surface (MackieControlProtocol&, const std::string& name, uint32_t number, surface_type_t stype);
44 surface_type_t type() const { return _stype; }
45 uint32_t number() const { return _number; }
46 const std::string& name() { return _name; }
50 bool active() const { return _active; }
53 typedef std::vector<Control*> Controls;
56 std::map<int,Fader*> faders;
57 std::map<int,Pot*> pots;
58 std::map<int,Button*> buttons; // index is device-DEPENDENT
59 std::map<int,Led*> leds;
60 std::map<int,Meter*> meters;
61 std::map<int,Control*> controls_by_device_independent_id;
63 Mackie::JogWheel* jog_wheel() const { return _jog_wheel; }
64 Fader* master_fader() const { return _master_fader; }
66 /// The collection of all numbered strips.
67 typedef std::vector<Strip*> Strips;
70 uint32_t n_strips (bool with_locked_strips = true) const;
71 Strip* nth_strip (uint32_t n) const;
73 bool route_is_locked_to_strip (boost::shared_ptr<ARDOUR::Route>) const;
75 /// This collection owns the groups
76 typedef std::map<std::string,Group*> Groups;
79 SurfacePort& port() const { return *_port; }
81 void map_routes (const std::vector<boost::shared_ptr<ARDOUR::Route> >& routes);
83 const MidiByteArray& sysex_hdr() const;
85 void periodic (uint64_t now_usecs);
87 void handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t, uint32_t channel_id);
88 void handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes*);
89 void handle_midi_note_on_message (MIDI::Parser&, MIDI::EventTwoBytes*);
91 /// Connect the any signal from the parser to handle_midi_any
92 /// unless it's already connected
93 void connect_to_signals ();
95 /// notification from a MackiePort that it's now inactive
96 void handle_port_inactive(Mackie::SurfacePort *);
98 /// write a sysex message
99 void write_sysex (const MidiByteArray& mba);
100 void write_sysex (MIDI::byte msg);
101 /// proxy write for port
102 void write (const MidiByteArray&);
104 /// display an indicator of the first switched-in Route. Do nothing by default.
105 void display_bank_start (uint32_t /*current_bank*/);
107 /// called from MackieControlProtocol::zero_all to turn things off
109 void zero_controls ();
111 /// turn off leds around the jog wheel. This is for surfaces that use a pot
112 /// pretending to be a jog wheel.
113 void blank_jog_ring ();
115 void display_timecode (const std::string & /*timecode*/, const std::string & /*timecode_last*/);
118 This is used to calculate the clicks per second that define
119 a transport speed of 1.0 for the jog wheel. 100.0 is 10 clicks
120 per second, 50.5 is 5 clicks per second.
122 float scrub_scaling_factor() const;
125 The scaling factor function for speed increase and decrease. At
126 low transport speeds this should return a small value, for high transport
127 speeds, this should return an exponentially larger value. This provides
128 high definition control at low speeds and quick speed changes to/from
131 float scaled_delta (float delta, float current_speed);
133 // display the first 2 chars of the msg in the 2 char display
134 // . is appended to the previous character, so A.B. would
136 void show_two_char_display (const std::string & msg, const std::string & dots = " ");
137 void show_two_char_display (unsigned int value, const std::string & dots = " ");
139 void update_view_mode_display ();
140 void update_flip_mode_display ();
142 void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
144 MackieControlProtocol& mcp() const { return _mcp; }
146 void next_jog_mode ();
147 void set_jog_mode (Mackie::JogWheel::Mode);
149 void notify_metering_state_changed();
154 MackieControlProtocol& _mcp;
156 surface_type_t _stype;
161 Mackie::JogWheel* _jog_wheel;
162 Fader* _master_fader;
163 float _last_master_gain_written;
165 void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
166 MidiByteArray host_connection_query (MidiByteArray& bytes);
167 MidiByteArray host_connection_confirmation (const MidiByteArray& bytes);
169 void init_controls ();
170 void init_strips (uint32_t n);
171 void setup_master ();
172 void master_gain_changed ();