Transfer 'midi_patch_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 } // anonymous
36
37 using namespace PBD;
38
39 namespace ARDOUR {
40
41 Searchpath
42 backend_search_path ()
43 {
44         Searchpath spath(user_config_directory ());
45         spath += ardour_dll_directory ();
46         spath.add_subdirectory_to_paths(backend_dir_name);
47
48         spath += Searchpath(Glib::getenv(backend_env_variable_name));
49         return spath;
50 }
51
52 Searchpath
53 control_protocol_search_path ()
54 {
55         Searchpath spath(user_config_directory ());
56         spath += ardour_dll_directory ();
57         spath.add_subdirectory_to_paths (surfaces_dir_name);
58         
59         spath += Searchpath(Glib::getenv(surfaces_env_variable_name));
60         return spath;
61 }
62
63 Searchpath
64 export_formats_search_path ()
65 {
66         Searchpath spath (ardour_data_search_path());
67         spath.add_subdirectory_to_paths (export_formats_dir_name);
68
69         bool export_formats_path_defined = false;
70         Searchpath spath_env (Glib::getenv(export_env_variable_name, export_formats_path_defined));
71
72         if (export_formats_path_defined) {
73                 spath += spath_env;
74         }
75
76         return spath;
77 }
78
79 Searchpath
80 ladspa_search_path ()
81 {
82         Searchpath spath_env (Glib::getenv(ladspa_env_variable_name));
83
84         Searchpath spath (user_config_directory ());
85
86         spath += ardour_dll_directory ();
87         spath.add_subdirectory_to_paths (ladspa_dir_name);
88
89 #ifndef PLATFORM_WINDOWS
90         spath.push_back ("/usr/local/lib64/ladspa");
91         spath.push_back ("/usr/local/lib/ladspa");
92         spath.push_back ("/usr/lib64/ladspa");
93         spath.push_back ("/usr/lib/ladspa");
94 #endif
95
96 #ifdef __APPLE__
97         spath.push_back (path_expand ("~/Library/Audio/Plug-Ins/LADSPA"));
98         spath.push_back ("/Library/Audio/Plug-Ins/LADSPA");
99 #endif
100
101         return spath_env + spath;
102 }
103
104 Searchpath
105 lv2_bundled_search_path ()
106 {
107         Searchpath spath( ardour_dll_directory () );
108         spath.add_subdirectory_to_paths ("LV2");
109
110         return spath;
111 }
112
113 Searchpath
114 midi_patch_search_path ()
115 {
116         Searchpath spath (ardour_data_search_path());
117         spath.add_subdirectory_to_paths(midi_patch_dir_name);
118
119         bool midi_patch_path_defined = false;
120         Searchpath spath_env (Glib::getenv(midi_patch_env_variable_name, midi_patch_path_defined));
121
122         if (midi_patch_path_defined) {
123                 spath += spath_env;
124         }
125
126         return spath;
127 }
128
129 } // namespace ARDOUR