1 #ifndef mackie_surface_h
2 #define mackie_surface_h
6 #include "midi++/types.h"
8 #include "control_protocol/types.h"
12 #include "mackie_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; }
48 bool active() const { return _active; }
51 typedef std::vector<Control*> Controls;
54 std::map<int,Fader*> faders;
55 std::map<int,Pot*> pots;
56 std::map<int,Button*> buttons; // index is device-DEPENDENT
57 std::map<int,Led*> leds;
58 std::map<int,Meter*> meters;
59 std::map<int,Control*> controls_by_device_independent_id;
61 Mackie::JogWheel* jog_wheel() const { return _jog_wheel; }
62 Fader* master_fader() const { return _master_fader; }
64 /// The collection of all numbered strips.
65 typedef std::vector<Strip*> Strips;
68 uint32_t n_strips () const;
69 Strip* nth_strip (uint32_t n) const;
71 /// This collection owns the groups
72 typedef std::map<std::string,Group*> Groups;
75 SurfacePort& port() const { return *_port; }
77 void map_routes (const std::vector<boost::shared_ptr<ARDOUR::Route> >& routes);
79 const MidiByteArray& sysex_hdr() const;
81 void periodic (uint64_t now_usecs);
83 void handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t, uint32_t channel_id);
84 void handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes*);
85 void handle_midi_note_on_message (MIDI::Parser&, MIDI::EventTwoBytes*);
87 /// Connect the any signal from the parser to handle_midi_any
88 /// unless it's already connected
89 void connect_to_signals ();
91 /// notification from a MackiePort that it's now inactive
92 void handle_port_inactive(Mackie::SurfacePort *);
94 /// write a sysex message
95 void write_sysex (const MidiByteArray& mba);
96 void write_sysex (MIDI::byte msg);
97 /// proxy write for port
98 void write (const MidiByteArray&);
100 /// display an indicator of the first switched-in Route. Do nothing by default.
101 void display_bank_start (uint32_t /*current_bank*/);
103 /// called from MackieControlProtocol::zero_all to turn things off
106 /// turn off leds around the jog wheel. This is for surfaces that use a pot
107 /// pretending to be a jog wheel.
108 void blank_jog_ring ();
110 bool has_timecode_display() const;
111 void display_timecode (const std::string & /*timecode*/, const std::string & /*timecode_last*/);
114 This is used to calculate the clicks per second that define
115 a transport speed of 1.0 for the jog wheel. 100.0 is 10 clicks
116 per second, 50.5 is 5 clicks per second.
118 float scrub_scaling_factor() const;
121 The scaling factor function for speed increase and decrease. At
122 low transport speeds this should return a small value, for high transport
123 speeds, this should return an exponentially larger value. This provides
124 high definition control at low speeds and quick speed changes to/from
127 float scaled_delta (float delta, float current_speed);
129 // display the first 2 chars of the msg in the 2 char display
130 // . is appended to the previous character, so A.B. would
132 MidiByteArray two_char_display (const std::string & msg, const std::string & dots = " ");
133 MidiByteArray two_char_display (unsigned int value, const std::string & dots = " ");
136 Timecode display. Only the difference between timecode and last_timecode will
137 be encoded, to save midi bandwidth. If they're the same, an empty array will
140 MidiByteArray timecode_display (const std::string & timecode, const std::string & last_timecode = "");
142 void update_view_mode_display ();
143 void update_flip_mode_display ();
145 void gui_selection_changed (ARDOUR::RouteNotificationListPtr);
147 MackieControlProtocol& mcp() const { return _mcp; }
152 MackieControlProtocol& _mcp;
154 surface_type_t _stype;
159 Mackie::JogWheel* _jog_wheel;
160 Fader* _master_fader;
162 void jog_wheel_state_display (Mackie::JogWheel::State state);
163 void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
164 MidiByteArray host_connection_query (MidiByteArray& bytes);
165 MidiByteArray host_connection_confirmation (const MidiByteArray& bytes);
167 void init_controls();
168 void init_strips (uint32_t n);
169 void setup_master ();
170 void master_gain_changed ();