From 79e6830d21b69d43ff7f31c86f0cf59a58114303 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 11 May 2023 02:10:21 +0200 Subject: [PATCH] VST3: allow to set non-automatable params (#9321) --- libs/ardour/vst3_plugin.cc | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index 6bb2813dba..793df852c6 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -1268,8 +1268,6 @@ VST3PI::VST3PI (std::shared_ptr m, std::string unique_ memset (&_program_change_port, 0, sizeof (_program_change_port)); _program_change_port.id = Vst::kNoParamId; - FUnknownPtr host_editing (_controller); - FUnknownPtr controller2 (_controller); if (controller2) { controller2->setKnobMode (Vst::kLinearMode); @@ -1287,13 +1285,6 @@ VST3PI::VST3PI (std::shared_ptr m, std::string unique_ _program_change_port = pi; continue; } - /* allow non-automatable parameters IFF IEditControllerHostEditing is available */ - if (0 == (pi.flags & Vst::ParameterInfo::kCanAutomate) && !host_editing) { - /* but allow read-only, not automatable params (ctrl outputs) */ - if (0 == (pi.flags & Vst::ParameterInfo::kIsReadOnly)) { - continue; - } - } if (tchar_to_utf8 (pi.title).find ("MIDI CC ") != std::string::npos) { /* Some JUCE plugins add 16 * 128 automatable MIDI CC parameters */ continue; @@ -1313,6 +1304,16 @@ VST3PI::VST3PI (std::shared_ptr m, std::string unique_ p.label = X_("hidden"); } +#if 1 // if (host_editing == 0) // FUnknownPtr host_editing (_controller); + if (0 == (pi.flags & (Vst::ParameterInfo::kCanAutomate | Vst::ParameterInfo::kIsReadOnly))) { + /* Hide writable parameters that cannot be automated in the generic UI. + * Those are usually internal params or MIDI ctrl hacks. + * index_to_id() needs to work for those. + */ + p.label = X_("hidden"); + } +#endif + uint32_t idx = _ctrl_params.size (); _ctrl_params.push_back (p); @@ -1956,7 +1957,7 @@ VST3PI::set_parameter (uint32_t p, float value, int32 sample_off, bool to_list, if (_shadow_data[p] == value && sample_off == 0 && to_list && !force) { return; } - if (to_list) { + if (to_list && parameter_is_automatable (p)) { set_parameter_internal (id, value, sample_off); } _shadow_data[p] = value; @@ -2055,12 +2056,11 @@ VST3PI::update_contoller_param () continue; } _update_ctrl[i->first] = false; - if (!parameter_is_automatable (i->first) && !parameter_is_readonly (i->first)) { - assert (host_editing); + if (host_editing && !parameter_is_automatable (i->first) && !parameter_is_readonly (i->first)) { host_editing->beginEditFromHost (i->second); } _controller->setParamNormalized (i->second, _shadow_data[i->first]); - if (!parameter_is_automatable (i->first) && !parameter_is_readonly (i->first)) { + if (host_editing && !parameter_is_automatable (i->first) && !parameter_is_readonly (i->first)) { host_editing->endEditFromHost (i->second); } } @@ -2094,12 +2094,11 @@ VST3PI::get_parameter (uint32_t p) const _update_ctrl[p] = false; FUnknownPtr host_editing (_controller); - if (!parameter_is_automatable (p) && !parameter_is_readonly (p)) { - assert (host_editing); + if (host_editing && !parameter_is_automatable (p) && !parameter_is_readonly (p)) { host_editing->beginEditFromHost (id); } _controller->setParamNormalized (id, _shadow_data[p]); // GUI thread only - if (!parameter_is_automatable (p) && !parameter_is_readonly (p)) { + if (host_editing && !parameter_is_automatable (p) && !parameter_is_readonly (p)) { host_editing->endEditFromHost (id); } }