From 649ad0f0520646bff7f89f3b486c5f7b4b8fc3d9 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 24 Apr 2023 01:52:09 +0200 Subject: [PATCH] VST3: update parameter and Bus names on plugin's request This is currently only the backend implementation, the GUI is not yet notified of the change --- libs/ardour/vst3_plugin.cc | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index 562a6fbe0c..f311637016 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -1524,6 +1524,58 @@ VST3PI::restartComponent (int32 flags) } _plugin_latency.reset (); } + if (flags & Vst::kIoTitlesChanged) { + /* Input and/or Output bus titles have changed + * compare to VST3PI::count_channels + */ + const Vst::MediaTypes medien [] = { Vst::kAudio, Vst::kEvent }; + const Vst::BusDirections dirs[] = { Vst::kInput, Vst::kOutput }; + for (auto const& media : medien) { + for (auto const& dir : dirs) { + int32 n_busses = _component->getBusCount (media, dir); + for (int32 i = 0; i < n_busses; ++i) { + Vst::BusInfo bus; + if (_component->getBusInfo (media, dir, i, bus) != kResultTrue) { + continue; + } + std::string bus_name = tchar_to_utf8 (bus.name); + if (media == Vst::kEvent && _io_name[media][dir].size () == 1) { + _io_name[media][dir][0].name = bus_name; + } else if (media == Vst::kAudio && _io_name[media][dir].size () == size_t(bus.channelCount)) { + for (int32_t j = 0; j < bus.channelCount; ++j) { + std::string channel_name; + if (bus.channelCount > 1) { + channel_name = string_compose ("%1 %2", bus_name, j + 1); + } else { + channel_name = bus_name; + } + _io_name[media][dir][j].name = channel_name; + } + } + } + } + } + } + if (flags & Vst::kParamTitlesChanged) { + /* titles or default values or flags have changed */ + int32 n_params = _controller->getParameterCount (); + for (int32 i = 0; i < n_params; ++i) { + Vst::ParameterInfo pi; + if (_controller->getParameterInfo (i, pi) != kResultTrue) { + continue; + } + std::map::const_iterator idx = _ctrl_id_index.find (pi.id); + if (idx != _ctrl_id_index.end ()) { + Param& p (_ctrl_params[idx->second]); + p.label = tchar_to_utf8 (pi.title).c_str (); + p.normal = pi.defaultNormalizedValue; + } + } + // TODO notify GUI: + // * ProcessorEntry caches _controls + // * call RouteTimeAxisView::processors_changed + // invalidate Automatable::_controls ParameterDescriptor ? + } if (flags & Vst::kIoChanged) { warning << "VST3: Vst::kIoChanged (not implemented)" << endmsg; #if 0