From 748d8e68ba34f057ee16a3eb578fef6af079a554 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 28 Jun 2024 12:11:41 +0200 Subject: [PATCH] osc: Send /select/plugin plugin_id feedback Whenever the active plugin changes (because the plugin changes or the selected strip changes), the name, some other properties and parameter values for the newly selected plugin is sent as feedback. However, there was no clear indication of which plugin was selected exactly. Applications or surfaces that need to know the active plugin could track the currently selected plugin by remembering the most recently selected index, but unexpected plugin changes (e.g. when switching to a strip with fewer plugins) and the asynchronous nature of OSC messages make this more complicated than it should be. By sending the active plugin id as feedback, clients do not have to guess. When no plugin is selected (e.g. on startup or when no strip is selected) or the currently selected index is not a plugin (but a some other kind of processor), a value of -1 is sent. This uses the `/select/plugin` message, which is also used to change the selected plugin. There is a slight discrepancy: the control messages accepts a delta on the selected plugin, while the feedback sends an absolute value. --- libs/surfaces/osc/osc_select_observer.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/surfaces/osc/osc_select_observer.cc b/libs/surfaces/osc/osc_select_observer.cc index a965b2f322c..23cb045847b 100644 --- a/libs/surfaces/osc/osc_select_observer.cc +++ b/libs/surfaces/osc/osc_select_observer.cc @@ -486,6 +486,8 @@ OSCSelectObserver::plugin_init() plugin_end (); return; } + _osc.float_message (X_("/select/plugin"), plug_id, addr); + std::shared_ptr pip = pi->plugin(); // we have a plugin we can ask if it is activated proc->ActiveChanged.connect (plugin_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::plug_enable, this, X_("/select/plugin/activate"), proc), OSC::instance()); @@ -558,6 +560,7 @@ void OSCSelectObserver::plugin_end () { plugin_connections.drop_connections (); + _osc.float_message (X_("/select/plugin"), -1, addr); _osc.float_message (X_("/select/plugin/activate"), 0, addr); _osc.text_message (X_("/select/plugin/name"), " ", addr); for (uint32_t i = 1; i <= plug_size; i++) {