From 52b7e6810274ed3809fc9b05ebae92e451add23c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 15 Apr 2021 23:20:59 -0600 Subject: [PATCH] use new Session transport API calls in GUI --- gtk2_ardour/editor_drag.cc | 2 +- gtk2_ardour/editor_mouse.cc | 5 +++-- gtk2_ardour/editor_ops.cc | 2 +- gtk2_ardour/shuttle_control.cc | 22 ++++++++++------------ libs/surfaces/control_protocol/basic_ui.cc | 4 ++-- libs/surfaces/osc/osc.cc | 3 +-- share/scripts/_cron.lua | 2 +- share/scripts/_session_test.lua | 2 +- tools/split_benchmark.lua | 2 +- 9 files changed, 21 insertions(+), 23 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 9f0405882b..7ac8ce5344 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -5467,7 +5467,7 @@ ScrubDrag::finished (GdkEvent* /*event*/, bool movement_occurred) { if (movement_occurred && _editor->session()) { /* make sure we stop */ - _editor->session()->request_transport_speed (0.0); + _editor->session()->request_stop (); } } diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 252b5bcda3..8518276185 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -313,7 +313,8 @@ Editor::mouse_mode_toggled (MouseMode m) if (_session && mouse_mode == MouseAudition) { /* stop transport and reset default speed to avoid oddness with auditioning */ - _session->request_transport_speed (0.0, true); + _session->request_stop (); + _session->request_transport_speed (1.0); } const bool was_internal = internal_editing(); @@ -1788,7 +1789,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT } } else if (_session) { /* make sure we stop */ - _session->request_transport_speed (0.0); + _session->request_stop (); } break; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index a8c5f6c960..e47b70eaf2 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4012,7 +4012,7 @@ Editor::freeze_route () } /* stop transport before we start. this is important */ - _session->request_transport_speed (0.0); + _session->request_stop(); /* wait for just a little while, because the above call is asynchronous */ int timeout = 10; diff --git a/gtk2_ardour/shuttle_control.cc b/gtk2_ardour/shuttle_control.cc index 754b0338cd..fea327e63c 100644 --- a/gtk2_ardour/shuttle_control.cc +++ b/gtk2_ardour/shuttle_control.cc @@ -269,11 +269,7 @@ ShuttleControl::reset_speed () return; } - if (_session->transport_rolling()) { - _session->request_transport_speed (1.0, true); - } else { - _session->request_transport_speed (0.0, true); - } + _session->reset_transport_speed (); } void @@ -307,7 +303,7 @@ ShuttleControl::on_button_press_event (GdkEventButton* ev) case 1: if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { if (_session->transport_rolling()) { - _session->request_transport_speed (1.0); + _session->reset_transport_speed (); } } else { add_modal_grab (); @@ -345,11 +341,7 @@ ShuttleControl::on_button_release_event (GdkEventButton* ev) gdk_pointer_ungrab (GDK_CURRENT_TIME); if (Config->get_shuttle_behaviour() == Sprung) { - if (shuttle_speed_on_grab == 0 ) { - _session->request_stop (); - } else { - _session->request_transport_speed (shuttle_speed_on_grab); - } + _session->reset_transport_speed(); } else { mouse_shuttle (ev->x, true); } @@ -567,6 +559,12 @@ ShuttleControl::use_shuttle_fract (bool force, bool zero_ok) } else { _session->request_transport_speed_nonzero (speed, Config->get_shuttle_behaviour() == Wheel); } + + if (speed != 0 && !_session->transport_state_rolling()) { + _session->request_roll (); + } else if (speed == 0 && zero_ok && _session->transport_state_rolling()) { + _session->request_stop (); + } } } @@ -721,7 +719,7 @@ ShuttleControl::parameter_changed (std::string p) /* reset current speed and revert to 1.0 as the default */ - _session->request_transport_speed (1.0); + _session->reset_transport_speed (); /* redraw when speed changes */ } } else { diff --git a/libs/surfaces/control_protocol/basic_ui.cc b/libs/surfaces/control_protocol/basic_ui.cc index 48a89f65c9..7192f3ae55 100644 --- a/libs/surfaces/control_protocol/basic_ui.cc +++ b/libs/surfaces/control_protocol/basic_ui.cc @@ -200,7 +200,7 @@ BasicUI::ffwd () void BasicUI::transport_stop () { - session->request_transport_speed (0.0); + session->request_stop (); } bool @@ -283,7 +283,7 @@ BasicUI::transport_play (bool from_last_start) } if (!rolling) { - session->request_transport_speed (1.0f, false); + session->request_roll (); } } diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 3fa77d350a..11b8c37b91 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -3022,7 +3022,7 @@ OSC::scrub (float delta, lo_message msg) session->request_transport_speed (-1); } } else { - session->request_transport_speed (0); + session->request_stop (); } return 0; @@ -5896,7 +5896,6 @@ OSC::periodic (void) int64_t diff = now - scrub_time; if (diff > 120000) { scrub_speed = 0; - session->request_transport_speed (0); // locate to the place PH was at last tick session->request_locate (scrub_place, MustStop); } diff --git a/share/scripts/_cron.lua b/share/scripts/_cron.lua index 8e7c8e76d8..4dfa927e47 100644 --- a/share/scripts/_cron.lua +++ b/share/scripts/_cron.lua @@ -29,7 +29,7 @@ function factory () -- event at 09:32:00 UTC (here: rec-stop) if (now >= hhmmss (09, 32, 00) and _last_time < hhmmss (09, 32, 00)) then Session:disable_record (false, false) - Session:request_transport_speed (0.0, true, ARDOUR.TransportRequestSource.TRS_UI) + Session:request_stop (false, false, TRS_UI); end _last_time = now diff --git a/share/scripts/_session_test.lua b/share/scripts/_session_test.lua index 40bf84c3f0..e7db82d557 100644 --- a/share/scripts/_session_test.lua +++ b/share/scripts/_session_test.lua @@ -28,7 +28,7 @@ function factory (params) end a = a + n_samples if (a > timeout * Session:sample_rate()) then - Session:request_transport_speed(0.0, true, ARDOUR.TransportRequestSource.TRS_Engine) + Session:request_stop (false, false, TRS_UI); end end end diff --git a/tools/split_benchmark.lua b/tools/split_benchmark.lua index f8c4c20b14..ae8ea9769a 100644 --- a/tools/split_benchmark.lua +++ b/tools/split_benchmark.lua @@ -22,7 +22,7 @@ s:maybe_enable_record() s:request_transport_speed(1.0, true, 4) ARDOUR.LuaAPI.usleep (1000000 * reclen) -s:request_transport_speed(0.0, false, 4) +s:request_stop (false, false, 4); for t in s:get_tracks():iter() do t:rec_enable_control():set_value(0, PBD.GroupControlDisposition.UseGroup)