diff --git a/libs/ardour/ardour/vst3_plugin.h b/libs/ardour/ardour/vst3_plugin.h index 70ebe85455..53f0ec366c 100644 --- a/libs/ardour/ardour/vst3_plugin.h +++ b/libs/ardour/ardour/vst3_plugin.h @@ -50,6 +50,7 @@ class LIBARDOUR_API VST3PI : public Vst::IComponentHandler , public Vst::IComponentHandler2 , public Vst::IConnectionPoint + , public Vst::IUnitHandler , public IPlugFrame { public: @@ -76,6 +77,10 @@ public: /* IPlugFrame */ tresult PLUGIN_API resizeView (IPlugView* view, ViewRect* newSize) SMTG_OVERRIDE; + /* IUnitHandler API */ + tresult PLUGIN_API notifyUnitSelection (Vst::UnitID) SMTG_OVERRIDE; + tresult PLUGIN_API notifyProgramListChange (Vst::ProgramListID, int32) SMTG_OVERRIDE; + /* GUI */ bool has_editor () const; IPlugView* view (); @@ -128,7 +133,7 @@ public: std::string format_parameter (uint32_t p) const; Vst::ParamID index_to_id (uint32_t) const; - enum ParameterChange { BeginGesture, EndGesture , ValueChange, InternalChange }; + enum ParameterChange { BeginGesture, EndGesture , ValueChange, InternalChange, PresetChange }; PBD::Signal3 OnParameterChange; /* API for Ardour -- Setup/Processing */ diff --git a/libs/ardour/vst3_host.cc b/libs/ardour/vst3_host.cc index 8b1c807269..58cca6c724 100644 --- a/libs/ardour/vst3_host.cc +++ b/libs/ardour/vst3_host.cc @@ -43,6 +43,8 @@ DEF_CLASS_IID (Vst::IComponentHandler) DEF_CLASS_IID (Vst::IComponentHandler2) DEF_CLASS_IID (Vst::IConnectionPoint) DEF_CLASS_IID (Vst::IEditController) +DEF_CLASS_IID (Vst::IEditController2) +DEF_CLASS_IID (Vst::IEditControllerHostEditing) DEF_CLASS_IID (Vst::IEventList) DEF_CLASS_IID (Vst::IHostApplication) DEF_CLASS_IID (Vst::IMessage) @@ -291,10 +293,10 @@ PlugInterfaceSupport::PlugInterfaceSupport () //---VST 3.0.1-------------------------------- addPlugInterfaceSupported (IMidiMapping::iid); -#if 0 //---VST 3.1---------------------------------- addPlugInterfaceSupported (IEditController2::iid); +#if 0 //---VST 3.0.2-------------------------------- addPlugInterfaceSupported (IParameterFinder::iid); @@ -304,7 +306,9 @@ PlugInterfaceSupport::PlugInterfaceSupport () //---VST 3.5---------------------------------- addPlugInterfaceSupported (IKeyswitchController::iid); addPlugInterfaceSupported (IContextMenuTarget::iid); +#endif addPlugInterfaceSupported (IEditControllerHostEditing::iid); +#if 0 addPlugInterfaceSupported (IXmlRepresentationController::iid); addPlugInterfaceSupported (INoteExpressionController::iid); diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index 45a230df6a..e480f5804e 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -108,6 +108,9 @@ VST3Plugin::parameter_change_handler (VST3PI::ParameterChange t, uint32_t param, case VST3PI::InternalChange: Plugin::state_changed (); break; + case VST3PI::PresetChange: + PresetsChanged (unique_id (), this, false); /* EMIT SIGNAL */ + break; } } @@ -1013,6 +1016,13 @@ VST3PI::VST3PI (boost::shared_ptr m, std::string uniqu 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::kRelativCircularMode); + } + int32 n_params = _controller->getParameterCount (); for (int32 i = 0; i < n_params; ++i) { Vst::ParameterInfo pi; @@ -1023,7 +1033,8 @@ VST3PI::VST3PI (boost::shared_ptr m, std::string uniqu _program_change_port = pi; continue; } - if (0 == (pi.flags & Vst::ParameterInfo::kCanAutomate)) { + /* 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; @@ -1278,6 +1289,19 @@ VST3PI::restartComponent (int32 flags) return kResultOk; } +tresult +VST3PI::notifyUnitSelection (Vst::UnitID unitId) +{ + return kResultFalse; +} + +tresult +VST3PI::notifyProgramListChange (Vst::ProgramListID, int32) +{ + OnParameterChange (PresetChange, 0, 0); /* EMIT SIGNAL */ + return kResultOk; +} + tresult VST3PI::performEdit (Vst::ParamID id, Vst::ParamValue v) { @@ -1679,13 +1703,22 @@ void VST3PI::update_contoller_param () { /* GUI thread */ + FUnknownPtr host_editing (_controller); + std::map::const_iterator i; for (i = _ctrl_index_id.begin (); i != _ctrl_index_id.end (); ++i) { if (!_update_ctrl[i->first]) { continue; } _update_ctrl[i->first] = false; + if (!parameter_is_automatable (i->first) && !parameter_is_readonly (i->first)) { + assert (host_editing); + host_editing->beginEditFromHost (i->second); + } _controller->setParamNormalized (i->second, _shadow_data[i->first]); + if (!parameter_is_automatable (i->first) && !parameter_is_readonly (i->first)) { + host_editing->endEditFromHost (i->second); + } } } @@ -1716,7 +1749,16 @@ VST3PI::get_parameter (uint32_t p) const Vst::ParamID id = index_to_id (p); if (_update_ctrl[p]) { _update_ctrl[p] = false; + + FUnknownPtr host_editing (_controller); + if (!parameter_is_automatable (p) && !parameter_is_readonly (p)) { + assert (host_editing); + host_editing->beginEditFromHost (id); + } _controller->setParamNormalized (id, _shadow_data[p]); // GUI thread only + if (!parameter_is_automatable (p) && !parameter_is_readonly (p)) { + host_editing->endEditFromHost (id); + } } return _controller->normalizedParamToPlain (id, _shadow_data[p]); }