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/session.h"
26 #include "ardour/track.h"
27 #include "ardour/types.h"
29 #include "faderport.h"
31 using namespace ARDOUR;
32 using namespace ArdourSurface;
34 /* this value is chosen to given smooth motion from 0..1.0 in about 270 degrees
35 * of encoder rotation.
37 static const double encoder_divider = 24.0;
42 access_action ("Editor/select-prev-route");
45 //if ( (button_state & ShiftDown) == ShiftDown )
52 access_action ("Editor/select-next-route");
55 //if ( (button_state & ShiftDown) == ShiftDown )
63 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
65 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Play );
74 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
76 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Write );
85 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
87 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Touch );
96 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
98 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Off );
109 ControlProtocol::Undo (); /* EMIT SIGNAL */
115 ControlProtocol::Redo (); /* EMIT SIGNAL */
121 if (!_current_route) {
125 if (_current_route == session->monitor_out()) {
126 boost::shared_ptr<MonitorProcessor> mp = _current_route->monitor_control();
127 mp->set_cut_all (!mp->cut_all());
131 boost::shared_ptr<RouteList> rl (new RouteList);
132 rl->push_back (_current_route);
133 session->set_mute (rl, !_current_route->muted());
139 if (!_current_route) {
143 boost::shared_ptr<RouteList> rl (new RouteList);
144 rl->push_back (_current_route);
146 if (Config->get_solo_control_is_listen_control()) {
147 session->set_listen (rl, !_current_route->listening_via_monitor());
149 session->set_solo (rl, !_current_route->soloed());
154 FaderPort::rec_enable ()
156 if (!_current_route) {
160 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_current_route);
166 boost::shared_ptr<RouteList> rl (new RouteList);
167 rl->push_back (_current_route);
169 session->set_record_enabled (rl, !t->record_enabled());
173 FaderPort::use_master ()
175 boost::shared_ptr<Route> r = session->master_out();
177 if (_current_route == r) {
178 r = pre_master_route.lock();
179 set_current_route (r);
180 get_button(Output).set_led_state (_output_port, false);
181 blinkers.remove (Output);
183 if (_current_route != session->master_out() && _current_route != session->monitor_out()) {
184 pre_master_route = boost::weak_ptr<Route> (_current_route);
186 set_current_route (r);
187 get_button(Output).set_led_state (_output_port, true);
188 blinkers.remove (Output);
194 FaderPort::use_monitor ()
196 boost::shared_ptr<Route> r = session->monitor_out();
199 if (_current_route == r) {
200 r = pre_monitor_route.lock();
201 set_current_route (r);
202 get_button(Output).set_led_state (_output_port, false);
203 blinkers.remove (Output);
205 if (_current_route != session->master_out() && _current_route != session->monitor_out()) {
206 pre_monitor_route = boost::weak_ptr<Route> (_current_route);
208 set_current_route (r);
209 get_button(Output).set_led_state (_output_port, true);
210 blinkers.push_back (Output);
217 FaderPort::ardour_pan_azimuth (int delta)
219 if (!_current_route) {
223 boost::shared_ptr<Pannable> pannable = _current_route->pannable ();
229 boost::shared_ptr<AutomationControl> azimuth = pannable->pan_azimuth_control;
235 azimuth->set_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta / encoder_divider)));
240 FaderPort::ardour_pan_width(int delta)
242 if (!_current_route) {
246 boost::shared_ptr<Pannable> pannable = _current_route->pannable ();
252 boost::shared_ptr<AutomationControl> width = pannable->pan_width_control;
258 width->set_value (width->interface_to_internal (width->internal_to_interface (width->get_value()) + (delta / encoder_divider)));
262 FaderPort::mixbus_pan (int delta)
265 if (!_current_route) {
269 const uint32_t port_channel_post_pan = 2; // gtk2_ardour/mixbus_ports.h
270 boost::shared_ptr<ARDOUR::PluginInsert> plug = _current_route->ch_post();
276 boost::shared_ptr<AutomationControl> azimuth = boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_pan)));
282 azimuth->set_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta / encoder_divider)));
289 access_action ("Transport/TogglePunch");