diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-04-24 17:59:08 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-04-24 17:59:08 +0000 |
commit | 1e59c4a2205d35a0bff50cce1ffa028fa32e5bdf (patch) | |
tree | b2d95afd0a38c7fbb387afd12956f43fded77764 /libs/ardour/plugin_manager.cc | |
parent | 805d4d54a1fbf1dad6cc693ff427101678457ca4 (diff) |
plugin selection via menu, along with "favorites"
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3284 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/plugin_manager.cc')
-rw-r--r-- | libs/ardour/plugin_manager.cc | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 336763faa1..2157774cac 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -21,6 +21,8 @@ #include <cstdio> #include <lrdf.h> #include <dlfcn.h> +#include <cstdlib> +#include <fstream> #ifdef VST_SUPPORT #include <fst.h> @@ -56,6 +58,7 @@ using namespace ARDOUR; using namespace PBD; +using namespace std; PluginManager* PluginManager::_manager = 0; @@ -64,6 +67,8 @@ PluginManager::PluginManager () char* s; string lrdf_path; + load_favorites (); + if ((s = getenv ("LADSPA_RDF_PATH"))){ lrdf_path = s; } @@ -484,3 +489,111 @@ PluginManager::vst_discover (string path) } #endif // VST_SUPPORT + +bool +PluginManager::is_a_favorite_plugin (const PluginInfoPtr& pi) +{ + FavoritePlugin fp (pi->type, pi->unique_id); + return find (favorites.begin(), favorites.end(), fp) != favorites.end(); +} + +void +PluginManager::save_favorites () +{ + Glib::ustring path = get_user_ardour_path (); + path += '/'; + path += "favorite_plugins"; + + ofstream ofs; + + ofs.open (path.c_str(), ios_base::openmode (ios::out|ios::trunc)); + + if (!ofs) { + return; + } + + for (FavoritePluginList::iterator i = favorites.begin(); i != favorites.end(); ++i) { + switch ((*i).type) { + case LADSPA: + ofs << "LADSPA"; + break; + case AudioUnit: + ofs << "AudioUnit"; + break; + case LV2: + ofs << "LV2"; + break; + case VST: + ofs << "VST"; + break; + } + + ofs << ' ' << (*i).unique_id << endl; + } + + ofs.close (); +} + +void +PluginManager::load_favorites () +{ + Glib::ustring path = get_user_ardour_path (); + path += '/'; + path += "favorite_plugins"; + + ifstream ifs (path.c_str()); + + if (!ifs) { + return; + } + + std::string stype; + std::string id; + PluginType type; + + while (ifs) { + + ifs >> stype; + if (!ifs) { + break; + + } + ifs >> id; + if (!ifs) { + break; + } + + if (stype == "LADSPA") { + type = LADSPA; + } else if (stype == "AudioUnit") { + type = AudioUnit; + } else if (stype == "LV2") { + type = LV2; + } else if (stype == "VST") { + type = VST; + } else { + error << string_compose (_("unknown favorite plugin type \"%1\" - ignored"), stype) + << endmsg; + continue; + } + + add_favorite (type, id); + } + + ifs.close (); +} + +void +PluginManager::add_favorite (PluginType t, string id) +{ + FavoritePlugin fp (t, id); + pair<FavoritePluginList::iterator,bool> res = favorites.insert (fp); + cerr << "Added " << t << " " << id << " success ? " << res.second << endl; +} + +void +PluginManager::remove_favorite (PluginType t, string id) +{ + FavoritePlugin fp (t, id); + favorites.erase (fp); +} |