2 Copyright (C) 2011 Tim Mayberry
3 Copyright (C) 2013 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "pbd/pathexpand.h"
27 #include "ardour/search_paths.h"
28 #include "ardour/directory_names.h"
29 #include "ardour/filesystem_paths.h"
31 #ifdef PLATFORM_WINDOWS
33 #include <shlobj.h> // CSIDL_*
34 #include "pbd/windows_special_dirs.h"
38 const char * const backend_env_variable_name = "ARDOUR_BACKEND_PATH";
39 const char * const surfaces_env_variable_name = "ARDOUR_SURFACES_PATH";
40 const char * const export_env_variable_name = "ARDOUR_EXPORT_FORMATS_PATH";
41 const char * const ladspa_env_variable_name = "LADSPA_PATH";
42 const char * const midi_patch_env_variable_name = "ARDOUR_MIDI_PATCH_PATH";
43 const char * const panner_env_variable_name = "ARDOUR_PANNER_PATH";
51 backend_search_path ()
53 Searchpath spath(user_config_directory ());
54 spath += ardour_dll_directory ();
55 spath.add_subdirectory_to_paths(backend_dir_name);
57 spath += Searchpath(Glib::getenv(backend_env_variable_name));
62 control_protocol_search_path ()
64 Searchpath spath(user_config_directory ());
65 spath += ardour_dll_directory ();
66 spath.add_subdirectory_to_paths (surfaces_dir_name);
68 spath += Searchpath(Glib::getenv(surfaces_env_variable_name));
73 export_formats_search_path ()
75 Searchpath spath (ardour_data_search_path());
76 spath.add_subdirectory_to_paths (export_formats_dir_name);
78 bool export_formats_path_defined = false;
79 Searchpath spath_env (Glib::getenv(export_env_variable_name, export_formats_path_defined));
81 if (export_formats_path_defined) {
91 Searchpath spath_env (Glib::getenv(ladspa_env_variable_name));
93 Searchpath spath (user_config_directory ());
95 spath += ardour_dll_directory ();
96 spath.add_subdirectory_to_paths (ladspa_dir_name);
98 #ifndef PLATFORM_WINDOWS
99 spath.push_back ("/usr/local/lib64/ladspa");
100 spath.push_back ("/usr/local/lib/ladspa");
101 spath.push_back ("/usr/lib64/ladspa");
102 spath.push_back ("/usr/lib/ladspa");
106 spath.push_back (path_expand ("~/Library/Audio/Plug-Ins/LADSPA"));
107 spath.push_back ("/Library/Audio/Plug-Ins/LADSPA");
110 return spath_env + spath;
114 lv2_bundled_search_path ()
116 Searchpath spath( ardour_dll_directory () );
117 spath.add_subdirectory_to_paths ("LV2");
123 midi_patch_search_path ()
125 Searchpath spath (ardour_data_search_path());
126 spath.add_subdirectory_to_paths(midi_patch_dir_name);
128 bool midi_patch_path_defined = false;
129 Searchpath spath_env (Glib::getenv(midi_patch_env_variable_name, midi_patch_path_defined));
131 if (midi_patch_path_defined) {
139 panner_search_path ()
141 Searchpath spath(user_config_directory ());
143 spath += ardour_dll_directory ();
144 spath.add_subdirectory_to_paths(panner_dir_name);
145 spath += Searchpath(Glib::getenv(panner_env_variable_name));
151 template_search_path ()
153 Searchpath spath (ardour_data_search_path());
154 spath.add_subdirectory_to_paths(templates_dir_name);
159 route_template_search_path ()
161 Searchpath spath (ardour_data_search_path());
162 spath.add_subdirectory_to_paths(route_templates_dir_name);
169 Searchpath spath (ardour_data_search_path());
170 spath.add_subdirectory_to_paths(lua_dir_name);
175 #ifdef PLATFORM_WINDOWS
180 DWORD dwType = REG_SZ;
182 DWORD dwSize = PATH_MAX;
185 char tmp[PATH_MAX+1];
187 if (ERROR_SUCCESS == RegOpenKeyExA (HKEY_CURRENT_USER, "Software\\VST", 0, KEY_READ, &hKey)) {
188 // Look for the user's VST Registry entry
189 if (ERROR_SUCCESS == RegQueryValueExA (hKey, "VSTPluginsPath", 0, &dwType, (LPBYTE)tmp, &dwSize))
190 p = g_build_filename (Glib::locale_to_utf8(tmp).c_str(), NULL);
196 if (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\VST", 0, KEY_READ, &hKey))
198 // Look for a global VST Registry entry
199 if (ERROR_SUCCESS == RegQueryValueExA (hKey, "VSTPluginsPath", 0, &dwType, (LPBYTE)tmp, &dwSize))
200 p = g_build_filename (Glib::locale_to_utf8(tmp).c_str(), NULL);
207 #if ( (defined __i386__) || (defined _M_IX86) )
209 std::string pProgFilesX86 = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILESX86);
211 if (!pProgFilesX86.empty()) {
212 // Look for a VST folder under C:\Program Files (x86)
213 if ((pVSTx86 = g_build_filename (pProgFilesX86.c_str(), "Steinberg", "VSTPlugins", NULL)))
215 if (Glib::file_test (pVSTx86, Glib::FILE_TEST_EXISTS))
216 if (Glib::file_test (pVSTx86, Glib::FILE_TEST_IS_DIR))
217 p = g_build_filename (pVSTx86, NULL);
223 // Look for a VST folder under C:\Program Files
225 std::string pProgFiles = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
227 if (!pProgFiles.empty()) {
228 if ((pVST = g_build_filename (pProgFiles.c_str(), "Steinberg", "VSTPlugins", NULL))) {
229 if (Glib::file_test (pVST, Glib::FILE_TEST_EXISTS))
230 if (Glib::file_test (pVST, Glib::FILE_TEST_IS_DIR))
231 p = g_build_filename (pVST, NULL);
240 // If all else failed, assume the plugins are under "My Documents"
241 user_home = (char*) g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
243 p = g_build_filename (user_home, "Plugins", "VST", NULL);
245 user_home = g_build_filename(g_get_home_dir(), "My Documents", NULL);
247 p = g_build_filename (user_home, "Plugins", "VST", NULL);
250 // Concatenate the registry path with the user's personal path
251 user_home = (char*) g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
254 p = g_build_path (";", p, g_build_filename(user_home, "Plugins", "VST", NULL), NULL);
256 user_home = g_build_filename(g_get_home_dir(), "My Documents", NULL);
259 p = g_build_path (";", p, g_build_filename (user_home, "Plugins", "VST", NULL), NULL);
269 /* Unix-like. Probably require some OS X specific breakdown if we ever add VST
270 * support on that platform.
276 return "/usr/local/lib/vst:/usr/lib/vst";
279 #endif // PLATFORM_WINDOWS
281 } // namespace ARDOUR