1 /*
2  * Carla Plugin Host
3  * Copyright (C) 2011-2021 Filipe Coelho <falktx@falktx.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of
8  * the License, or 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  * For a full copy of the GNU General Public License see the doc/GPL.txt file.
16  */
17 
18 #include "CarlaHost.h"
19 #include "CarlaUtils.h"
20 
21 #include "CarlaString.hpp"
22 
23 #if defined(HAVE_FLUIDSYNTH) && !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH)
24 # include <fluidsynth.h>
25 #endif
26 
27 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
28 # pragma GCC diagnostic push
29 # pragma GCC diagnostic ignored "-Wconversion"
30 # pragma GCC diagnostic ignored "-Weffc++"
31 # pragma GCC diagnostic ignored "-Wsign-conversion"
32 # pragma GCC diagnostic ignored "-Wundef"
33 # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
34 #endif
35 
36 #ifdef USING_JUCE
37 # include "AppConfig.h"
38 # include "juce_core/juce_core.h"
39 #else
40 # include "rtaudio/RtAudio.h"
41 # include "rtmidi/RtMidi.h"
42 #endif
43 
44 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
45 # pragma GCC diagnostic pop
46 #endif
47 
48 #include "water/files/File.h"
49 
50 // -------------------------------------------------------------------------------------------------------------------
51 
carla_get_complete_license_text()52 const char* carla_get_complete_license_text()
53 {
54     carla_debug("carla_get_complete_license_text()");
55 
56     static CarlaString retText;
57 
58     if (retText.isEmpty())
59     {
60         retText =
61         "<p>This current Carla build is using the following features and 3rd-party code:</p>"
62         "<ul>"
63 
64         // Plugin formats
65         "<li>LADSPA plugin support</li>"
66         "<li>DSSI plugin support</li>"
67         "<li>LV2 plugin support</li>"
68 #if defined(USING_JUCE) && JUCE_PLUGINHOST_VST
69         "<li>VST2 plugin support (using JUCE)</li>"
70 #else
71         "<li>VST2 plugin support (using VeSTige header by Javier Serrano Polo)</li>"
72 #endif
73 #if defined(USING_JUCE) && JUCE_PLUGINHOST_VST3
74         "<li>VST3 plugin support (using JUCE)</li>"
75 #endif
76 #if defined(USING_JUCE) && JUCE_PLUGINHOST_AU
77         "<li>AU plugin support (using JUCE)</li>"
78 #endif
79 
80         // Sample kit libraries
81 #if defined(HAVE_FLUIDSYNTH) && !defined(BUILD_BRIDGE_ALTERNATIVE_ARCH)
82         "<li>FluidSynth library v" FLUIDSYNTH_VERSION " for SF2/3 support</li>"
83 #endif
84         "<li>SFZero module for SFZ support</li>"
85 
86         // misc libs
87         "<li>base64 utilities based on code by Ren\u00E9 Nyffenegger</li>"
88         "<li>dr_mp3 for mp3 file support</li>"
89 #ifdef HAVE_LIBLO
90         "<li>liblo library for OSC support</li>"
91 #endif
92 #ifdef HAVE_SNDFILE
93         "<li>libsndfile library for base audio file support</li>"
94 #endif
95         "<li>rtmempool library by Nedko Arnaudov"
96         "<li>serd, sord, sratom and lilv libraries for LV2 discovery</li>"
97 #ifndef USING_JUCE
98         "<li>RtAudio v" RTAUDIO_VERSION " and RtMidi v" RTMIDI_VERSION " for native Audio and MIDI support</li>"
99 #endif
100         "<li>zita-resampler for audio file sample rate resampling</li>"
101 
102         // Internal plugins
103         "<li>MIDI Sequencer UI code by Perry Nguyen</li>"
104 
105         // External plugins
106 #ifdef HAVE_EXTERNAL_PLUGINS
107         "<li>Nekobi plugin code based on nekobee by Sean Bolton and others</li>"
108         "<li>VectorJuice and WobbleJuice plugin code by Andre Sklenar</li>"
109 # ifdef HAVE_ZYN_DEPS
110         "<li>ZynAddSubFX plugin code by Mark McCurry and Nasca Octavian Paul</li>"
111 # endif
112 #endif // HAVE_EXTERNAL_PLUGINS
113 
114         // end
115         "</ul>";
116     }
117 
118     return retText;
119 }
120 
carla_get_juce_version()121 const char* carla_get_juce_version()
122 {
123     carla_debug("carla_get_juce_version()");
124 
125     static CarlaString retVersion;
126 
127 #ifdef USING_JUCE
128     if (retVersion.isEmpty())
129     {
130         if (const char* const version = juce::SystemStats::getJUCEVersion().toRawUTF8())
131             retVersion = version+6;
132         else
133             retVersion = "Unknown";
134     }
135 #endif
136 
137     return retVersion;
138 }
139 
carla_get_supported_file_extensions()140 const char* const* carla_get_supported_file_extensions()
141 {
142     carla_debug("carla_get_supported_file_extensions()");
143 
144     // NOTE: please keep in sync with CarlaEngine::loadFile!!
145     static const char* const extensions[] = {
146         // Base types
147         "carxp", "carxs",
148 
149         // plugin files and resources
150 #ifdef HAVE_FLUIDSYNTH
151         "sf2", "sf3",
152 #endif
153 #ifdef HAVE_FLUIDSYNTH_INSTPATCH
154         "dls", "gig",
155 #endif
156 #ifdef HAVE_ZYN_DEPS
157         "xmz", "xiz",
158 #endif
159 #ifdef CARLA_OS_MAC
160         "vst",
161 #else
162         "dll",
163         "so",
164 #endif
165         "vst3",
166 
167         // Audio files
168 #ifdef HAVE_SNDFILE
169         "aif", "aifc", "aiff", "au", "bwf", "flac", "htk", "iff", "mat4", "mat5", "oga", "ogg", "opus",
170         "paf", "pvf", "pvf5", "sd2", "sf", "snd", "svx", "vcc", "w64", "wav", "xi",
171 #endif
172 #ifdef HAVE_FFMPEG
173         "3g2", "3gp", "aac", "ac3", "amr", "ape", "mp2", "mp3", "mpc", "wma",
174 # ifndef HAVE_SNDFILE
175         // FFmpeg without sndfile
176         "flac", "oga", "ogg", "w64", "wav",
177 # endif
178 #else
179         // dr_mp3
180         "mp3",
181 #endif
182 
183         // MIDI files
184         "mid", "midi",
185 
186         // SFZ
187         "sfz",
188 
189         // terminator
190         nullptr
191     };
192 
193     return extensions;
194 }
195 
carla_get_supported_features()196 const char* const* carla_get_supported_features()
197 {
198     carla_debug("carla_get_supported_features()");
199 
200     static const char* const features[] = {
201 #ifdef HAVE_FLUIDSYNTH
202         "sf2",
203 #endif
204 #ifdef HAVE_FLUIDSYNTH_INSTPATCH
205         "dls", "gig",
206 #endif
207 #ifdef HAVE_HYLIA
208         "link",
209 #endif
210 #ifdef HAVE_LIBLO
211         "osc",
212 #endif
213 #if defined(HAVE_LIBMAGIC) || defined(CARLA_OS_WIN)
214         "bridges",
215 #endif
216 #ifdef HAVE_PYQT
217         "gui",
218 #endif
219 #ifdef USING_JUCE
220         "juce",
221         "vst3",
222 # if defined(CARLA_OS_MAC)
223         "au",
224 # endif
225 #endif
226         nullptr
227     };
228 
229     return features;
230 }
231 
232 // -------------------------------------------------------------------------------------------------------------------
233 
carla_get_library_filename()234 const char* carla_get_library_filename()
235 {
236     carla_debug("carla_get_library_filename()");
237 
238     static CarlaString ret;
239 
240     if (ret.isEmpty())
241     {
242         using water::File;
243         ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8();
244     }
245 
246     return ret;
247 }
248 
carla_get_library_folder()249 const char* carla_get_library_folder()
250 {
251     carla_debug("carla_get_library_folder()");
252 
253     static CarlaString ret;
254 
255     if (ret.isEmpty())
256     {
257         using water::File;
258         ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8();
259     }
260 
261     return ret;
262 }
263 
264 // -------------------------------------------------------------------------------------------------------------------
265