2 * Copyright (C) 2014-2018 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2014 John Emmas <john@creativepost.co.uk>
4 * Copyright (C) 2015-2016 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2016 Ben Loftis <ben@harrisonconsoles.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "pbd/pathexpand.h"
28 #include "ardour/search_paths.h"
29 #include "ardour/directory_names.h"
30 #include "ardour/filesystem_paths.h"
32 #ifdef PLATFORM_WINDOWS
34 #include <shlobj.h> // CSIDL_*
35 #include "pbd/windows_special_dirs.h"
39 const char * const backend_env_variable_name = "ARDOUR_BACKEND_PATH";
40 const char * const surfaces_env_variable_name = "ARDOUR_SURFACES_PATH";
41 const char * const export_env_variable_name = "ARDOUR_EXPORT_FORMATS_PATH";
42 const char * const theme_env_variable_name = "ARDOUR_THEMES_PATH";
43 const char * const ladspa_env_variable_name = "LADSPA_PATH";
44 const char * const midi_patch_env_variable_name = "ARDOUR_MIDI_PATCH_PATH";
45 const char * const panner_env_variable_name = "ARDOUR_PANNER_PATH";
53 backend_search_path ()
55 Searchpath spath(user_config_directory ());
56 spath += ardour_dll_directory ();
57 spath.add_subdirectory_to_paths(backend_dir_name);
59 spath += Searchpath(Glib::getenv(backend_env_variable_name));
64 control_protocol_search_path ()
66 Searchpath spath(user_config_directory ());
67 spath += ardour_dll_directory ();
68 spath.add_subdirectory_to_paths (surfaces_dir_name);
70 spath += Searchpath(Glib::getenv(surfaces_env_variable_name));
77 Searchpath spath (ardour_data_search_path ());
78 spath.add_subdirectory_to_paths (theme_dir_name);
80 spath += Searchpath(Glib::getenv(theme_env_variable_name));
85 export_formats_search_path ()
87 Searchpath spath (ardour_data_search_path());
88 spath.add_subdirectory_to_paths (export_formats_dir_name);
90 bool export_formats_path_defined = false;
91 Searchpath spath_env (Glib::getenv(export_env_variable_name, export_formats_path_defined));
93 if (export_formats_path_defined) {
101 ladspa_search_path ()
103 Searchpath spath_env (Glib::getenv(ladspa_env_variable_name));
105 Searchpath spath (user_config_directory ());
107 spath += ardour_dll_directory ();
108 spath.add_subdirectory_to_paths (ladspa_dir_name);
110 #ifndef PLATFORM_WINDOWS
111 spath.push_back ("/usr/local/lib64/ladspa");
112 spath.push_back ("/usr/local/lib/ladspa");
113 spath.push_back ("/usr/lib64/ladspa");
114 spath.push_back ("/usr/lib/ladspa");
118 spath.push_back (path_expand ("~/Library/Audio/Plug-Ins/LADSPA"));
119 spath.push_back ("/Library/Audio/Plug-Ins/LADSPA");
122 return spath_env + spath;
126 lv2_bundled_search_path ()
128 Searchpath spath( ardour_dll_directory () );
129 spath.add_subdirectory_to_paths ("LV2");
135 midi_patch_search_path ()
137 Searchpath spath (ardour_data_search_path());
138 spath.add_subdirectory_to_paths(midi_patch_dir_name);
140 bool midi_patch_path_defined = false;
141 Searchpath spath_env (Glib::getenv(midi_patch_env_variable_name, midi_patch_path_defined));
143 if (midi_patch_path_defined) {
151 panner_search_path ()
153 Searchpath spath(user_config_directory ());
155 spath += ardour_dll_directory ();
156 spath.add_subdirectory_to_paths(panner_dir_name);
157 spath += Searchpath(Glib::getenv(panner_env_variable_name));
163 template_search_path ()
165 Searchpath spath (ardour_data_search_path());
166 spath.add_subdirectory_to_paths(templates_dir_name);
171 plugin_metadata_search_path ()
173 Searchpath spath (ardour_data_search_path());
174 spath.add_subdirectory_to_paths(plugin_metadata_dir_name);
179 route_template_search_path ()
181 Searchpath spath (ardour_data_search_path());
182 spath.add_subdirectory_to_paths(route_templates_dir_name);
189 Searchpath spath (ardour_data_search_path());
190 spath.add_subdirectory_to_paths(lua_dir_name);
195 #ifdef PLATFORM_WINDOWS
200 DWORD dwType = REG_SZ;
202 DWORD dwSize = PATH_MAX;
205 char tmp[PATH_MAX+1];
207 if (ERROR_SUCCESS == RegOpenKeyExA (HKEY_CURRENT_USER, "Software\\VST", 0, KEY_READ, &hKey)) {
208 // Look for the user's VST Registry entry
209 if (ERROR_SUCCESS == RegQueryValueExA (hKey, "VSTPluginsPath", 0, &dwType, (LPBYTE)tmp, &dwSize))
210 p = g_build_filename (Glib::locale_to_utf8(tmp).c_str(), NULL);
216 if (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\VST", 0, KEY_READ, &hKey))
218 // Look for a global VST Registry entry
219 if (ERROR_SUCCESS == RegQueryValueExA (hKey, "VSTPluginsPath", 0, &dwType, (LPBYTE)tmp, &dwSize))
220 p = g_build_filename (Glib::locale_to_utf8(tmp).c_str(), NULL);
227 #if ( (defined __i386__) || (defined _M_IX86) )
229 std::string pProgFilesX86 = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILESX86);
231 if (!pProgFilesX86.empty()) {
232 // Look for a VST folder under C:\Program Files (x86)
233 if ((pVSTx86 = g_build_filename (pProgFilesX86.c_str(), "Steinberg", "VSTPlugins", NULL)))
235 if (Glib::file_test (pVSTx86, Glib::FILE_TEST_EXISTS))
236 if (Glib::file_test (pVSTx86, Glib::FILE_TEST_IS_DIR))
237 p = g_build_filename (pVSTx86, NULL);
243 // Look for a VST folder under C:\Program Files
245 std::string pProgFiles = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
247 if (!pProgFiles.empty()) {
248 if ((pVST = g_build_filename (pProgFiles.c_str(), "Steinberg", "VSTPlugins", NULL))) {
249 if (Glib::file_test (pVST, Glib::FILE_TEST_EXISTS))
250 if (Glib::file_test (pVST, Glib::FILE_TEST_IS_DIR))
251 p = g_build_filename (pVST, NULL);
260 // If all else failed, assume the plugins are under "My Documents"
261 user_home = (char*) g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
263 p = g_build_filename (user_home, "Plugins", "VST", NULL);
265 user_home = g_build_filename(g_get_home_dir(), "My Documents", NULL);
267 p = g_build_filename (user_home, "Plugins", "VST", NULL);
270 // Concatenate the registry path with the user's personal path
271 user_home = (char*) g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
274 p = g_build_path (";", p, g_build_filename(user_home, "Plugins", "VST", NULL), NULL);
276 user_home = g_build_filename(g_get_home_dir(), "My Documents", NULL);
279 p = g_build_path (";", p, g_build_filename (user_home, "Plugins", "VST", NULL), NULL);
289 /* Unix-like. Probably require some OS X specific breakdown if we ever add VST
290 * support on that platform.
296 return "/usr/local/lib/vst:/usr/lib/vst";
299 #endif // PLATFORM_WINDOWS
301 } // namespace ARDOUR