2 Copyright (C) 2006,2007 John Anderson
3 Copyright (C) 2012 Paul Davis
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "pbd/memento_command.h"
22 #include "ardour/session.h"
23 #include "ardour/route.h"
24 #include "ardour/location.h"
25 #include "ardour/rc_configuration.h"
27 #include "mackie_control_protocol.h"
31 /* handlers for all buttons, broken into a separate file to avoid clutter in
32 * mackie_control_protocol.cc
35 using namespace Mackie;
36 using namespace ARDOUR;
40 MackieControlProtocol::shift_press (Button &)
42 _modifier_state |= MODIFIER_SHIFT;
46 MackieControlProtocol::shift_release (Button &)
48 _modifier_state &= ~MODIFIER_SHIFT;
52 MackieControlProtocol::option_press (Button &)
54 _modifier_state |= MODIFIER_OPTION;
58 MackieControlProtocol::option_release (Button &)
60 _modifier_state &= ~MODIFIER_OPTION;
64 MackieControlProtocol::control_press (Button &)
66 _modifier_state |= MODIFIER_CONTROL;
70 MackieControlProtocol::control_release (Button &)
72 _modifier_state &= ~MODIFIER_CONTROL;
76 MackieControlProtocol::cmd_alt_press (Button &)
78 _modifier_state |= MODIFIER_CMDALT;
82 MackieControlProtocol::cmd_alt_release (Button &)
84 _modifier_state &= ~MODIFIER_CMDALT;
89 MackieControlProtocol::left_press (Button &)
91 Sorted sorted = get_sorted_routes();
92 if (sorted.size() > route_table.size()) {
93 int new_initial = _current_initial_bank - route_table.size();
94 if (new_initial < 0) {
98 if (new_initial != int (_current_initial_bank)) {
100 switch_banks (new_initial);
110 MackieControlProtocol::left_release (Button &)
116 MackieControlProtocol::right_press (Button &)
122 MackieControlProtocol::right_release (Button &)
132 MackieControlProtocol::cursor_left_press (Button& )
136 if (_modifier_state & MODIFIER_OPTION) {
137 /* reset selected tracks to default vertical zoom */
139 ZoomOut (); /* EMIT SIGNAL */
147 MackieControlProtocol::cursor_left_release (Button&)
153 MackieControlProtocol::cursor_right_press (Button& )
157 if (_modifier_state & MODIFIER_OPTION) {
158 /* reset selected tracks to default vertical zoom */
160 ZoomIn (); /* EMIT SIGNAL */
168 MackieControlProtocol::cursor_right_release (Button&)
174 MackieControlProtocol::cursor_up_press (Button&)
177 if (_modifier_state & MODIFIER_OPTION) {
178 VerticalZoomOutSelected (); /* EMIT SIGNAL */
180 VerticalZoomOutAll (); /* EMIT SIGNAL */
187 MackieControlProtocol::cursor_up_release (Button&)
193 MackieControlProtocol::cursor_down_press (Button&)
197 if (_modifier_state & MODIFIER_OPTION) {
198 VerticalZoomInSelected (); /* EMIT SIGNAL */
200 VerticalZoomInAll (); /* EMIT SIGNAL */
207 MackieControlProtocol::cursor_down_release (Button&)
213 MackieControlProtocol::channel_left_press (Button &)
215 Sorted sorted = get_sorted_routes();
216 if (sorted.size() > route_table.size()) {
225 MackieControlProtocol::channel_left_release (Button &)
231 MackieControlProtocol::channel_right_press (Button &)
233 Sorted sorted = get_sorted_routes();
234 if (sorted.size() > route_table.size()) {
243 MackieControlProtocol::channel_right_release (Button &)
248 /////////////////////////////////////
250 /////////////////////////////////////
252 MackieControlProtocol::marker_press (Button &)
254 // cut'n'paste from LocationUI::add_new_location()
256 framepos_t where = session->audible_frame();
257 session->locations()->next_available_name(markername,"mcu");
258 Location *location = new Location (*session, where, where, markername, Location::IsMark);
259 session->begin_reversible_command (_("add marker"));
260 XMLNode &before = session->locations()->get_state();
261 session->locations()->add (location, true);
262 XMLNode &after = session->locations()->get_state();
263 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
264 session->commit_reversible_command ();
269 MackieControlProtocol::marker_release (Button &)
274 /////////////////////////////////////
276 /////////////////////////////////////
279 MackieControlProtocol::frm_left_press (Button &)
281 // can use first_mark_before/after as well
282 unsigned long elapsed = _frm_left_last.restart();
284 Location * loc = session->locations()->first_location_before (
285 session->transport_frame()
288 // allow a quick double to go past a previous mark
289 if (session->transport_rolling() && elapsed < 500 && loc != 0) {
290 Location * loc_two_back = session->locations()->first_location_before (loc->start());
291 if (loc_two_back != 0)
297 // move to the location, if it's valid
299 session->request_locate (loc->start(), session->transport_rolling());
306 MackieControlProtocol::frm_left_release (Button &)
312 MackieControlProtocol::frm_right_press (Button &)
314 // can use first_mark_before/after as well
315 Location * loc = session->locations()->first_location_after (session->transport_frame());
318 session->request_locate (loc->start(), session->transport_rolling());
325 MackieControlProtocol::frm_right_release (Button &)
331 MackieControlProtocol::stop_press (Button &)
333 session->request_stop();
338 MackieControlProtocol::stop_release (Button &)
340 return session->transport_stopped();
344 MackieControlProtocol::play_press (Button &)
346 session->request_transport_speed (1.0);
351 MackieControlProtocol::play_release (Button &)
353 return session->transport_rolling();
357 MackieControlProtocol::record_press (Button &)
359 if (session->get_record_enabled()) {
360 session->disable_record (false);
362 session->maybe_enable_record();
368 MackieControlProtocol::record_release (Button &)
370 if (session->get_record_enabled()) {
371 if (session->transport_rolling()) {
382 MackieControlProtocol::rewind_press (Button &)
384 _jog_wheel.push (JogWheel::speed);
385 _jog_wheel.transport_direction (-1);
386 session->request_transport_speed (-_jog_wheel.transport_speed());
391 MackieControlProtocol::rewind_release (Button &)
394 _jog_wheel.transport_direction (0);
395 if (_transport_previously_rolling) {
396 session->request_transport_speed (1.0);
398 session->request_stop();
404 MackieControlProtocol::ffwd_press (Button &)
406 _jog_wheel.push (JogWheel::speed);
407 _jog_wheel.transport_direction (1);
408 session->request_transport_speed (_jog_wheel.transport_speed());
413 MackieControlProtocol::ffwd_release (Button &)
416 _jog_wheel.transport_direction (0);
417 if (_transport_previously_rolling) {
418 session->request_transport_speed (1.0);
420 session->request_stop();
426 MackieControlProtocol::loop_press (Button &)
428 session->request_play_loop (!session->get_play_loop());
433 MackieControlProtocol::loop_release (Button &)
435 return session->get_play_loop();
439 MackieControlProtocol::punch_in_press (Button &)
441 bool const state = !session->config.get_punch_in();
442 session->config.set_punch_in (state);
447 MackieControlProtocol::punch_in_release (Button &)
449 return session->config.get_punch_in();
453 MackieControlProtocol::punch_out_press (Button &)
455 bool const state = !session->config.get_punch_out();
456 session->config.set_punch_out (state);
461 MackieControlProtocol::punch_out_release (Button &)
463 return session->config.get_punch_out();
467 MackieControlProtocol::home_press (Button &)
469 session->goto_start();
474 MackieControlProtocol::home_release (Button &)
480 MackieControlProtocol::end_press (Button &)
487 MackieControlProtocol::end_release (Button &)
493 MackieControlProtocol::clicking_press (Button &)
495 bool state = !Config->get_clicking();
496 Config->set_clicking (state);
501 MackieControlProtocol::clicking_release (Button &)
503 return Config->get_clicking();
506 LedState MackieControlProtocol::global_solo_press (Button &)
508 bool state = !session->soloing();
509 session->set_solo (session->get_routes(), state);
513 LedState MackieControlProtocol::global_solo_release (Button &)
515 return session->soloing();
519 MackieControlProtocol::enter_press (Button &)
521 Enter(); /* EMIT SIGNAL */
526 MackieControlProtocol::enter_release (Button &)
534 MackieControlProtocol::io_press (Button &)
539 MackieControlProtocol::io_release (Button &)
544 MackieControlProtocol::sends_press (Button &)
549 MackieControlProtocol::sends_release (Button &)
554 MackieControlProtocol::pan_press (Button &)
559 MackieControlProtocol::pan_release (Button &)
564 MackieControlProtocol::plugin_press (Button &)
569 MackieControlProtocol::plugin_release (Button &)
574 MackieControlProtocol::eq_press (Button &)
579 MackieControlProtocol::eq_release (Button &)
584 MackieControlProtocol::dyn_press (Button &)
589 MackieControlProtocol::dyn_release (Button &)
594 MackieControlProtocol::flip_press (Button &)
599 MackieControlProtocol::flip_release (Button &)
604 MackieControlProtocol::edit_press (Button &)
609 MackieControlProtocol::edit_release (Button &)
614 MackieControlProtocol::name_value_press (Button &)
619 MackieControlProtocol::name_value_release (Button &)
624 MackieControlProtocol::F1_press (Button &)
626 GotoView (0); /* EMIT SIGNAL */
630 MackieControlProtocol::F1_release (Button &)
635 MackieControlProtocol::F2_press (Button &)
637 GotoView (1); /* EMIT SIGNAL */
641 MackieControlProtocol::F2_release (Button &)
646 MackieControlProtocol::F3_press (Button &)
648 GotoView (2); /* EMIT SIGNAL */
652 MackieControlProtocol::F3_release (Button &)
657 MackieControlProtocol::F4_press (Button &)
659 GotoView (3); /* EMIT SIGNAL */
663 MackieControlProtocol::F4_release (Button &)
668 MackieControlProtocol::F5_press (Button &)
670 GotoView (4); /* EMIT SIGNAL */
674 MackieControlProtocol::F5_release (Button &)
679 MackieControlProtocol::F6_press (Button &)
681 GotoView (5); /* EMIT SIGNAL */
685 MackieControlProtocol::F6_release (Button &)
690 MackieControlProtocol::F7_press (Button &)
692 GotoView (6); /* EMIT SIGNAL */
696 MackieControlProtocol::F7_release (Button &)
701 MackieControlProtocol::F8_press (Button &)
703 CloseDialog (); /* EMIT SIGNAL */
707 MackieControlProtocol::F8_release (Button &)
712 MackieControlProtocol::F9_press (Button &)
714 GotoView (8); /* EMIT SIGNAL */
718 MackieControlProtocol::F9_release (Button &)
723 MackieControlProtocol::F10_press (Button &)
728 MackieControlProtocol::F10_release (Button &)
733 MackieControlProtocol::F11_press (Button &)
738 MackieControlProtocol::F11_release (Button &)
743 MackieControlProtocol::F12_press (Button &)
748 MackieControlProtocol::F12_release (Button &)
753 MackieControlProtocol::F13_press (Button &)
758 MackieControlProtocol::F13_release (Button &)
763 MackieControlProtocol::F14_press (Button &)
768 MackieControlProtocol::F14_release (Button &)
773 MackieControlProtocol::F15_press (Button &)
778 MackieControlProtocol::F15_release (Button &)
783 MackieControlProtocol::F16_press (Button &)
788 MackieControlProtocol::F16_release (Button &)
793 MackieControlProtocol::on_press (Button &)
798 MackieControlProtocol::on_release (Button &)
803 MackieControlProtocol::rec_ready_press (Button &)
808 MackieControlProtocol::rec_ready_release (Button &)
813 MackieControlProtocol::snapshot_press (Button &)
818 MackieControlProtocol::snapshot_release (Button &)
823 MackieControlProtocol::touch_press (Button &)
828 MackieControlProtocol::touch_release (Button &)
833 MackieControlProtocol::cancel_press (Button &)
838 MackieControlProtocol::cancel_release (Button &)
843 MackieControlProtocol::mixer_press (Button &)
848 MackieControlProtocol::mixer_release (Button &)
853 MackieControlProtocol::user_a_press (Button &)
858 MackieControlProtocol::user_a_release (Button &)
863 MackieControlProtocol::user_b_press (Button &)
868 MackieControlProtocol::user_b_release (Button &)
873 MackieControlProtocol::fader_touch_press (Button &)
878 MackieControlProtocol::fader_touch_release (Button &)