1 /* 2 * Copyright (C) 2006-2007 John Anderson 3 * Copyright (C) 2012-2015 Paul Davis <paul@linuxaudiosystems.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #ifndef __ardour_mackie_control_protocol_strip_h__ 21 #define __ardour_mackie_control_protocol_strip_h__ 22 23 #include <string> 24 #include <iostream> 25 26 #include "evoral/Parameter.h" 27 28 #include "pbd/property_basics.h" 29 #include "pbd/ringbuffer.h" 30 #include "pbd/signals.h" 31 32 #include "ardour/types.h" 33 #include "control_protocol/types.h" 34 35 #include "control_group.h" 36 #include "types.h" 37 #include "mackie_control_protocol.h" 38 #include "midi_byte_array.h" 39 #include "device_info.h" 40 41 namespace ARDOUR { 42 class Stripable; 43 class Bundle; 44 class ChannelCount; 45 } 46 47 namespace ArdourSurface { 48 49 namespace Mackie { 50 51 class Control; 52 class Surface; 53 class Button; 54 class Pot; 55 class Fader; 56 class Meter; 57 class SurfacePort; 58 59 struct GlobalControlDefinition { 60 const char* name; 61 int id; 62 Control* (*factory)(Surface&, int index, const char* name, Group&); 63 const char* group_name; 64 }; 65 66 /** 67 This is the set of controls that make up a strip. 68 */ 69 class Strip : public Group 70 { 71 public: 72 Strip (Surface&, const std::string & name, int index, const std::map<Button::ID,StripButtonInfo>&); 73 ~Strip(); 74 stripable()75 boost::shared_ptr<ARDOUR::Stripable> stripable() const { return _stripable; } 76 77 void add (Control & control); index()78 int index() const { return _index; } // zero based surface()79 Surface* surface() const { return _surface; } 80 81 void set_stripable (boost::shared_ptr<ARDOUR::Stripable>, bool with_messages = true); 82 83 // call all signal handlers manually 84 void notify_all (); 85 86 void handle_button (Button&, ButtonState bs); 87 void handle_fader (Fader&, float position); 88 void handle_fader_touch (Fader&, bool touch_on); 89 void handle_pot (Pot&, float delta); 90 91 void periodic (PBD::microseconds_t now_usecs); 92 void redisplay (PBD::microseconds_t now_usecs, bool force = true); 93 94 MidiByteArray display (uint32_t line_number, const std::string&); 95 MidiByteArray blank_display (uint32_t line_number); 96 97 static std::string format_paramater_for_display( 98 ARDOUR::ParameterDescriptor const& desc, 99 float val, 100 boost::shared_ptr<ARDOUR::Stripable> stripable_for_non_mixbus_azimuth_automation, 101 bool& overwrite_screen_hold); 102 103 void zero (); 104 105 void flip_mode_changed (); 106 void subview_mode_changed (); 107 108 void lock_controls (); 109 void unlock_controls (); locked()110 bool locked() const { return _controls_locked; } 111 112 void notify_metering_state_changed(); 113 114 void update_selection_state (); 115 116 void block_screen_display_for (uint32_t msecs); 117 void block_vpot_mode_display_for (uint32_t msecs); 118 119 private: 120 enum VPotDisplayMode { 121 Name, 122 Value 123 }; 124 125 Button* _solo; 126 Button* _recenable; 127 Button* _mute; 128 Button* _select; 129 Button* _vselect; 130 Button* _fader_touch; 131 Pot* _vpot; 132 Fader* _fader; 133 Meter* _meter; 134 int _index; 135 Surface* _surface; 136 bool _controls_locked; 137 bool _transport_is_rolling; 138 bool _metering_active; 139 std::string pending_display[2]; 140 std::string current_display[2]; 141 PBD::microseconds_t _block_screen_redisplay_until; 142 PBD::microseconds_t return_to_vpot_mode_display_at; 143 boost::shared_ptr<ARDOUR::Stripable> _stripable; 144 PBD::ScopedConnectionList stripable_connections; 145 146 ARDOUR::AutomationType _pan_mode; 147 148 float _last_gain_position_written; 149 float _last_pan_azi_position_written; 150 float _last_pan_width_position_written; 151 float _last_trim_position_written; 152 153 void notify_solo_changed (); 154 void notify_mute_changed (); 155 void notify_record_enable_changed (); 156 void notify_gain_changed (bool force_update = true); 157 void notify_property_changed (const PBD::PropertyChange&); 158 void notify_panner_azi_changed (bool force_update = true); 159 void notify_panner_width_changed (bool force_update = true); 160 void notify_stripable_deleted (); 161 void notify_processor_changed (bool force_update = true); 162 void update_automation (); 163 void update_meter (); 164 std::string vpot_mode_string (); 165 166 boost::shared_ptr<ARDOUR::AutomationControl> mb_pan_controllable; 167 168 void return_to_vpot_mode_display (); 169 void next_pot_mode (); 170 171 void do_parameter_display (ARDOUR::ParameterDescriptor const&, float val, bool screen_hold = false); 172 void select_event (Button&, ButtonState); 173 void vselect_event (Button&, ButtonState); 174 void fader_touch_event (Button&, ButtonState); 175 176 std::vector<ARDOUR::AutomationType> possible_pot_parameters; 177 std::vector<ARDOUR::AutomationType> possible_trim_parameters; 178 void set_vpot_parameter (ARDOUR::AutomationType); 179 void show_stripable_name (); 180 181 void reset_saved_values (); 182 183 bool is_midi_track () const; 184 }; 185 186 } 187 } 188 189 #endif /* __ardour_mackie_control_protocol_strip_h__ */ 190