1 #ifndef mackie_surface_h
2 #define mackie_surface_h
6 #include "midi++/types.h"
10 #include "mackie_midi_builder.h"
11 #include "mackie_jog_wheel.h"
18 class MackieControlProtocol;
23 class MackieButtonHandler;
25 class MackieMidiBuilder;
34 class Surface : public PBD::ScopedConnectionList
37 Surface (MackieControlProtocol&, jack_client_t* jack, const std::string& device_name, uint32_t number, surface_type_t stype);
40 surface_type_t type() const { return _stype; }
41 uint32_t number() const { return _number; }
43 MackieControlProtocol& mcp() const { return _mcp; }
45 bool active() const { return _active; }
48 typedef std::vector<Control*> Controls;
51 std::map<int,Fader*> faders;
52 std::map<int,Pot*> pots;
53 std::map<int,Button*> buttons;
54 std::map<int,Led*> leds;
55 std::map<int,Meter*> meters;
57 /// no strip controls in here because they usually
58 /// have the same names.
59 std::map<std::string,Control*> controls_by_name;
61 Mackie::JogWheel* jog_wheel() const { return _jog_wheel; }
63 /// The collection of all numbered strips. No master
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 const MidiByteArray& sysex_hdr() const;
81 void handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t, uint32_t channel_id);
82 void handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes*);
83 void handle_midi_note_on_message (MIDI::Parser&, MIDI::EventTwoBytes*);
85 /// Connect the any signal from the parser to handle_midi_any
86 /// unless it's already connected
87 void connect_to_signals ();
89 /// notification from a MackiePort that it's now inactive
90 void handle_port_inactive(Mackie::SurfacePort *);
92 /// write a sysex message
93 void write_sysex (const MidiByteArray& mba);
94 void write_sysex (MIDI::byte msg);
95 /// proxy write for port
96 void write (const MidiByteArray&);
98 /// display an indicator of the first switched-in Route. Do nothing by default.
99 void display_bank_start (uint32_t /*current_bank*/);
101 /// called from MackieControlProtocol::zero_all to turn things off
104 /// turn off leds around the jog wheel. This is for surfaces that use a pot
105 /// pretending to be a jog wheel.
106 void blank_jog_ring ();
108 bool has_timecode_display() const;
109 void display_timecode (const std::string & /*timecode*/, const std::string & /*timecode_last*/);
112 This is used to calculate the clicks per second that define
113 a transport speed of 1.0 for the jog wheel. 100.0 is 10 clicks
114 per second, 50.5 is 5 clicks per second.
116 float scrub_scaling_factor() const;
119 The scaling factor function for speed increase and decrease. At
120 low transport speeds this should return a small value, for high transport
121 speeds, this should return an exponentially larger value. This provides
122 high definition control at low speeds and quick speed changes to/from
125 float scaled_delta (const ControlState & state, float current_speed);
127 void handle_control_event (Mackie::Control & control, const Mackie::ControlState & state);
130 void init_controls();
134 MackieControlProtocol& _mcp;
136 surface_type_t _stype;
140 Mackie::JogWheel* _jog_wheel;
141 MackieMidiBuilder builder;
143 void jog_wheel_state_display (Mackie::JogWheel::State state);