redesign VCA control over gain (and theoretically other scalar controls)
[ardour.git] / libs / ardour / ardour / plugin_manager.h
1 /*
2     Copyright (C) 2000-2007 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_plugin_manager_h__
21 #define __ardour_plugin_manager_h__
22
23 #ifdef WAF_BUILD
24 #include "libardour-config.h"
25 #endif
26
27 #include <list>
28 #include <map>
29 #include <string>
30 #include <set>
31 #include <boost/utility.hpp>
32
33 #include "ardour/libardour_visibility.h"
34 #include "ardour/types.h"
35 #include "ardour/plugin.h"
36
37 namespace ARDOUR {
38
39 class Plugin;
40
41 class LIBARDOUR_API PluginManager : public boost::noncopyable {
42   public:
43         static PluginManager& instance();
44         static std::string scanner_bin_path;
45
46         ~PluginManager ();
47
48         const ARDOUR::PluginInfoList& windows_vst_plugin_info ();
49         const ARDOUR::PluginInfoList& lxvst_plugin_info ();
50         const ARDOUR::PluginInfoList& mac_vst_plugin_info ();
51         const ARDOUR::PluginInfoList& ladspa_plugin_info ();
52         const ARDOUR::PluginInfoList& lv2_plugin_info ();
53         const ARDOUR::PluginInfoList& au_plugin_info ();
54         const ARDOUR::PluginInfoList& lua_plugin_info ();
55
56         void refresh (bool cache_only = false);
57         void cancel_plugin_scan();
58         void cancel_plugin_timeout();
59         void clear_vst_cache ();
60         void clear_vst_blacklist ();
61         void clear_au_cache ();
62         void clear_au_blacklist ();
63
64         const std::string get_default_windows_vst_path() const { return windows_vst_path; }
65         const std::string get_default_lxvst_path() const { return lxvst_path; }
66
67         bool cancelled () { return _cancel_scan; }
68         bool no_timeout () { return _cancel_timeout; }
69
70         enum PluginStatusType {
71                 Normal = 0,
72                 Favorite,
73                 Hidden
74         };
75
76         void load_statuses ();
77         void save_statuses ();
78         void set_status (ARDOUR::PluginType type, std::string unique_id, PluginStatusType status);
79         PluginStatusType get_status (const PluginInfoPtr&) const;
80
81         /** plugins were added to or removed from one of the PluginInfoLists */
82         PBD::Signal0<void> PluginListChanged;
83         /** Plugin Hidden/Favorite status changed */
84         PBD::Signal0<void> PluginStatusesChanged;
85
86   private:
87         struct PluginStatus {
88             ARDOUR::PluginType type;
89             std::string unique_id;
90             PluginStatusType status;
91
92             PluginStatus (ARDOUR::PluginType t, std::string id, PluginStatusType s = Normal)
93             : type (t), unique_id (id), status (s) {}
94
95             bool operator==(const PluginStatus& other) const {
96                     return other.type == type && other.unique_id == unique_id;
97             }
98
99             bool operator<(const PluginStatus& other) const {
100                     if (other.type < type) {
101                             return true;
102                     } else if (other.type == type && other.unique_id < unique_id) {
103                             return true;
104                     }
105                     return false;
106             }
107         };
108         typedef std::set<PluginStatus> PluginStatusList;
109         PluginStatusList statuses;
110
111         ARDOUR::PluginInfoList  _empty_plugin_info;
112         ARDOUR::PluginInfoList* _windows_vst_plugin_info;
113         ARDOUR::PluginInfoList* _lxvst_plugin_info;
114         ARDOUR::PluginInfoList* _mac_vst_plugin_info;
115         ARDOUR::PluginInfoList* _ladspa_plugin_info;
116         ARDOUR::PluginInfoList* _lv2_plugin_info;
117         ARDOUR::PluginInfoList* _au_plugin_info;
118         ARDOUR::PluginInfoList* _lua_plugin_info;
119
120         std::map<uint32_t, std::string> rdf_type;
121
122         std::string windows_vst_path;
123         std::string lxvst_path;
124
125         bool _cancel_scan;
126         bool _cancel_timeout;
127
128         void ladspa_refresh ();
129         void lua_refresh ();
130         void lua_refresh_cb ();
131         void windows_vst_refresh (bool cache_only = false);
132         void mac_vst_refresh (bool cache_only = false);
133         void lxvst_refresh (bool cache_only = false);
134
135         void add_lrdf_data (const std::string &path);
136         void add_ladspa_presets ();
137         void add_windows_vst_presets ();
138         void add_mac_vst_presets ();
139         void add_lxvst_presets ();
140         void add_presets (std::string domain);
141
142         void au_refresh (bool cache_only = false);
143
144         void lv2_refresh ();
145
146         int windows_vst_discover_from_path (std::string path, bool cache_only = false);
147         int windows_vst_discover (std::string path, bool cache_only = false);
148
149         int mac_vst_discover_from_path (std::string path, bool cache_only = false);
150         int mac_vst_discover (std::string path, bool cache_only = false);
151
152         int lxvst_discover_from_path (std::string path, bool cache_only = false);
153         int lxvst_discover (std::string path, bool cache_only = false);
154
155         int ladspa_discover (std::string path);
156
157         std::string get_ladspa_category (uint32_t id);
158         std::vector<uint32_t> ladspa_plugin_whitelist;
159
160         PBD::ScopedConnection lua_refresh_connection;
161         Glib::Threads::Mutex _lock;
162
163         static PluginManager* _instance; // singleton
164         PluginManager ();
165 };
166
167 } /* namespace ARDOUR */
168
169 #endif /* __ardour_plugin_manager_h__ */
170