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; }
57 typedef std::vector<Control*> Controls;
60 std::map<int,Fader*> faders;
61 std::map<int,Pot*> pots;
62 std::map<int,Button*> buttons; // index is device-DEPENDENT
63 std::map<int,Led*> leds;
64 std::map<int,Meter*> meters;
65 std::map<int,Control*> controls_by_device_independent_id;
67 Mackie::JogWheel* jog_wheel() const { return _jog_wheel; }
68 Fader* master_fader() const { return _master_fader; }
70 /// The collection of all numbered strips.
71 typedef std::vector<Strip*> Strips;
74 uint32_t n_strips (bool with_locked_strips = true) const;
75 Strip* nth_strip (uint32_t n) const;
77 bool route_is_locked_to_strip (boost::shared_ptr<ARDOUR::Route>) const;
79 /// This collection owns the groups
80 typedef std::map<std::string,Group*> Groups;
83 SurfacePort& port() const { return *_port; }
85 void map_routes (const std::vector<boost::shared_ptr<ARDOUR::Route> >& routes);
87 const MidiByteArray& sysex_hdr() const;
89 void periodic (uint64_t now_usecs);
91 void handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t, uint32_t channel_id);
92 void handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes*);
93 void handle_midi_note_on_message (MIDI::Parser&, MIDI::EventTwoBytes*);
95 /// Connect the any signal from the parser to handle_midi_any
96 /// unless it's already connected
97 void connect_to_signals ();
99 /// write a sysex message
100 void write_sysex (const MidiByteArray& mba);
101 void write_sysex (MIDI::byte msg);
102 /// proxy write for port
103 void write (const MidiByteArray&);
105 /// display an indicator of the first switched-in Route. Do nothing by default.
106 void display_bank_start (uint32_t /*current_bank*/);
108 /// called from MackieControlProtocol::zero_all to turn things off
110 void zero_controls ();
112 /// turn off leds around the jog wheel. This is for surfaces that use a pot
113 /// pretending to be a jog wheel.
114 void blank_jog_ring ();
116 void display_timecode (const std::string & /*timecode*/, const std::string & /*timecode_last*/);
118 /// sends MCP "reset" message to surface
121 void recalibrate_faders ();
122 void toggle_backlight ();
123 void set_touch_sensitivity (int);
126 This is used to calculate the clicks per second that define
127 a transport speed of 1.0 for the jog wheel. 100.0 is 10 clicks
128 per second, 50.5 is 5 clicks per second.
130 float scrub_scaling_factor() const;
133 The scaling factor function for speed increase and decrease. At
134 low transport speeds this should return a small value, for high transport
135 speeds, this should return an exponentially larger value. This provides
136 high definition control at low speeds and quick speed changes to/from
139 float scaled_delta (float delta, float current_speed);
141 // display the first 2 chars of the msg in the 2 char display
142 // . is appended to the previous character, so A.B. would
144 void show_two_char_display (const std::string & msg, const std::string & dots = " ");
145 void show_two_char_display (unsigned int value, const std::string & dots = " ");
147 void update_view_mode_display ();
148 void update_flip_mode_display ();
150 void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
152 MackieControlProtocol& mcp() const { return _mcp; }
154 void next_jog_mode ();
155 void set_jog_mode (Mackie::JogWheel::Mode);
157 void notify_metering_state_changed();
160 XMLNode& get_state ();
161 int set_state (const XMLNode&, int version);
166 MackieControlProtocol& _mcp;
168 surface_type_t _stype;
173 Mackie::JogWheel* _jog_wheel;
174 Fader* _master_fader;
175 float _last_master_gain_written;
177 void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
178 MidiByteArray host_connection_query (MidiByteArray& bytes);
179 MidiByteArray host_connection_confirmation (const MidiByteArray& bytes);
181 void init_controls ();
182 void init_strips (uint32_t n);
183 void setup_master ();
184 void master_gain_changed ();