From 8c1bb6ac588b0ed469b8dc110dadaff61e716beb Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 9 Nov 2025 16:18:26 +0100 Subject: [PATCH] Add API to lookup plugin by URI --- libs/ardour/ardour/route.h | 1 + libs/ardour/route.cc | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 07a9547f38..5001b2e905 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -251,6 +251,7 @@ public: } std::shared_ptr processor_by_id (PBD::ID) const; + std::shared_ptr plugin_by_uri (std::string const&, int offset = 0) const; std::shared_ptr nth_plugin (uint32_t n) const; std::shared_ptr nth_send (uint32_t n) const; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 3fa35049f9..a9f8586c65 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -5631,6 +5631,24 @@ Route::processor_by_id (PBD::ID id) const return std::shared_ptr (); } +std::shared_ptr +Route::plugin_by_uri (std::string const& uri, int offset) const +{ + Glib::Threads::RWLock::ReaderLock lm (_processor_lock); + for (auto const& p : _processors) { + std::shared_ptr pi = std::dynamic_pointer_cast(p); + if (!pi) { + continue; + } + if (pi->plugin()->unique_id () == uri) { + if (offset-- <= 0) { + return p; + } + } + } + return std::shared_ptr (); +} + bool Route::can_freeze_processor (std::shared_ptr p, bool allow_routing) const {