Skip to content

Commit

Permalink
osc: Pass user-visible piid to OSCSelectObserver
Browse files Browse the repository at this point in the history
There are two ways to identify a plugin:

 1. The user-visible number, usually named "piid". This is a 1-based
    index into the list of visible, non-channelstrip plugins only.
 2. The plugin id. This is a 1-based index into the list of all plugins as passed to nth_plugin

The sur->plugins vector is used to translate the former into the latter.

Previously, the latter, already translated, index was passed to
OSCSelectObserver to indicate the currently selected plugin. To prepare
for sending the piid of the selected plugin in a feedback message (in
the next commit), this commit moves the translation of piid to plugin id
into OSCSelectObserver.

To emphasize the new meaning of the plug_id variable, it is renamed to
selected_piid. Also, since the piid is 1-based, change it to a uint32_t
and use 0 to mean "no plugin selected" instead of -1.

This commit is expected to subtly change behaviour: When selecting
a different strip, OSCSelectObserver would (via OSC::_strip_select2 and
refresh_strip) send feedback for the plugin with the same plugin id as
the previously selected plugin. Then OSC::_strip_select2 would do the
piid to plugin id translation for the new strip and call set_plugin,
causing a second round of feedback for the plugin with the same piid as
the previously selected plugin.

If the new strip has hidden plugins (i.e. piid and plugin id do not
match), this could mean that you get feedback for two different plugins.

With this commit applied, the translation happens in both cases and the
feedback returned should be for the same plugin twice.
  • Loading branch information
matthijskooijman committed Jun 30, 2024
1 parent f375e81 commit 8a2a22d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions libs/surfaces/osc/osc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2888,7 +2888,7 @@ OSC::_sel_plugin (int id, lo_address addr)
sur->plugin_id = 0;
sur->plug_page = 1;
if (sur->sel_obs) {
sur->sel_obs->set_plugin_id(-1, 1);
sur->sel_obs->set_plugin_id(0, 1);
}
return 0;
} else if (id < 1) {
Expand Down Expand Up @@ -2924,7 +2924,7 @@ OSC::_sel_plugin (int id, lo_address addr)
sur->plug_page = 1;

if (sur->sel_obs) {
sur->sel_obs->set_plugin_id(sur->plugins[sur->plugin_id - 1], sur->plug_page);
sur->sel_obs->set_plugin_id(sur->plugin_id, sur->plug_page);
}
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions libs/surfaces/osc/osc_select_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ OSCSelectObserver::OSCSelectObserver (OSC& o, ARDOUR::Session& s, ArdourSurface:
plug_size = plug_page_size;
plug_page = sur->plug_page;
if (sur->plugins.size () > 0) {
plug_id = sur->plugins[sur->plugin_id - 1];
selected_piid = sur->plugin_id;
} else {
plug_id = -1;
selected_piid = 0;
}
_group_sharing[15] = 1;
refresh_strip (sur->select, sur->nsends, gainmode, true);
Expand Down Expand Up @@ -441,7 +441,7 @@ OSCSelectObserver::send_end ()
void
OSCSelectObserver::set_plugin_id (int id, uint32_t page)
{
plug_id = id;
selected_piid = id;
plug_page = page;
renew_plugin ();
}
Expand Down Expand Up @@ -469,7 +469,7 @@ OSCSelectObserver::renew_plugin () {
void
OSCSelectObserver::plugin_init()
{
if (plug_id < 0) {
if (!selected_piid) {
plugin_end ();
return;
}
Expand All @@ -480,7 +480,7 @@ OSCSelectObserver::plugin_init()
}

// we have a plugin number now get the processor
std::shared_ptr<Processor> proc = r->nth_plugin (plug_id);
std::shared_ptr<Processor> proc = r->nth_plugin (sur->plugins[selected_piid - 1]);
std::shared_ptr<PluginInsert> pi;
if (!(pi = std::dynamic_pointer_cast<PluginInsert>(proc))) {
plugin_end ();
Expand Down
2 changes: 1 addition & 1 deletion libs/surfaces/osc/osc_select_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class OSCSelectObserver
uint32_t nplug_params;
uint32_t plug_page_size;
uint32_t plug_page;
int plug_id;
uint32_t selected_piid;
uint32_t plug_size;
std::vector<int> plug_params;
int eq_bands;
Expand Down

0 comments on commit 8a2a22d

Please sign in to comment.