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;
35 /* this value is chosen to given smooth motion from 0..1.0 in about 270 degrees
36 * of encoder rotation.
38 static const double encoder_divider = 24.0;
43 access_action ("Editor/select-prev-route");
46 //if ( (button_state & ShiftDown) == ShiftDown )
53 access_action ("Editor/select-next-route");
56 //if ( (button_state & ShiftDown) == ShiftDown )
64 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
66 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Play );
75 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
77 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Write );
86 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
88 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Touch );
97 boost::shared_ptr<AutomationControl> gain = _current_route->gain_control ();
99 gain->set_automation_state( (ARDOUR::AutoState) ARDOUR::Off );
110 ControlProtocol::Undo (); /* EMIT SIGNAL */
116 ControlProtocol::Redo (); /* EMIT SIGNAL */
122 if (!_current_route) {
126 if (_current_route == session->monitor_out()) {
127 boost::shared_ptr<MonitorProcessor> mp = _current_route->monitor_control();
128 mp->set_cut_all (!mp->cut_all());
132 boost::shared_ptr<RouteList> rl (new RouteList);
133 rl->push_back (_current_route);
134 session->set_mute (rl, !_current_route->muted());
140 if (!_current_route) {
144 boost::shared_ptr<RouteList> rl (new RouteList);
145 rl->push_back (_current_route);
147 if (Config->get_solo_control_is_listen_control()) {
148 session->set_listen (rl, !_current_route->listening_via_monitor());
150 session->set_solo (rl, !_current_route->soloed());
155 FaderPort::rec_enable ()
157 if (!_current_route) {
161 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_current_route);
167 boost::shared_ptr<RouteList> rl (new RouteList);
168 rl->push_back (_current_route);
170 session->set_record_enabled (rl, !t->record_enabled());
174 FaderPort::use_master ()
176 boost::shared_ptr<Route> r = session->master_out();
178 if (_current_route == r) {
179 r = pre_master_route.lock();
180 set_current_route (r);
181 get_button(Output).set_led_state (_output_port, false);
182 blinkers.remove (Output);
184 if (_current_route != session->master_out() && _current_route != session->monitor_out()) {
185 pre_master_route = boost::weak_ptr<Route> (_current_route);
187 set_current_route (r);
188 get_button(Output).set_led_state (_output_port, true);
189 blinkers.remove (Output);
195 FaderPort::use_monitor ()
197 boost::shared_ptr<Route> r = session->monitor_out();
200 if (_current_route == r) {
201 r = pre_monitor_route.lock();
202 set_current_route (r);
203 get_button(Output).set_led_state (_output_port, false);
204 blinkers.remove (Output);
206 if (_current_route != session->master_out() && _current_route != session->monitor_out()) {
207 pre_monitor_route = boost::weak_ptr<Route> (_current_route);
209 set_current_route (r);
210 get_button(Output).set_led_state (_output_port, true);
211 blinkers.push_back (Output);
218 FaderPort::ardour_pan_azimuth (int delta)
220 if (!_current_route) {
224 boost::shared_ptr<Pannable> pannable = _current_route->pannable ();
230 boost::shared_ptr<AutomationControl> azimuth = pannable->pan_azimuth_control;
236 azimuth->set_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta / encoder_divider)), Controllable::NoGroup);
241 FaderPort::ardour_pan_width(int delta)
243 if (!_current_route) {
247 boost::shared_ptr<Pannable> pannable = _current_route->pannable ();
253 boost::shared_ptr<AutomationControl> width = pannable->pan_width_control;
259 width->set_value (width->interface_to_internal (width->internal_to_interface (width->get_value()) + (delta / encoder_divider)), Controllable::NoGroup);
263 FaderPort::mixbus_pan (int delta)
266 if (!_current_route) {
270 const uint32_t port_channel_post_pan = 2; // gtk2_ardour/mixbus_ports.h
271 boost::shared_ptr<ARDOUR::PluginInsert> plug = _current_route->ch_post();
277 boost::shared_ptr<AutomationControl> azimuth = boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_pan)));
283 azimuth->set_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta / encoder_divider)), Controllable::NoGroup);
290 access_action ("Transport/TogglePunch");