2 Copyright (C) 2015 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "ardour/async_midi_port.h"
21 #include "ardour/monitor_processor.h"
22 #include "ardour/pannable.h"
23 #include "ardour/plugin_insert.h"
24 #include "ardour/rc_configuration.h"
25 #include "ardour/record_enable_control.h"
26 #include "ardour/session.h"
27 #include "ardour/track.h"
28 #include "ardour/types.h"
30 #include "faderport.h"
32 using namespace ARDOUR;
33 using namespace ArdourSurface;
36 /* this value is chosen to given smooth motion from 0..1.0 in about 270 degrees
37 * of encoder rotation.
39 static const double encoder_divider = 24.0;
44 access_action ("Editor/select-prev-route");
47 //if ( (button_state & ShiftDown) == ShiftDown )
54 access_action ("Editor/select-next-route");
57 //if ( (button_state & ShiftDown) == ShiftDown )
64 if (_current_stripable) {
65 boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
67 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Play );
75 if (_current_stripable) {
76 boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
78 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Write );
86 if (_current_stripable) {
87 boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
89 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Touch );
97 if (_current_stripable) {
98 boost::shared_ptr<AutomationControl> gain = _current_stripable->gain_control ();
100 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Off );
111 ControlProtocol::Undo (); /* EMIT SIGNAL */
117 ControlProtocol::Redo (); /* EMIT SIGNAL */
123 if (!_current_stripable) {
127 if (_current_stripable == session->monitor_out()) {
128 boost::shared_ptr<MonitorProcessor> mp = _current_stripable->monitor_control();
129 mp->set_cut_all (!mp->cut_all());
133 _current_stripable->mute_control()->set_value (!_current_stripable->mute_control()->muted(), PBD::Controllable::UseGroup);
139 if (!_current_stripable) {
143 _current_stripable->solo_control()->set_value (_current_stripable->solo_control()->soloed(), PBD::Controllable::UseGroup);
147 FaderPort::rec_enable ()
149 if (!_current_stripable) {
153 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_current_stripable);
159 t->rec_enable_control()->set_value (!t->rec_enable_control()->get_value(), Controllable::UseGroup);
163 FaderPort::use_master ()
165 boost::shared_ptr<Stripable> r = session->master_out();
167 if (_current_stripable == r) {
168 r = pre_master_stripable.lock();
169 set_current_stripable (r);
170 get_button(Output).set_led_state (_output_port, false);
171 blinkers.remove (Output);
173 if (_current_stripable != session->master_out() && _current_stripable != session->monitor_out()) {
174 pre_master_stripable = boost::weak_ptr<Stripable> (_current_stripable);
176 set_current_stripable (r);
177 get_button(Output).set_led_state (_output_port, true);
178 blinkers.remove (Output);
184 FaderPort::use_monitor ()
186 boost::shared_ptr<Stripable> r = session->monitor_out();
189 if (_current_stripable == r) {
190 r = pre_monitor_stripable.lock();
191 set_current_stripable (r);
192 get_button(Output).set_led_state (_output_port, false);
193 blinkers.remove (Output);
195 if (_current_stripable != session->master_out() && _current_stripable != session->monitor_out()) {
196 pre_monitor_stripable = boost::weak_ptr<Stripable> (_current_stripable);
198 set_current_stripable (r);
199 get_button(Output).set_led_state (_output_port, true);
200 blinkers.push_back (Output);
207 FaderPort::ardour_pan_azimuth (int delta)
209 if (!_current_stripable) {
213 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
219 boost::shared_ptr<Pannable> pannable = r->pannable ();
225 boost::shared_ptr<AutomationControl> azimuth = pannable->pan_azimuth_control;
231 azimuth->set_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta / encoder_divider)), Controllable::NoGroup);
236 FaderPort::ardour_pan_width(int delta)
238 if (!_current_stripable) {
242 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
248 boost::shared_ptr<Pannable> pannable = r->pannable ();
254 boost::shared_ptr<AutomationControl> width = pannable->pan_width_control;
260 width->set_value (width->interface_to_internal (width->internal_to_interface (width->get_value()) + (delta / encoder_divider)), Controllable::NoGroup);
264 FaderPort::mixbus_pan (int delta)
267 if (!_current_stripable) {
270 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
277 const uint32_t port_channel_post_pan = 2; // gtk2_ardour/mixbus_ports.h
278 boost::shared_ptr<ARDOUR::PluginInsert> plug = r->ch_post();
284 boost::shared_ptr<AutomationControl> azimuth = boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_pan)));
290 azimuth->set_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta / encoder_divider)), Controllable::NoGroup);
297 access_action ("Transport/TogglePunch");