Transfer 'panner_search_path()' into 'libs/ardour/search_paths.cc'
[ardour.git] / libs / ardour / search_paths.cc
1 /*
2     Copyright (C) 2011 Tim Mayberry 
3     Copyright (C) 2013 Paul Davis 
4
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.
9
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.
14
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.
18
19 */
20
21 #include <glibmm/miscutils.h>
22
23 #include "pbd/pathexpand.h"
24
25 #include "ardour/search_paths.h"
26 #include "ardour/directory_names.h"
27 #include "ardour/filesystem_paths.h"
28
29 namespace {
30         const char * const backend_env_variable_name = "ARDOUR_BACKEND_PATH";
31         const char * const surfaces_env_variable_name = "ARDOUR_SURFACES_PATH";
32         const char * const export_env_variable_name = "ARDOUR_EXPORT_FORMATS_PATH";
33         const char * const ladspa_env_variable_name = "LADSPA_PATH";
34         const char * const midi_patch_env_variable_name = "ARDOUR_MIDI_PATCH_PATH";
35         const char * const panner_env_variable_name = "ARDOUR_PANNER_PATH";
36 } // anonymous
37
38 using namespace PBD;
39
40 namespace ARDOUR {
41
42 Searchpath
43 backend_search_path ()
44 {
45         Searchpath spath(user_config_directory ());
46         spath += ardour_dll_directory ();
47         spath.add_subdirectory_to_paths(backend_dir_name);
48
49         spath += Searchpath(Glib::getenv(backend_env_variable_name));
50         return spath;
51 }
52
53 Searchpath
54 control_protocol_search_path ()
55 {
56         Searchpath spath(user_config_directory ());
57         spath += ardour_dll_directory ();
58         spath.add_subdirectory_to_paths (surfaces_dir_name);
59         
60         spath += Searchpath(Glib::getenv(surfaces_env_variable_name));
61         return spath;
62 }
63
64 Searchpath
65 export_formats_search_path ()
66 {
67         Searchpath spath (ardour_data_search_path());
68         spath.add_subdirectory_to_paths (export_formats_dir_name);
69
70         bool export_formats_path_defined = false;
71         Searchpath spath_env (Glib::getenv(export_env_variable_name, export_formats_path_defined));
72
73         if (export_formats_path_defined) {
74                 spath += spath_env;
75         }
76
77         return spath;
78 }
79
80 Searchpath
81 ladspa_search_path ()
82 {
83         Searchpath spath_env (Glib::getenv(ladspa_env_variable_name));
84
85         Searchpath spath (user_config_directory ());
86
87         spath += ardour_dll_directory ();
88         spath.add_subdirectory_to_paths (ladspa_dir_name);
89
90 #ifndef PLATFORM_WINDOWS
91         spath.push_back ("/usr/local/lib64/ladspa");
92         spath.push_back ("/usr/local/lib/ladspa");
93         spath.push_back ("/usr/lib64/ladspa");
94         spath.push_back ("/usr/lib/ladspa");
95 #endif
96
97 #ifdef __APPLE__
98         spath.push_back (path_expand ("~/Library/Audio/Plug-Ins/LADSPA"));
99         spath.push_back ("/Library/Audio/Plug-Ins/LADSPA");
100 #endif
101
102         return spath_env + spath;
103 }
104
105 Searchpath
106 lv2_bundled_search_path ()
107 {
108         Searchpath spath( ardour_dll_directory () );
109         spath.add_subdirectory_to_paths ("LV2");
110
111         return spath;
112 }
113
114 Searchpath
115 midi_patch_search_path ()
116 {
117         Searchpath spath (ardour_data_search_path());
118         spath.add_subdirectory_to_paths(midi_patch_dir_name);
119
120         bool midi_patch_path_defined = false;
121         Searchpath spath_env (Glib::getenv(midi_patch_env_variable_name, midi_patch_path_defined));
122
123         if (midi_patch_path_defined) {
124                 spath += spath_env;
125         }
126
127         return spath;
128 }
129
130 Searchpath
131 panner_search_path ()
132 {
133         Searchpath spath(user_config_directory ());
134
135         spath += ardour_dll_directory ();
136         spath.add_subdirectory_to_paths(panner_dir_name);
137         spath += Searchpath(Glib::getenv(panner_env_variable_name));
138
139         return spath;
140 }
141
142 } // namespace ARDOUR