X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fwindows_vst_plugin.cc;h=4bfe8226459699f67c921262bf8a01c8a3a517f1;hb=357361c89d4c3743ee86f9dc3a349b9e2aae658c;hp=571b0e5e7f15bbc0bc68c9ca908fda6e5323511e;hpb=d1226a8628f11d32251666d5fb9d9dabbc44446c;p=ardour.git diff --git a/libs/ardour/windows_vst_plugin.cc b/libs/ardour/windows_vst_plugin.cc index 571b0e5e7f..4bfe822645 100644 --- a/libs/ardour/windows_vst_plugin.cc +++ b/libs/ardour/windows_vst_plugin.cc @@ -19,23 +19,30 @@ #include "fst.h" +#include +#include + +#include "ardour/filesystem_paths.h" #include "ardour/windows_vst_plugin.h" #include "ardour/session.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; using namespace PBD; -WindowsVSTPlugin::WindowsVSTPlugin (AudioEngine& e, Session& session, VSTHandle* h) +WindowsVSTPlugin::WindowsVSTPlugin (AudioEngine& e, Session& session, VSTHandle* h, int unique_id) : VSTPlugin (e, session, h) { + Session::vst_current_loading_id = unique_id; if ((_state = fst_instantiate (_handle, Session::vst_callback, this)) == 0) { throw failed_constructor(); } + open_plugin (); + Session::vst_current_loading_id = 0; - set_plugin (_state->plugin); + init_plugin (); } WindowsVSTPlugin::WindowsVSTPlugin (const WindowsVSTPlugin &other) @@ -43,15 +50,24 @@ WindowsVSTPlugin::WindowsVSTPlugin (const WindowsVSTPlugin &other) { _handle = other._handle; + Session::vst_current_loading_id = PBD::atoi(other.unique_id()); if ((_state = fst_instantiate (_handle, Session::vst_callback, this)) == 0) { throw failed_constructor(); } - - _plugin = _state->plugin; + open_plugin (); + Session::vst_current_loading_id = 0; + + XMLNode* root = new XMLNode (other.state_node_name ()); + other.add_state (root); + set_state (*root, Stateful::loading_state_version); + delete root; + + init_plugin (); } WindowsVSTPlugin::~WindowsVSTPlugin () { + deactivate (); fst_close (_state); } @@ -66,10 +82,10 @@ WindowsVSTPluginInfo::load (Session& session) handle = fst_load(path.c_str()); - if ((int) handle == -1) { + if (!handle) { error << string_compose(_("VST: cannot load module from \"%1\""), path) << endmsg; } else { - plugin.reset (new WindowsVSTPlugin (session.engine(), session, handle)); + plugin.reset (new WindowsVSTPlugin (session.engine(), session, handle, PBD::atoi(unique_id))); } } else { error << _("You asked ardour to not use any VST plugins") << endmsg; @@ -85,6 +101,39 @@ WindowsVSTPluginInfo::load (Session& session) } } +std::vector +WindowsVSTPluginInfo::get_presets (bool user_only) const +{ + std::vector p; +#ifndef NO_PLUGIN_STATE + if (!Config->get_use_lxvst()) { + return p; + } + + if (!user_only) { + // TODO cache and load factory-preset names + } + + /* user presets */ + XMLTree* t = new XMLTree; + std::string pf = Glib::build_filename (ARDOUR::user_config_directory (), "presets", string_compose ("vst-%1", unique_id)); + if (Glib::file_test (pf, Glib::FILE_TEST_EXISTS)) { + t->set_filename (pf); + if (t->read ()) { + XMLNode* root = t->root (); + for (XMLNodeList::const_iterator i = root->children().begin(); i != root->children().end(); ++i) { + XMLProperty const * uri = (*i)->property (X_("uri")); + XMLProperty const * label = (*i)->property (X_("label")); + p.push_back (Plugin::PresetRecord (uri->value(), label->value(), true)); + } + } + } + delete t; +#endif + + return p; +} + WindowsVSTPluginInfo::WindowsVSTPluginInfo() { type = ARDOUR::Windows_VST;