From 74d7bf407a5895e8d2353f0ef6323e9bd6501397 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 17 Jul 2025 21:42:39 +0200 Subject: [PATCH] Add roll-will-loop option (as alternative to loop-is-mode) This is mainly for the benefit of Mixbus (this option is not [yet] available for Ardour, except for power users manually editing the config). This option is ostensibly exclusive with loop-is-mode, but an enum seems not appropriate at this point in time. --- .../ardour/ardour/rc_configuration_vars.inc.h | 1 + libs/ardour/ardour/session.h | 4 +++- libs/ardour/session.cc | 1 + libs/ardour/session_transport.cc | 19 ++++++++++++++++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/rc_configuration_vars.inc.h b/libs/ardour/ardour/rc_configuration_vars.inc.h index b0b2d2f9ee..306be66960 100644 --- a/libs/ardour/ardour/rc_configuration_vars.inc.h +++ b/libs/ardour/ardour/rc_configuration_vars.inc.h @@ -171,6 +171,7 @@ CONFIG_VARIABLE (bool, create_xrun_marker, "create-xrun-marker", false) CONFIG_VARIABLE (bool, stop_at_session_end, "stop-at-session-end", false) CONFIG_VARIABLE (float, preroll_seconds, "preroll-seconds", -2.0f) CONFIG_VARIABLE (bool, loop_is_mode, "loop-is-mode", false) +CONFIG_VARIABLE (bool, roll_will_loop, "roll-will-loop", false) CONFIG_VARIABLE (LoopFadeChoice, loop_fade_choice, "loop-fade-choice", XFadeLoop) CONFIG_VARIABLE (float, shuttle_speed_factor, "shuttle-speed-factor", 1.0f) // used for MMC shuttle CONFIG_VARIABLE (float, shuttle_speed_threshold, "shuttle-speed-threshold", 5.0f) // used for MMC shuttle diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index fe76043a33..61a61a4902 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1559,7 +1559,7 @@ private: * know when to send full MTC messages every so often. */ pframes_t _pframes_since_last_mtc; - bool play_loop; + std::atomic play_loop; bool loop_changing; samplepos_t last_loopend; @@ -2200,6 +2200,8 @@ private: mutable bool have_looped; ///< Used in \ref audible_sample + bool roll_started_loop; + void update_route_record_state (); std::atomic _have_rec_enabled_track; std::atomic _have_rec_disabled_track; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 56f41f1992..77554547c9 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -338,6 +338,7 @@ Session::Session (AudioEngine &eng, , first_file_data_format_reset (true) , first_file_header_format_reset (true) , have_looped (false) + , roll_started_loop (false) , _step_editors (0) , _speakers (new Speakers) , _ignore_route_processor_changes (0) diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index e6cdd1cc0e..68d8321024 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -153,6 +153,10 @@ Session::realtime_stop (bool abort, bool clear_state) waiting_for_sync_offset = true; } + if (todo & PostTransportClearSubstate) { + roll_started_loop = false; + } + if (todo) { TFSM_EVENT (TransportFSM::ButlerRequired); } @@ -475,6 +479,17 @@ Session::start_transport (bool after_loop) ENSURE_PROCESS_THREAD; DEBUG_TRACE (DEBUG::Transport, "start_transport\n"); + if (!after_loop && !roll_started_loop && !_exporting + && Config->get_roll_will_loop () + && !get_play_loop () + && !transport_master_is_external () + && _locations->auto_loop_location ()) { + roll_started_loop = true; + SessionEvent* ev = new SessionEvent (SessionEvent::SetLoop, SessionEvent::Add, SessionEvent::Immediate, 0, _transport_fsm->default_speed(), true, true); + queue_event (ev); + return; + } + if (Config->get_loop_is_mode() && get_play_loop ()) { Location *location = _locations->auto_loop_location(); @@ -1541,7 +1556,9 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished, bool will_ if (ptw & (PostTransportClearSubstate|PostTransportStop)) { if (!Config->get_loop_is_mode() && get_play_loop() && !loop_changing) { - unset_play_loop (); + if (!Config->get_roll_will_loop () || (ptw & PostTransportClearSubstate)) { + unset_play_loop (); + } } }