From 7b25a8994412003562d360ef130bedd5d97d060f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 2 Nov 2019 16:20:32 -0600 Subject: [PATCH] part 1 of replicating semantics of ARDOUR_UI::toggle_roll() in BasicUI::toggle_roll() This can be done better, even without sharing code --- libs/surfaces/control_protocol/basic_ui.cc | 66 +++++++++++++++++-- .../control_protocol/basic_ui.h | 2 +- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index a6bf65f55b..2f0e4732e8 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -29,6 +29,7 @@ #include "ardour/session.h" #include "ardour/location.h" #include "ardour/tempo.h" +#include "ardour/transport_master_manager.h" #include "ardour/utils.h" #include "control_protocol/basic_ui.h" @@ -205,6 +206,8 @@ BasicUI::transport_stop () void BasicUI::transport_play (bool from_last_start) { + /* ::toggle_roll() is smarter and preferred */ + if (!session) { return; } @@ -486,12 +489,65 @@ BasicUI::toggle_click () } void -BasicUI::toggle_roll () +BasicUI::toggle_roll (bool roll_out_of_bounded_mode) { - if (session->transport_rolling()) { - transport_stop (); - } else { - transport_play (false); + /* TO BE KEPT IN SYNC WITH ARDOUR_UI::toggle_roll() */ + + if (!session) { + return; + } + + if (session->is_auditioning()) { + session->cancel_audition (); + return; + } + + if (session->config.get_external_sync()) { + switch (TransportMasterManager::instance().current()->type()) { + case Engine: + break; + default: + /* transport controlled by the master */ + return; + } + } + + bool rolling = session->transport_rolling(); + + if (rolling) { + + if (roll_out_of_bounded_mode) { + /* drop out of loop/range playback but leave transport rolling */ + + if (session->get_play_loop()) { + + if (session->actively_recording()) { + /* actually stop transport because + otherwise the captured data will make + no sense. + */ + session->request_play_loop (false, true); + + } else { + session->request_play_loop (false, false); + } + + } else if (session->get_play_range ()) { + + session->request_cancel_play_range (); + } + + } else { + session->request_stop (true, true); + } + + } else { /* not rolling */ + + if (session->get_play_loop() && Config->get_loop_is_mode()) { + session->request_locate (session->locations()->auto_loop_location()->start(), true); + } else { + session->request_transport_speed (1.0f); + } } } diff --git a/libs/surfaces/control_protocol/control_protocol/basic_ui.h b/libs/surfaces/control_protocol/control_protocol/basic_ui.h index b270993ab5..e57623cb9b 100644 --- a/libs/surfaces/control_protocol/control_protocol/basic_ui.h +++ b/libs/surfaces/control_protocol/control_protocol/basic_ui.h @@ -102,7 +102,7 @@ class LIBCONTROLCP_API BasicUI { void quick_snapshot_stay (); void quick_snapshot_switch (); - void toggle_roll(); //this provides the same operation as the "spacebar", it's a lot smarter than "play". + void toggle_roll(bool roll_out_of_bounded_mode=true); //this provides the same operation as the "spacebar", it's a lot smarter than "play". void stop_forget();