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/rc_configuration.h"
24 #include "ardour/session.h"
25 #include "ardour/track.h"
26 #include "ardour/types.h"
28 #include "faderport.h"
30 using namespace ARDOUR;
31 using namespace ArdourSurface;
33 /* this value is chosen to given smooth motion from 0..1.0 in about 270 degrees
34 * of encoder rotation.
36 static const double encoder_divisor = 24.0;
41 access_action ("Editor/select-prev-route");
44 //if ( (button_state & ShiftDown) == ShiftDown )
51 access_action ("Editor/select-next-route");
54 //if ( (button_state & ShiftDown) == ShiftDown )
62 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
64 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Play );
73 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
75 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Write );
84 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
86 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Touch );
95 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
97 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Off );
108 ControlProtocol::Undo (); /* EMIT SIGNAL */
114 ControlProtocol::Redo (); /* EMIT SIGNAL */
120 if (!_current_route) {
124 if (_current_route == session->monitor_out()) {
125 boost::shared_ptr<MonitorProcessor> mp = _current_route->monitor_control();
126 mp->set_cut_all (!mp->cut_all());
130 boost::shared_ptr<RouteList> rl (new RouteList);
131 rl->push_back (_current_route);
132 session->set_mute (rl, !_current_route->muted());
138 if (!_current_route) {
142 boost::shared_ptr<RouteList> rl (new RouteList);
143 rl->push_back (_current_route);
145 if (Config->get_solo_control_is_listen_control()) {
146 session->set_listen (rl, !_current_route->listening_via_monitor());
148 session->set_solo (rl, !_current_route->soloed());
153 FaderPort::rec_enable ()
155 if (!_current_route) {
159 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_current_route);
165 boost::shared_ptr<RouteList> rl (new RouteList);
166 rl->push_back (_current_route);
168 session->set_record_enabled (rl, !t->record_enabled());
172 FaderPort::use_master ()
174 boost::shared_ptr<Route> r = session->master_out();
176 if (_current_route == r) {
177 r = pre_master_route.lock();
178 set_current_route (r);
179 get_button(Output).set_led_state (_output_port, false);
180 blinkers.remove (Output);
182 if (_current_route != session->master_out() && _current_route != session->monitor_out()) {
183 pre_master_route = boost::weak_ptr<Route> (_current_route);
185 set_current_route (r);
186 get_button(Output).set_led_state (_output_port, true);
187 blinkers.remove (Output);
193 FaderPort::use_monitor ()
195 boost::shared_ptr<Route> r = session->monitor_out();
198 if (_current_route == r) {
199 r = pre_monitor_route.lock();
200 set_current_route (r);
201 get_button(Output).set_led_state (_output_port, false);
202 blinkers.remove (Output);
204 if (_current_route != session->master_out() && _current_route != session->monitor_out()) {
205 pre_monitor_route = boost::weak_ptr<Route> (_current_route);
207 set_current_route (r);
208 get_button(Output).set_led_state (_output_port, true);
209 blinkers.push_back (Output);
216 FaderPort::ardour_pan_azimuth (int delta)
218 if (!_current_route) {
222 boost::shared_ptr<Pannable> pannable = _current_route->pannable ();
228 boost::shared_ptr<AutomationControl> azimuth = pannable->pan_azimuth_control;
234 azimuth->set_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta / encoder_divider)));
239 FaderPort::ardour_pan_width(int delta)
241 if (!_current_route) {
245 boost::shared_ptr<Pannable> pannable = _current_route->pannable ();
251 boost::shared_ptr<AutomationControl> width = pannable->pan_width_control;
257 width->set_value (width->interface_to_internal (width->internal_to_interface (width->get_value()) + (delta / encoder_divider)));
261 FaderPort::mixbus_pan (int delta)
269 access_action ("Transport/TogglePunch");