1 #ifndef mackie_surface_h
2 #define mackie_surface_h
6 #include "midi++/types.h"
10 #include "mackie_jog_wheel.h"
21 class MackieControlProtocol;
26 class MackieButtonHandler;
28 class MackieMidiBuilder;
36 class Surface : public PBD::ScopedConnectionList
39 Surface (MackieControlProtocol&, jack_client_t* jack, const std::string& device_name, uint32_t number, surface_type_t stype);
42 surface_type_t type() const { return _stype; }
43 uint32_t number() const { return _number; }
45 MackieControlProtocol& mcp() const { return _mcp; }
47 bool active() const { return _active; }
50 typedef std::vector<Control*> Controls;
53 std::map<int,Fader*> faders;
54 std::map<int,Pot*> pots;
55 std::map<int,Button*> buttons;
56 std::map<int,Led*> leds;
57 std::map<int,Meter*> meters;
59 /// no strip controls in here because they usually
60 /// have the same names.
61 std::map<std::string,Control*> controls_by_name;
63 Mackie::JogWheel* jog_wheel() const { return _jog_wheel; }
65 /// The collection of all numbered strips. No master
67 typedef std::vector<Strip*> Strips;
70 uint32_t n_strips () const;
71 Strip* nth_strip (uint32_t n) const;
73 /// This collection owns the groups
74 typedef std::map<std::string,Group*> Groups;
77 SurfacePort& port() const { return *_port; }
79 void map_routes (const std::vector<boost::shared_ptr<ARDOUR::Route> >& routes);
81 const MidiByteArray& sysex_hdr() const;
85 void handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t, uint32_t channel_id);
86 void handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes*);
87 void handle_midi_note_on_message (MIDI::Parser&, MIDI::EventTwoBytes*);
89 /// Connect the any signal from the parser to handle_midi_any
90 /// unless it's already connected
91 void connect_to_signals ();
93 /// notification from a MackiePort that it's now inactive
94 void handle_port_inactive(Mackie::SurfacePort *);
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
108 /// turn off leds around the jog wheel. This is for surfaces that use a pot
109 /// pretending to be a jog wheel.
110 void blank_jog_ring ();
112 bool has_timecode_display() const;
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 MidiByteArray two_char_display (const std::string & msg, const std::string & dots = " ");
135 MidiByteArray two_char_display (unsigned int value, const std::string & dots = " ");
138 Timecode display. Only the difference between timecode and last_timecode will
139 be encoded, to save midi bandwidth. If they're the same, an empty array will
142 MidiByteArray timecode_display (const std::string & timecode, const std::string & last_timecode = "");
144 void update_view_mode_display ();
147 void init_controls();
151 MackieControlProtocol& _mcp;
153 surface_type_t _stype;
157 Mackie::JogWheel* _jog_wheel;
159 void jog_wheel_state_display (Mackie::JogWheel::State state);