From 15fcb5c78215e6c89c5244ebf8512d2ec7e3a1c8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 18 Jul 2020 17:29:53 -0600 Subject: [PATCH] Transport: engaging loop play while rolling with no audio tracks now works At present only audio data from disk readers is declicked. MIDI tracks with audio output should likely also be declicked, at which time Session::need_declick_before_locate() will require amending --- libs/ardour/ardour/session.h | 2 ++ libs/ardour/ardour/transport_api.h | 1 + libs/ardour/session.cc | 19 +++++++++++++++++++ libs/ardour/session_transport.cc | 9 +++++++++ libs/ardour/transport_fsm.cc | 13 ++++++++++--- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 4b775fe19c..f0e0709839 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -337,6 +337,7 @@ public: uint32_t nstripables (bool with_monitor = false) const; uint32_t nroutes() const { return routes.reader()->size(); } uint32_t ntracks () const; + uint32_t naudiotracks () const; uint32_t nbusses () const; bool plot_process_graph (std::string const& file_name) const; @@ -1296,6 +1297,7 @@ protected: double speed() const { return _transport_speed; } samplepos_t position() const { return _transport_sample; } void set_transport_speed (double speed, bool abort, bool clear_state, bool as_default); + bool need_declick_before_locate () const; private: int create (const std::string& mix_template, BusProfile const *, bool unnamed); diff --git a/libs/ardour/ardour/transport_api.h b/libs/ardour/ardour/transport_api.h index 5f6d674e3f..d36b53c828 100644 --- a/libs/ardour/ardour/transport_api.h +++ b/libs/ardour/ardour/transport_api.h @@ -43,6 +43,7 @@ class LIBARDOUR_API TransportAPI virtual double speed() const = 0; virtual void set_transport_speed (double speed, bool abort_capture, bool clear_state, bool as_default) = 0; virtual samplepos_t position() const = 0; + virtual bool need_declick_before_locate () const = 0; }; } /* end namespace ARDOUR */ diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 49b653a684..8dc7ad20cc 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -6002,6 +6002,8 @@ Session::get_mix_buffers (ChanCount count) uint32_t Session::ntracks () const { + /* XXX Could be optimized by caching */ + uint32_t n = 0; boost::shared_ptr r = routes.reader (); @@ -6014,6 +6016,23 @@ Session::ntracks () const return n; } +uint32_t +Session::naudiotracks () const +{ + /* XXX Could be optimized by caching */ + + uint32_t n = 0; + boost::shared_ptr r = routes.reader (); + + for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { + if (boost::dynamic_pointer_cast (*i)) { + ++n; + } + } + + return n; +} + uint32_t Session::nbusses () const { diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 36bca39ede..6c6f93db52 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -647,6 +647,15 @@ Session::start_transport () TransportStateChange (); /* EMIT SIGNAL */ } +bool +Session::need_declick_before_locate () const +{ + /* At this time (July 2020) only audio playback from disk readers is + de-clicked. MIDI tracks with audio output really need it too. + */ + return naudiotracks() > 0; +} + bool Session::should_roll_after_locate () const { diff --git a/libs/ardour/transport_fsm.cc b/libs/ardour/transport_fsm.cc index 39d726175c..4841067851 100644 --- a/libs/ardour/transport_fsm.cc +++ b/libs/ardour/transport_fsm.cc @@ -292,6 +292,7 @@ TransportFSM::process_event (Event& ev, bool already_deferred, bool& deferred) break; case Rolling: if (ev.for_loop_end) { + /* we will finish the locate synchronously, so * that after returning from * ::locate_for_loop() we will already have @@ -308,6 +309,7 @@ TransportFSM::process_event (Event& ev, bool already_deferred, bool& deferred) */ transition (WaitingForLocate); locate_for_loop (ev); + } else if (DiskReader::no_disk_output()) { /* separate clause to allow a comment that is @@ -326,8 +328,14 @@ TransportFSM::process_event (Event& ev, bool already_deferred, bool& deferred) transition (WaitingForLocate); locate_for_loop (ev); } else { - transition (DeclickToLocate); - start_declick_for_locate (ev); + + if (api->need_declick_before_locate()) { + transition (DeclickToLocate); + start_declick_for_locate (ev); + } else { + transition (WaitingForLocate); + locate_for_loop (ev); + } } break; case WaitingForLocate: @@ -675,4 +683,3 @@ TransportFSM::will_roll_fowards () const } return (_direction_state == Forwards); } -