2 # -*- coding: utf-8 -*-
4 # Script to start carla plugin bridges
5 # Copyright (C) 2015-2018 Filipe Coelho <falktx@falktx.com>
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of
10 # the License, or 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 # For a full copy of the GNU General Public License see the doc/GPL.txt file.
19 # --------------------------------------------------------------------------------------------------------
25 # --------------------------------------------------------------------------------------------------------
28 INSTALL_PREFIX = "X-PREFIX-X"
30 CARLA_LIBDIR = os.path.join(INSTALL_PREFIX, "lib", "carla")
31 CARLA_RESDIR = os.path.join(INSTALL_PREFIX, "share", "carla", "resources")
33 # --------------------------------------------------------------------------------------------------------
34 # Check for enough arguments
37 usage: %s [arch (optional)] [format] [filename/uri] [label (optional)] [uniqueId (optional)]
59 $ %s internal midisplit
60 $ %s dssi /usr/lib/dssi/whysynth.so
61 $ %s lv2 http://calf.sourceforge.net/plugins/Compressor
62 $ %s native vst /usr/lib/vst/TAL-NoiseMaker.so
63 $ %s win32 vst \"~/.wine/drive_c/Program Files (x86)/VstPlugins/Kontakt 5.dll\"
64 $ CARLA_BRIDGE_PLUGIN_BINARY_TYPE=win64 %s vst \"~/.wine/drive_c/Program Files/Common Files/VST2/Sytrus VSTi.dll\"
66 Format can be skipped for internal and lv2 plugins (auto-detected), like this:
68 $ %s http://synthv1.sourceforge.net/lv2""" % ((sys.argv[0],)*9)
70 def printUsageAndQuit():
77 # --------------------------------------------------------------------------------------------------------
78 # Initialize variables to null
80 ARCH = os.getenv("CARLA_BRIDGE_PLUGIN_BINARY_TYPE", "native")
81 TESTING = os.getenv("CARLA_BRIDGE_TESTING", None)
87 # --------------------------------------------------------------------------------------------------------
92 if sys.argv[arg] in ("native", "posix32", "posix64", "linux32", "linux64", "mac32", "mac64", "win32", "win64"):
93 ARCH = sys.argv[arg].replace("linux", "posix").replace("mac", "posix")
96 if len(sys.argv) == arg:
99 # --------------------------------------------------------------------------------------------------------
102 if sys.argv[arg] in ("internal", "ladspa", "dssi", "lv2", "vst", "vst2", "vst3", "au", "clap", "jsfx", "sf2", "sfz"):
103 FORMAT = sys.argv[arg]
109 elif len(sys.argv) == arg+1:
110 FORMAT = "lv2" if ":" in sys.argv[arg] else "internal"
113 print("Invalid format")
116 if len(sys.argv) == arg:
119 # --------------------------------------------------------------------------------------------------------
122 if FORMAT in ("internal", "lv2"):
123 LABEL = sys.argv[arg]
127 FILENAME = os.path.expanduser(sys.argv[arg])
130 # --------------------------------------------------------------------------------------------------------
131 # Set label (optional)
133 if len(sys.argv) > arg:
134 if FORMAT == "internal":
135 print("label/uri already set, ignoring 2nd label")
136 elif FORMAT == "lv2":
137 newpwd = sys.argv[arg]
138 if os.path.exists(newpwd):
139 print("using path hack for lv2 plugin")
142 LABEL = sys.argv[arg]
145 # --------------------------------------------------------------------------------------------------------
146 # Set uniqueId (optional)
148 if len(sys.argv) > arg:
149 if FORMAT in ("internal", "dssi", "lv2", "au", "sf2", "sfz"):
150 print("uniqueId is not used in this format, ignored")
153 UNIQUEID = int(sys.argv[arg])
155 print("uniqueId must be a number")
159 # --------------------------------------------------------------------------------------------------------
162 if len(sys.argv) > arg:
163 print("Got too many arguments, ignoring past uniqueId")
165 # --------------------------------------------------------------------------------------------------------
168 BRIDGE = os.path.join(CARLA_LIBDIR, "carla-bridge-" + ARCH)
170 if ARCH in ("win32", "win64") or TESTING in ("win32", "win64"):
171 BRIDGE = BRIDGE + ".exe"
173 # --------------------------------------------------------------------------------------------------------
174 # Check for existing carla folder
176 if not os.path.exists(CARLA_LIBDIR):
177 print("Carla library folder does not exist, is Carla installed?")
180 if not os.path.exists(CARLA_RESDIR):
181 print("Carla resource folder does not exist, is Carla installed?")
184 # --------------------------------------------------------------------------------------------------------
185 # Check for existing arch binary
187 if not os.path.exists(BRIDGE):
188 print("Carla plugin bridge (%s) for the requested arch (%s) does not exist" % (os.path.basename(BRIDGE), ARCH,))
191 # --------------------------------------------------------------------------------------------------------
194 if ARCH not in ("native", "posix32", "posix64", "win32", "win64"):
195 print("Invalid arch")
198 if FORMAT not in ("internal", "ladspa", "dssi", "lv2", "vst2", "vst3", "au", "clap", "jsfx", "sf2", "sfz"):
199 print("Invalid format")
202 if FILENAME and not os.path.exists(FILENAME):
203 print("Requested filename does not exist")
206 # --------------------------------------------------------------------------------------------------------
209 LADSPA_PATH = os.getenv("LADSPA_PATH")
210 DSSI_PATH = os.getenv("DSSI_PATH")
211 LV2_PATH = os.getenv("LV2_PATH")
212 VST2_PATH = os.getenv("VST_PATH")
213 VST3_PATH = os.getenv("VST3_PATH")
214 CLAP_PATH = os.getenv("CLAP_PATH")
215 SF2_PATH = os.getenv("SF2_PATH")
216 SFZ_PATH = os.getenv("SFZ_PATH")
218 if LADSPA_PATH is not None: os.environ["ENGINE_OPTION_PLUGIN_PATH_LADSPA"] = LADSPA_PATH
219 if DSSI_PATH is not None: os.environ["ENGINE_OPTION_PLUGIN_PATH_DSSI"] = DSSI_PATH
220 if LV2_PATH is not None: os.environ["ENGINE_OPTION_PLUGIN_PATH_LV2"] = LV2_PATH
221 if VST2_PATH is not None: os.environ["ENGINE_OPTION_PLUGIN_PATH_VST2"] = VST2_PATH
222 if VST3_PATH is not None: os.environ["ENGINE_OPTION_PLUGIN_PATH_VST3"] = VST3_PATH
223 if CLAP_PATH is not None: os.environ["ENGINE_OPTION_PLUGIN_PATH_CLAP"] = CLAP_PATH
224 if SF2_PATH is not None: os.environ["ENGINE_OPTION_PLUGIN_PATH_SF2"] = SF2_PATH
225 if SFZ_PATH is not None: os.environ["ENGINE_OPTION_PLUGIN_PATH_SFZ"] = SFZ_PATH
227 os.environ["ENGINE_OPTION_PATH_BINARIES"] = CARLA_LIBDIR
228 os.environ["ENGINE_OPTION_PATH_RESOURCES"] = CARLA_RESDIR
230 # --------------------------------------------------------------------------------------------------------
232 CARLA_CLIENT_NAME = os.getenv("CARLA_CLIENT_NAME")
233 LADISH_APP_NAME = os.getenv("LADISH_APP_NAME")
235 if CARLA_CLIENT_NAME is not None:
236 os.environ["CARLA_CLIENT_NAME"] = CARLA_CLIENT_NAME
237 elif LADISH_APP_NAME is not None:
238 os.environ["CARLA_CLIENT_NAME"] = LADISH_APP_NAME
240 os.environ["CARLA_CLIENT_NAME"] = "(none)"
242 # --------------------------------------------------------------------------------------------------------
247 if os.getenv("CARLA_BRIDGE_PLUGIN_BINARY_TYPE") is not None:
248 BRIDGE = os.path.join(CARLA_LIBDIR, "carla-bridge-native")
249 elif ARCH == "win32" or TESTING == "win32":
250 command.append("wine")
251 elif ARCH == "win64" or TESTING == "win64":
252 command.append("wine64")
254 command.append(BRIDGE)
255 command.append(FORMAT)
256 command.append(FILENAME or "(none)")
257 command.append(LABEL or "(none)")
258 command.append(str(UNIQUEID))
261 os.execvp(command[0], command)
263 # --------------------------------------------------------------------------------------------------------