Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

carla_database.py 73KB

11 years ago
9 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin database code
  4. # Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ----------------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. from copy import deepcopy
  20. from subprocess import Popen, PIPE
  21. from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QEventLoop, QThread, QSettings
  22. from PyQt5.QtWidgets import QApplication, QDialog, QDialogButtonBox, QTableWidgetItem
  23. # ----------------------------------------------------------------------------------------------------------------------
  24. # Imports (Custom)
  25. import ui_carla_add_jack
  26. import ui_carla_database
  27. import ui_carla_refresh
  28. from carla_shared import *
  29. # ----------------------------------------------------------------------------------------------------------------------
  30. # Try Import LADSPA-RDF
  31. if WINDOWS:
  32. haveLRDF = False
  33. elif not CXFREEZE:
  34. try:
  35. import ladspa_rdf
  36. import json
  37. haveLRDF = True
  38. except:
  39. qWarning("LRDF Support not available (LADSPA-RDF will be disabled)")
  40. haveLRDF = False
  41. else:
  42. qWarning("LRDF Support disabled for static build (LADSPA-RDF will be disabled)")
  43. haveLRDF = False
  44. # ----------------------------------------------------------------------------------------------------------------------
  45. # Set LADSPA-RDF Path
  46. if haveLRDF and readEnvVars:
  47. LADSPA_RDF_PATH_env = os.getenv("LADSPA_RDF_PATH")
  48. if LADSPA_RDF_PATH_env:
  49. try:
  50. ladspa_rdf.set_rdf_path(LADSPA_RDF_PATH_env.split(splitter))
  51. except:
  52. pass
  53. del LADSPA_RDF_PATH_env
  54. # ----------------------------------------------------------------------------------------------------------------------
  55. # Plugin Query (helper functions)
  56. def findBinaries(binPath, OS):
  57. binaries = []
  58. if OS == "WINDOWS":
  59. extensions = (".dll",)
  60. elif OS == "MACOS":
  61. extensions = (".dylib", ".so")
  62. else:
  63. extensions = (".so",)
  64. for root, dirs, files in os.walk(binPath):
  65. for name in [name for name in files if name.lower().endswith(extensions)]:
  66. binaries.append(os.path.join(root, name))
  67. return binaries
  68. def findVST3Binaries(binPath):
  69. binaries = []
  70. for root, dirs, files in os.walk(binPath):
  71. for name in [name for name in files if name.lower().endswith(".vst3")]:
  72. binaries.append(os.path.join(root, name))
  73. return binaries
  74. def findLV2Bundles(bundlePath):
  75. bundles = []
  76. for root, dirs, files in os.walk(bundlePath, followlinks=True):
  77. if root == bundlePath: continue
  78. if os.path.exists(os.path.join(root, "manifest.ttl")):
  79. bundles.append(root)
  80. return bundles
  81. def findMacVSTBundles(bundlePath, isVST3):
  82. bundles = []
  83. extension = ".vst3" if isVST3 else ".vst"
  84. for root, dirs, files in os.walk(bundlePath, followlinks=True):
  85. #if root == bundlePath: continue # FIXME
  86. for name in [name for name in dirs if name.lower().endswith(extension)]:
  87. bundles.append(os.path.join(root, name))
  88. return bundles
  89. def findFilenames(filePath, stype):
  90. filenames = []
  91. if stype == "sf2":
  92. extensions = (".sf2",".sf3",)
  93. else:
  94. return []
  95. for root, dirs, files in os.walk(filePath):
  96. for name in [name for name in files if name.lower().endswith(extensions)]:
  97. filenames.append(os.path.join(root, name))
  98. return filenames
  99. # ----------------------------------------------------------------------------------------------------------------------
  100. # Plugin Query
  101. PLUGIN_QUERY_API_VERSION = 8
  102. PyPluginInfo = {
  103. 'API': PLUGIN_QUERY_API_VERSION,
  104. 'valid': False,
  105. 'build': BINARY_NONE,
  106. 'type': PLUGIN_NONE,
  107. 'hints': 0x0,
  108. 'filename': "",
  109. 'name': "",
  110. 'label': "",
  111. 'maker': "",
  112. 'uniqueId': 0,
  113. 'audio.ins': 0,
  114. 'audio.outs': 0,
  115. 'midi.ins': 0,
  116. 'midi.outs': 0,
  117. 'parameters.ins': 0,
  118. 'parameters.outs': 0
  119. }
  120. global gDiscoveryProcess
  121. gDiscoveryProcess = None
  122. def findWinePrefix(filename, recursionLimit = 10):
  123. if recursionLimit == 0 or len(filename) < 5 or "/" not in filename:
  124. return ""
  125. path = filename[:filename.rfind("/")]
  126. if os.path.isdir(path + "/dosdevices"):
  127. return path
  128. return findWinePrefix(path, recursionLimit-1)
  129. def runCarlaDiscovery(itype, stype, filename, tool, wineSettings=None):
  130. if not os.path.exists(tool):
  131. qWarning("runCarlaDiscovery() - tool '%s' does not exist" % tool)
  132. return
  133. command = []
  134. if LINUX or MACOS:
  135. command.append("env")
  136. command.append("LANG=C")
  137. command.append("LD_PRELOAD=")
  138. if wineSettings is not None:
  139. command.append("WINEDEBUG=-all")
  140. if wineSettings['autoPrefix']:
  141. winePrefix = findWinePrefix(filename)
  142. else:
  143. winePrefix = ""
  144. if not winePrefix:
  145. envWinePrefix = os.getenv("WINEPREFIX")
  146. if envWinePrefix:
  147. winePrefix = envWinePrefix
  148. elif wineSettings['fallbackPrefix']:
  149. winePrefix = os.path.expanduser(wineSettings['fallbackPrefix'])
  150. else:
  151. winePrefix = os.path.expanduser("~/.wine")
  152. wineCMD = wineSettings['executable'] if wineSettings['executable'] else "wine"
  153. if tool.endswith("64.exe") and os.path.exists(wineCMD + "64"):
  154. wineCMD += "64"
  155. command.append("WINEPREFIX=" + winePrefix)
  156. command.append(wineCMD)
  157. command.append(tool)
  158. command.append(stype)
  159. command.append(filename)
  160. global gDiscoveryProcess
  161. gDiscoveryProcess = Popen(command, stdout=PIPE)
  162. pinfo = None
  163. plugins = []
  164. fakeLabel = os.path.basename(filename).rsplit(".", 1)[0]
  165. while True:
  166. try:
  167. line = gDiscoveryProcess.stdout.readline().decode("utf-8", errors="ignore")
  168. except:
  169. print("ERROR: discovery readline failed")
  170. break
  171. # line is valid, strip it
  172. if line:
  173. line = line.strip()
  174. # line is invalid, try poll() again
  175. elif gDiscoveryProcess.poll() is None:
  176. continue
  177. # line is invalid and poll() failed, stop here
  178. else:
  179. break
  180. if line == "carla-discovery::init::-----------":
  181. pinfo = deepcopy(PyPluginInfo)
  182. pinfo['type'] = itype
  183. pinfo['filename'] = filename if filename != ":all" else ""
  184. elif line == "carla-discovery::end::------------":
  185. if pinfo is not None:
  186. plugins.append(pinfo)
  187. del pinfo
  188. pinfo = None
  189. elif line == "Segmentation fault":
  190. print("carla-discovery::crash::%s crashed during discovery" % filename)
  191. elif line.startswith("err:module:import_dll Library"):
  192. print(line)
  193. elif line.startswith("carla-discovery::info::"):
  194. print("%s - %s" % (line, filename))
  195. elif line.startswith("carla-discovery::warning::"):
  196. print("%s - %s" % (line, filename))
  197. elif line.startswith("carla-discovery::error::"):
  198. print("%s - %s" % (line, filename))
  199. elif line.startswith("carla-discovery::"):
  200. if pinfo == None:
  201. continue
  202. try:
  203. prop, value = line.replace("carla-discovery::", "").split("::", 1)
  204. except:
  205. continue
  206. if prop == "build":
  207. if value.isdigit(): pinfo['build'] = int(value)
  208. elif prop == "name":
  209. pinfo['name'] = value if value else fakeLabel
  210. elif prop == "label":
  211. pinfo['label'] = value if value else fakeLabel
  212. elif prop == "maker":
  213. pinfo['maker'] = value
  214. elif prop == "uniqueId":
  215. if value.isdigit(): pinfo['uniqueId'] = int(value)
  216. elif prop == "hints":
  217. if value.isdigit(): pinfo['hints'] = int(value)
  218. elif prop == "audio.ins":
  219. if value.isdigit(): pinfo['audio.ins'] = int(value)
  220. elif prop == "audio.outs":
  221. if value.isdigit(): pinfo['audio.outs'] = int(value)
  222. elif prop == "midi.ins":
  223. if value.isdigit(): pinfo['midi.ins'] = int(value)
  224. elif prop == "midi.outs":
  225. if value.isdigit(): pinfo['midi.outs'] = int(value)
  226. elif prop == "parameters.ins":
  227. if value.isdigit(): pinfo['parameters.ins'] = int(value)
  228. elif prop == "parameters.outs":
  229. if value.isdigit(): pinfo['parameters.outs'] = int(value)
  230. elif prop == "uri":
  231. if value:
  232. pinfo['label'] = value
  233. else:
  234. # cannot use empty URIs
  235. del pinfo
  236. pinfo = None
  237. continue
  238. else:
  239. print("%s - %s (unknown property)" % (line, filename))
  240. # FIXME?
  241. tmp = gDiscoveryProcess
  242. gDiscoveryProcess = None
  243. del gDiscoveryProcess, tmp
  244. return plugins
  245. def killDiscovery():
  246. global gDiscoveryProcess
  247. if gDiscoveryProcess is not None:
  248. gDiscoveryProcess.kill()
  249. def checkPluginCached(desc, ptype):
  250. pinfo = deepcopy(PyPluginInfo)
  251. pinfo['build'] = BINARY_NATIVE
  252. pinfo['type'] = ptype
  253. pinfo['hints'] = desc['hints']
  254. pinfo['name'] = desc['name']
  255. pinfo['label'] = desc['label']
  256. pinfo['maker'] = desc['maker']
  257. pinfo['audio.ins'] = desc['audioIns']
  258. pinfo['audio.outs'] = desc['audioOuts']
  259. pinfo['midi.ins'] = desc['midiIns']
  260. pinfo['midi.outs'] = desc['midiOuts']
  261. pinfo['parameters.ins'] = desc['parameterIns']
  262. pinfo['parameters.outs'] = desc['parameterOuts']
  263. if ptype == PLUGIN_SFZ:
  264. pinfo['filename'] = pinfo['label']
  265. pinfo['label'] = pinfo['name']
  266. return pinfo
  267. def checkPluginLADSPA(filename, tool, wineSettings=None):
  268. return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, wineSettings)
  269. def checkPluginDSSI(filename, tool, wineSettings=None):
  270. return runCarlaDiscovery(PLUGIN_DSSI, "DSSI", filename, tool, wineSettings)
  271. def checkPluginLV2(filename, tool, wineSettings=None):
  272. return runCarlaDiscovery(PLUGIN_LV2, "LV2", filename, tool, wineSettings)
  273. def checkPluginVST2(filename, tool, wineSettings=None):
  274. return runCarlaDiscovery(PLUGIN_VST2, "VST2", filename, tool, wineSettings)
  275. def checkPluginVST3(filename, tool, wineSettings=None):
  276. return runCarlaDiscovery(PLUGIN_VST3, "VST3", filename, tool, wineSettings)
  277. def checkFileSF2(filename, tool):
  278. return runCarlaDiscovery(PLUGIN_SF2, "SF2", filename, tool)
  279. def checkFileSFZ(filename, tool):
  280. return runCarlaDiscovery(PLUGIN_SFZ, "SFZ", filename, tool)
  281. # ----------------------------------------------------------------------------------------------------------------------
  282. # Separate Thread for Plugin Search
  283. class SearchPluginsThread(QThread):
  284. pluginLook = pyqtSignal(int, str)
  285. def __init__(self, parent, pathBinaries):
  286. QThread.__init__(self, parent)
  287. self.fContinueChecking = False
  288. self.fPathBinaries = pathBinaries
  289. self.fCheckNative = False
  290. self.fCheckPosix32 = False
  291. self.fCheckPosix64 = False
  292. self.fCheckWin32 = False
  293. self.fCheckWin64 = False
  294. self.fCheckLADSPA = False
  295. self.fCheckDSSI = False
  296. self.fCheckLV2 = False
  297. self.fCheckVST2 = False
  298. self.fCheckVST3 = False
  299. self.fCheckAU = False
  300. self.fCheckSF2 = False
  301. self.fCheckSFZ = False
  302. if WINDOWS:
  303. toolNative = "carla-discovery-win64.exe" if kIs64bit else "carla-discovery-win32.exe"
  304. self.fWineSettings = None
  305. else:
  306. toolNative = "carla-discovery-native"
  307. settings = QSettings("falkTX", "Carla2")
  308. self.fWineSettings = {
  309. 'executable' : settings.value(CARLA_KEY_WINE_EXECUTABLE, CARLA_DEFAULT_WINE_EXECUTABLE, type=str),
  310. 'autoPrefix' : settings.value(CARLA_KEY_WINE_AUTO_PREFIX, CARLA_DEFAULT_WINE_AUTO_PREFIX, type=bool),
  311. 'fallbackPrefix': settings.value(CARLA_KEY_WINE_FALLBACK_PREFIX, CARLA_DEFAULT_WINE_FALLBACK_PREFIX, type=str)
  312. }
  313. del settings
  314. self.fToolNative = os.path.join(pathBinaries, toolNative)
  315. if not os.path.exists(self.fToolNative):
  316. self.fToolNative = ""
  317. self.fCurCount = 0
  318. self.fCurPercentValue = 0
  319. self.fLastCheckValue = 0
  320. self.fSomethingChanged = False
  321. # -------------------------------------------------------------
  322. def hasSomethingChanged(self):
  323. return self.fSomethingChanged
  324. def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64):
  325. self.fCheckNative = native
  326. self.fCheckPosix32 = posix32
  327. self.fCheckPosix64 = posix64
  328. self.fCheckWin32 = win32
  329. self.fCheckWin64 = win64
  330. def setSearchPluginTypes(self, ladspa, dssi, lv2, vst2, vst3, au, sf2, sfz):
  331. self.fCheckLADSPA = ladspa
  332. self.fCheckDSSI = dssi
  333. self.fCheckLV2 = lv2
  334. self.fCheckVST2 = vst2
  335. self.fCheckVST3 = vst3 and (MACOS or WINDOWS)
  336. self.fCheckAU = au and MACOS
  337. self.fCheckSF2 = sf2
  338. self.fCheckSFZ = sfz
  339. def stop(self):
  340. self.fContinueChecking = False
  341. def run(self):
  342. settingsDB = QSettings("falkTX", "CarlaPlugins4")
  343. self.fContinueChecking = True
  344. self.fCurCount = 0
  345. # looking for plugins via external discovery
  346. pluginCount = 0
  347. if self.fCheckLADSPA: pluginCount += 1
  348. if self.fCheckDSSI: pluginCount += 1
  349. if self.fCheckVST2: pluginCount += 1
  350. if self.fCheckVST3: pluginCount += 1
  351. # Increase count by the number of externally discoverable plugin types
  352. if self.fCheckNative:
  353. self.fCurCount += pluginCount
  354. # MacOS and Windows are the only VST3 supported OSes
  355. if self.fCheckVST3 and not (MACOS or WINDOWS):
  356. self.fCurCount -= 1
  357. if self.fCheckPosix32:
  358. self.fCurCount += pluginCount
  359. # MacOS is the only VST3 supported posix OS
  360. if self.fCheckVST3 and not MACOS:
  361. self.fCurCount -= 1
  362. if self.fCheckPosix64:
  363. self.fCurCount += pluginCount
  364. # MacOS is the only VST3 supported posix OS
  365. if self.fCheckVST3 and not MACOS:
  366. self.fCurCount -= 1
  367. if self.fCheckWin32:
  368. self.fCurCount += pluginCount
  369. if self.fCheckWin64:
  370. self.fCurCount += pluginCount
  371. # Special case for cached plugins, only "search" for native plugins (does not need tool)
  372. if self.fCheckLV2:
  373. if self.fCheckNative:
  374. self.fCurCount += 1
  375. else:
  376. self.fCheckLV2 = False
  377. if self.fCheckSFZ:
  378. if self.fCheckNative:
  379. self.fCurCount += 1
  380. else:
  381. self.fCheckSFZ = False
  382. # Special case for Sound Kits, only search native
  383. if self.fCheckNative and self.fToolNative:
  384. if self.fCheckSF2: self.fCurCount += 1
  385. else:
  386. self.fCheckSF2 = False
  387. if self.fCurCount == 0:
  388. return
  389. self.fCurPercentValue = 100.0 / self.fCurCount
  390. self.fLastCheckValue = 0.0
  391. del pluginCount
  392. if HAIKU:
  393. OS = "HAIKU"
  394. elif LINUX:
  395. OS = "LINUX"
  396. elif MACOS:
  397. OS = "MACOS"
  398. elif WINDOWS:
  399. OS = "WINDOWS"
  400. else:
  401. OS = "UNKNOWN"
  402. if not self.fContinueChecking: return
  403. self.fSomethingChanged = True
  404. if self.fCheckLADSPA:
  405. checkValue = 0.0
  406. if haveLRDF:
  407. if self.fCheckNative: checkValue += 0.1
  408. if self.fCheckPosix32: checkValue += 0.1
  409. if self.fCheckPosix64: checkValue += 0.1
  410. if self.fCheckWin32: checkValue += 0.1
  411. if self.fCheckWin64: checkValue += 0.1
  412. rdfPadValue = self.fCurPercentValue * checkValue
  413. if self.fCheckNative:
  414. plugins = self._checkLADSPA(OS, self.fToolNative)
  415. settingsDB.setValue("Plugins/LADSPA_native", plugins)
  416. if not self.fContinueChecking: return
  417. if self.fCheckPosix32:
  418. plugins = self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  419. settingsDB.setValue("Plugins/LADSPA_posix32", plugins)
  420. if not self.fContinueChecking: return
  421. if self.fCheckPosix64:
  422. plugins = self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  423. settingsDB.setValue("Plugins/LADSPA_posix64", plugins)
  424. if not self.fContinueChecking: return
  425. if self.fCheckWin32:
  426. plugins = self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  427. settingsDB.setValue("Plugins/LADSPA_win32", plugins)
  428. if not self.fContinueChecking: return
  429. if self.fCheckWin64:
  430. plugins = self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  431. settingsDB.setValue("Plugins/LADSPA_win64", plugins)
  432. settingsDB.sync()
  433. if not self.fContinueChecking: return
  434. if haveLRDF and checkValue > 0:
  435. startValue = self.fLastCheckValue - rdfPadValue
  436. self._pluginLook(startValue, "LADSPA RDFs...")
  437. try:
  438. ladspaRdfInfo = ladspa_rdf.recheck_all_plugins(self, startValue, self.fCurPercentValue, checkValue)
  439. except:
  440. ladspaRdfInfo = None
  441. if ladspaRdfInfo is not None:
  442. settingsDir = os.path.join(HOME, ".config", "falkTX")
  443. fdLadspa = open(os.path.join(settingsDir, "ladspa_rdf.db"), 'w')
  444. json.dump(ladspaRdfInfo, fdLadspa)
  445. fdLadspa.close()
  446. if not self.fContinueChecking: return
  447. if self.fCheckDSSI:
  448. if self.fCheckNative:
  449. plugins = self._checkDSSI(OS, self.fToolNative)
  450. settingsDB.setValue("Plugins/DSSI_native", plugins)
  451. if not self.fContinueChecking: return
  452. if self.fCheckPosix32:
  453. plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  454. settingsDB.setValue("Plugins/DSSI_posix32", plugins)
  455. if not self.fContinueChecking: return
  456. if self.fCheckPosix64:
  457. plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  458. settingsDB.setValue("Plugins/DSSI_posix64", plugins)
  459. if not self.fContinueChecking: return
  460. if self.fCheckWin32:
  461. plugins = self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  462. settingsDB.setValue("Plugins/DSSI_win32", plugins)
  463. if not self.fContinueChecking: return
  464. if self.fCheckWin64:
  465. plugins = self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  466. settingsDB.setValue("Plugins/DSSI_win64", plugins)
  467. settingsDB.sync()
  468. if not self.fContinueChecking: return
  469. if self.fCheckLV2:
  470. plugins = self._checkLv2Cached()
  471. settingsDB.setValue("Plugins/LV2", plugins)
  472. settingsDB.sync()
  473. if not self.fContinueChecking: return
  474. if self.fCheckVST2:
  475. if self.fCheckNative:
  476. plugins = self._checkVST2(OS, self.fToolNative)
  477. settingsDB.setValue("Plugins/VST2_native", plugins)
  478. if not self.fContinueChecking: return
  479. if self.fCheckPosix32:
  480. plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  481. settingsDB.setValue("Plugins/VST2_posix32", plugins)
  482. if not self.fContinueChecking: return
  483. if self.fCheckPosix64:
  484. plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  485. settingsDB.setValue("Plugins/VST2_posix64", plugins)
  486. if not self.fContinueChecking: return
  487. if self.fCheckWin32:
  488. plugins = self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  489. settingsDB.setValue("Plugins/VST2_win32", plugins)
  490. if not self.fContinueChecking: return
  491. if self.fCheckWin64:
  492. plugins = self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  493. settingsDB.setValue("Plugins/VST2_win64", plugins)
  494. if not self.fContinueChecking: return
  495. settingsDB.sync()
  496. if not self.fContinueChecking: return
  497. if self.fCheckSF2:
  498. settings = QSettings("falkTX", "Carla2")
  499. SF2_PATH = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH))
  500. del settings
  501. kits = self._checkKIT(SF2_PATH, "sf2")
  502. settingsDB.setValue("Plugins/SF2", kits)
  503. settingsDB.sync()
  504. if not self.fContinueChecking: return
  505. if self.fCheckSFZ:
  506. kits = self._checkSfzCached()
  507. settingsDB.setValue("Plugins/SFZ", kits)
  508. settingsDB.sync()
  509. def _checkLADSPA(self, OS, tool, isWine=False):
  510. ladspaBinaries = []
  511. ladspaPlugins = []
  512. self._pluginLook(self.fLastCheckValue, "LADSPA plugins...")
  513. settings = QSettings("falkTX", "Carla2")
  514. LADSPA_PATH = toList(settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH))
  515. del settings
  516. for iPATH in LADSPA_PATH:
  517. binaries = findBinaries(iPATH, OS)
  518. for binary in binaries:
  519. if binary not in ladspaBinaries:
  520. ladspaBinaries.append(binary)
  521. ladspaBinaries.sort()
  522. if not self.fContinueChecking:
  523. return ladspaPlugins
  524. for i in range(len(ladspaBinaries)):
  525. ladspa = ladspaBinaries[i]
  526. percent = ( float(i) / len(ladspaBinaries) ) * self.fCurPercentValue
  527. self._pluginLook((self.fLastCheckValue + percent) * 0.9, ladspa)
  528. plugins = checkPluginLADSPA(ladspa, tool, self.fWineSettings if isWine else None)
  529. if plugins:
  530. ladspaPlugins.append(plugins)
  531. if not self.fContinueChecking:
  532. break
  533. self.fLastCheckValue += self.fCurPercentValue
  534. return ladspaPlugins
  535. def _checkDSSI(self, OS, tool, isWine=False):
  536. dssiBinaries = []
  537. dssiPlugins = []
  538. self._pluginLook(self.fLastCheckValue, "DSSI plugins...")
  539. settings = QSettings("falkTX", "Carla2")
  540. DSSI_PATH = toList(settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH))
  541. del settings
  542. for iPATH in DSSI_PATH:
  543. binaries = findBinaries(iPATH, OS)
  544. for binary in binaries:
  545. if binary not in dssiBinaries:
  546. dssiBinaries.append(binary)
  547. dssiBinaries.sort()
  548. if not self.fContinueChecking:
  549. return dssiPlugins
  550. for i in range(len(dssiBinaries)):
  551. dssi = dssiBinaries[i]
  552. percent = ( float(i) / len(dssiBinaries) ) * self.fCurPercentValue
  553. self._pluginLook(self.fLastCheckValue + percent, dssi)
  554. plugins = checkPluginDSSI(dssi, tool, self.fWineSettings if isWine else None)
  555. if plugins:
  556. dssiPlugins.append(plugins)
  557. if not self.fContinueChecking:
  558. break
  559. self.fLastCheckValue += self.fCurPercentValue
  560. return dssiPlugins
  561. def _checkVST2(self, OS, tool, isWine=False):
  562. vst2Binaries = []
  563. vstPlugins = []
  564. if MACOS and not isWine:
  565. self._pluginLook(self.fLastCheckValue, "VST2 bundles...")
  566. else:
  567. self._pluginLook(self.fLastCheckValue, "VST2 plugins...")
  568. settings = QSettings("falkTX", "Carla2")
  569. VST2_PATH = toList(settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH))
  570. del settings
  571. for iPATH in VST2_PATH:
  572. if MACOS and not isWine:
  573. binaries = findMacVSTBundles(iPATH, False)
  574. else:
  575. binaries = findBinaries(iPATH, OS)
  576. for binary in binaries:
  577. if binary not in vst2Binaries:
  578. vst2Binaries.append(binary)
  579. vst2Binaries.sort()
  580. if not self.fContinueChecking:
  581. return vstPlugins
  582. for i in range(len(vst2Binaries)):
  583. vst2 = vst2Binaries[i]
  584. percent = ( float(i) / len(vst2Binaries) ) * self.fCurPercentValue
  585. self._pluginLook(self.fLastCheckValue + percent, vst2)
  586. plugins = checkPluginVST2(vst2, tool, self.fWineSettings if isWine else None)
  587. if plugins:
  588. vstPlugins.append(plugins)
  589. if not self.fContinueChecking:
  590. break
  591. self.fLastCheckValue += self.fCurPercentValue
  592. return vstPlugins
  593. def _checkKIT(self, kitPATH, kitExtension):
  594. kitFiles = []
  595. kitPlugins = []
  596. for iPATH in kitPATH:
  597. files = findFilenames(iPATH, kitExtension)
  598. for file_ in files:
  599. if file_ not in kitFiles:
  600. kitFiles.append(file_)
  601. kitFiles.sort()
  602. if not self.fContinueChecking:
  603. return kitPlugins
  604. for i in range(len(kitFiles)):
  605. kit = kitFiles[i]
  606. percent = ( float(i) / len(kitFiles) ) * self.fCurPercentValue
  607. self._pluginLook(self.fLastCheckValue + percent, kit)
  608. if kitExtension == "sf2":
  609. plugins = checkFileSF2(kit, self.fToolNative)
  610. else:
  611. plugins = None
  612. if plugins:
  613. kitPlugins.append(plugins)
  614. if not self.fContinueChecking:
  615. break
  616. self.fLastCheckValue += self.fCurPercentValue
  617. return kitPlugins
  618. def _checkLv2Cached(self):
  619. settings = QSettings("falkTX", "Carla2")
  620. PLUG_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH)))
  621. del settings
  622. lv2Plugins = []
  623. self._pluginLook(self.fLastCheckValue, "LV2 plugins...")
  624. count = gCarla.utils.get_cached_plugin_count(PLUGIN_LV2, PLUG_PATH)
  625. if not self.fContinueChecking:
  626. return lv2Plugins
  627. for i in range(count):
  628. descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_LV2, i)
  629. percent = ( float(i) / count ) * self.fCurPercentValue
  630. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  631. if not descInfo['valid']:
  632. continue
  633. lv2Plugins.append(checkPluginCached(descInfo, PLUGIN_LV2))
  634. if not self.fContinueChecking:
  635. break
  636. self.fLastCheckValue += self.fCurPercentValue
  637. return lv2Plugins
  638. def _checkSfzCached(self):
  639. settings = QSettings("falkTX", "Carla2")
  640. PLUG_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH)))
  641. del settings
  642. sfzKits = []
  643. self._pluginLook(self.fLastCheckValue, "SFZ kits...")
  644. count = gCarla.utils.get_cached_plugin_count(PLUGIN_SFZ, PLUG_PATH)
  645. if not self.fContinueChecking:
  646. return sfzKits
  647. for i in range(count):
  648. descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_SFZ, i)
  649. percent = ( float(i) / count ) * self.fCurPercentValue
  650. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  651. if not descInfo['valid']:
  652. continue
  653. sfzKits.append(checkPluginCached(descInfo, PLUGIN_SFZ))
  654. if not self.fContinueChecking:
  655. break
  656. self.fLastCheckValue += self.fCurPercentValue
  657. return sfzKits
  658. def _pluginLook(self, percent, plugin):
  659. self.pluginLook.emit(percent, plugin)
  660. # ---------------------------------------------------------------------------------------------------------------------
  661. # Plugin Refresh Dialog
  662. class PluginRefreshW(QDialog):
  663. def __init__(self, parent, host):
  664. QDialog.__init__(self, parent)
  665. self.host = host
  666. self.ui = ui_carla_refresh.Ui_PluginRefreshW()
  667. self.ui.setupUi(self)
  668. if False:
  669. # kdevelop likes this :)
  670. self.host = host = CarlaHostNull()
  671. # -------------------------------------------------------------------------------------------------------------
  672. # Internal stuff
  673. hasNative = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-native"))
  674. hasPosix32 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-posix32"))
  675. hasPosix64 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-posix64"))
  676. hasWin32 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-win32.exe"))
  677. hasWin64 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-win64.exe"))
  678. self.fThread = SearchPluginsThread(self, host.pathBinaries)
  679. self.fIconYes = getIcon("dialog-ok-apply").pixmap(16, 16)
  680. self.fIconNo = getIcon("dialog-error").pixmap(16, 16)
  681. # -------------------------------------------------------------------------------------------------------------
  682. # Set-up GUI
  683. self.ui.b_skip.setVisible(False)
  684. if HAIKU:
  685. self.ui.ch_posix32.setText("Haiku 32bit")
  686. self.ui.ch_posix64.setText("Haiku 64bit")
  687. elif LINUX:
  688. self.ui.ch_posix32.setText("Linux 32bit")
  689. self.ui.ch_posix64.setText("Linux 64bit")
  690. elif MACOS:
  691. self.ui.ch_posix32.setText("MacOS 32bit")
  692. self.ui.ch_posix64.setText("MacOS 64bit")
  693. if hasPosix32 and not WINDOWS:
  694. self.ui.ico_posix32.setPixmap(self.fIconYes)
  695. else:
  696. self.ui.ico_posix32.setPixmap(self.fIconNo)
  697. self.ui.ch_posix32.setEnabled(False)
  698. if hasPosix64 and not WINDOWS:
  699. self.ui.ico_posix64.setPixmap(self.fIconYes)
  700. else:
  701. self.ui.ico_posix64.setPixmap(self.fIconNo)
  702. self.ui.ch_posix64.setEnabled(False)
  703. if hasWin32:
  704. self.ui.ico_win32.setPixmap(self.fIconYes)
  705. else:
  706. self.ui.ico_win32.setPixmap(self.fIconNo)
  707. self.ui.ch_win32.setEnabled(False)
  708. if hasWin64:
  709. self.ui.ico_win64.setPixmap(self.fIconYes)
  710. else:
  711. self.ui.ico_win64.setPixmap(self.fIconNo)
  712. self.ui.ch_win64.setEnabled(False)
  713. if haveLRDF:
  714. self.ui.ico_rdflib.setPixmap(self.fIconYes)
  715. else:
  716. self.ui.ico_rdflib.setPixmap(self.fIconNo)
  717. if WINDOWS:
  718. if kIs64bit:
  719. hasNative = hasWin64
  720. hasNonNative = hasWin32
  721. self.ui.ch_win64.setEnabled(False)
  722. self.ui.ch_win64.setVisible(False)
  723. self.ui.ico_win64.setVisible(False)
  724. self.ui.label_win64.setVisible(False)
  725. else:
  726. hasNative = hasWin32
  727. hasNonNative = hasWin64
  728. self.ui.ch_win32.setEnabled(False)
  729. self.ui.ch_win32.setVisible(False)
  730. self.ui.ico_win32.setVisible(False)
  731. self.ui.label_win32.setVisible(False)
  732. self.ui.ch_posix32.setEnabled(False)
  733. self.ui.ch_posix32.setVisible(False)
  734. self.ui.ch_posix64.setEnabled(False)
  735. self.ui.ch_posix64.setVisible(False)
  736. self.ui.ico_posix32.hide()
  737. self.ui.ico_posix64.hide()
  738. self.ui.label_posix32.hide()
  739. self.ui.label_posix64.hide()
  740. self.ui.ico_rdflib.hide()
  741. self.ui.label_rdflib.hide()
  742. else:
  743. if kIs64bit:
  744. hasNonNative = bool(hasPosix32 or hasWin32 or hasWin64)
  745. self.ui.ch_posix64.setEnabled(False)
  746. self.ui.ch_posix64.setVisible(False)
  747. self.ui.ico_posix64.setVisible(False)
  748. self.ui.label_posix64.setVisible(False)
  749. else:
  750. hasNonNative = bool(hasPosix64 or hasWin32 or hasWin64)
  751. self.ui.ch_posix32.setEnabled(False)
  752. self.ui.ch_posix32.setVisible(False)
  753. self.ui.ico_posix32.setVisible(False)
  754. self.ui.label_posix32.setVisible(False)
  755. if hasNative:
  756. self.ui.ico_native.setPixmap(self.fIconYes)
  757. else:
  758. self.ui.ico_native.setPixmap(self.fIconNo)
  759. self.ui.ch_native.setEnabled(False)
  760. self.ui.ch_sf2.setEnabled(False)
  761. self.ui.ch_sfz.setEnabled(False)
  762. if not hasNonNative:
  763. self.ui.ch_ladspa.setEnabled(False)
  764. self.ui.ch_dssi.setEnabled(False)
  765. self.ui.ch_vst.setEnabled(False)
  766. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  767. # -------------------------------------------------------------------------------------------------------------
  768. # Load settings
  769. self.loadSettings()
  770. # -------------------------------------------------------------------------------------------------------------
  771. # Hide bridges if disabled
  772. # NOTE: We Assume win32 carla build will not run win64 plugins
  773. if (WINDOWS and not kIs64bit) or not host.showPluginBridges:
  774. self.ui.ch_native.setChecked(True)
  775. self.ui.ch_native.setEnabled(False)
  776. self.ui.ch_native.setVisible(False)
  777. self.ui.ch_posix32.setChecked(False)
  778. self.ui.ch_posix32.setEnabled(False)
  779. self.ui.ch_posix32.setVisible(False)
  780. self.ui.ch_posix64.setChecked(False)
  781. self.ui.ch_posix64.setEnabled(False)
  782. self.ui.ch_posix64.setVisible(False)
  783. self.ui.ch_win32.setChecked(False)
  784. self.ui.ch_win32.setEnabled(False)
  785. self.ui.ch_win32.setVisible(False)
  786. self.ui.ch_win64.setChecked(False)
  787. self.ui.ch_win64.setEnabled(False)
  788. self.ui.ch_win64.setVisible(False)
  789. self.ui.ico_posix32.hide()
  790. self.ui.ico_posix64.hide()
  791. self.ui.ico_win32.hide()
  792. self.ui.ico_win64.hide()
  793. self.ui.label_posix32.hide()
  794. self.ui.label_posix64.hide()
  795. self.ui.label_win32.hide()
  796. self.ui.label_win64.hide()
  797. self.ui.sep_format.hide()
  798. elif not (WINDOWS or host.showWineBridges):
  799. self.ui.ch_win32.setChecked(False)
  800. self.ui.ch_win32.setEnabled(False)
  801. self.ui.ch_win32.setVisible(False)
  802. self.ui.ch_win64.setChecked(False)
  803. self.ui.ch_win64.setEnabled(False)
  804. self.ui.ch_win64.setVisible(False)
  805. self.ui.ico_win32.hide()
  806. self.ui.ico_win64.hide()
  807. self.ui.label_win32.hide()
  808. self.ui.label_win64.hide()
  809. # Disable non-supported features
  810. features = gCarla.utils.get_supported_features()
  811. if "sf2" not in features:
  812. self.ui.ch_sf2.setChecked(False)
  813. self.ui.ch_sf2.setEnabled(False)
  814. # -------------------------------------------------------------------------------------------------------------
  815. # Resize to minimum size, as it's very likely UI stuff was hidden
  816. self.resize(self.minimumSize())
  817. # -------------------------------------------------------------------------------------------------------------
  818. # Set-up connections
  819. self.finished.connect(self.slot_saveSettings)
  820. self.ui.b_start.clicked.connect(self.slot_start)
  821. self.ui.b_skip.clicked.connect(self.slot_skip)
  822. self.ui.ch_native.clicked.connect(self.slot_checkTools)
  823. self.ui.ch_posix32.clicked.connect(self.slot_checkTools)
  824. self.ui.ch_posix64.clicked.connect(self.slot_checkTools)
  825. self.ui.ch_win32.clicked.connect(self.slot_checkTools)
  826. self.ui.ch_win64.clicked.connect(self.slot_checkTools)
  827. self.ui.ch_ladspa.clicked.connect(self.slot_checkTools)
  828. self.ui.ch_dssi.clicked.connect(self.slot_checkTools)
  829. self.ui.ch_lv2.clicked.connect(self.slot_checkTools)
  830. self.ui.ch_vst.clicked.connect(self.slot_checkTools)
  831. self.ui.ch_sf2.clicked.connect(self.slot_checkTools)
  832. self.ui.ch_sfz.clicked.connect(self.slot_checkTools)
  833. self.fThread.pluginLook.connect(self.slot_handlePluginLook)
  834. self.fThread.finished.connect(self.slot_handlePluginThreadFinished)
  835. # -------------------------------------------------------------------------------------------------------------
  836. # Post-connect setup
  837. self.slot_checkTools()
  838. # -----------------------------------------------------------------------------------------------------------------
  839. def loadSettings(self):
  840. settings = QSettings("falkTX", "CarlaRefresh2")
  841. check = settings.value("PluginDatabase/SearchLADSPA", True, type=bool) and self.ui.ch_ladspa.isEnabled()
  842. self.ui.ch_ladspa.setChecked(check)
  843. check = settings.value("PluginDatabase/SearchDSSI", True, type=bool) and self.ui.ch_dssi.isEnabled()
  844. self.ui.ch_dssi.setChecked(check)
  845. check = settings.value("PluginDatabase/SearchLV2", True, type=bool) and self.ui.ch_lv2.isEnabled()
  846. self.ui.ch_lv2.setChecked(check)
  847. check = settings.value("PluginDatabase/SearchVST2", True, type=bool) and self.ui.ch_vst.isEnabled()
  848. self.ui.ch_vst.setChecked(check)
  849. check = settings.value("PluginDatabase/SearchSF2", False, type=bool) and self.ui.ch_sf2.isEnabled()
  850. self.ui.ch_sf2.setChecked(check)
  851. check = settings.value("PluginDatabase/SearchSFZ", False, type=bool) and self.ui.ch_sfz.isEnabled()
  852. self.ui.ch_sfz.setChecked(check)
  853. check = settings.value("PluginDatabase/SearchNative", True, type=bool) and self.ui.ch_native.isEnabled()
  854. self.ui.ch_native.setChecked(check)
  855. check = settings.value("PluginDatabase/SearchPOSIX32", False, type=bool) and self.ui.ch_posix32.isEnabled()
  856. self.ui.ch_posix32.setChecked(check)
  857. check = settings.value("PluginDatabase/SearchPOSIX64", False, type=bool) and self.ui.ch_posix64.isEnabled()
  858. self.ui.ch_posix64.setChecked(check)
  859. check = settings.value("PluginDatabase/SearchWin32", False, type=bool) and self.ui.ch_win32.isEnabled()
  860. self.ui.ch_win32.setChecked(check)
  861. check = settings.value("PluginDatabase/SearchWin64", False, type=bool) and self.ui.ch_win64.isEnabled()
  862. self.ui.ch_win64.setChecked(check)
  863. self.ui.ch_do_checks.setChecked(settings.value("PluginDatabase/DoChecks", False, type=bool))
  864. # ------------------------------------------------------------------------------------------------------------------
  865. @pyqtSlot()
  866. def slot_saveSettings(self):
  867. settings = QSettings("falkTX", "CarlaRefresh2")
  868. settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked())
  869. settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked())
  870. settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked())
  871. settings.setValue("PluginDatabase/SearchVST2", self.ui.ch_vst.isChecked())
  872. settings.setValue("PluginDatabase/SearchSF2", self.ui.ch_sf2.isChecked())
  873. settings.setValue("PluginDatabase/SearchSFZ", self.ui.ch_sfz.isChecked())
  874. settings.setValue("PluginDatabase/SearchNative", self.ui.ch_native.isChecked())
  875. settings.setValue("PluginDatabase/SearchPOSIX32", self.ui.ch_posix32.isChecked())
  876. settings.setValue("PluginDatabase/SearchPOSIX64", self.ui.ch_posix64.isChecked())
  877. settings.setValue("PluginDatabase/SearchWin32", self.ui.ch_win32.isChecked())
  878. settings.setValue("PluginDatabase/SearchWin64", self.ui.ch_win64.isChecked())
  879. settings.setValue("PluginDatabase/DoChecks", self.ui.ch_do_checks.isChecked())
  880. # ------------------------------------------------------------------------------------------------------------------
  881. @pyqtSlot()
  882. def slot_start(self):
  883. self.ui.progressBar.setMinimum(0)
  884. self.ui.progressBar.setMaximum(100)
  885. self.ui.progressBar.setValue(0)
  886. self.ui.b_start.setEnabled(False)
  887. self.ui.b_skip.setVisible(True)
  888. self.ui.b_close.setVisible(False)
  889. self.ui.group_types.setEnabled(False)
  890. self.ui.group_options.setEnabled(False)
  891. if self.ui.ch_do_checks.isChecked():
  892. gCarla.utils.unsetenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS")
  893. else:
  894. gCarla.utils.setenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS", "true")
  895. native, posix32, posix64, win32, win64 = (self.ui.ch_native.isChecked(),
  896. self.ui.ch_posix32.isChecked(), self.ui.ch_posix64.isChecked(),
  897. self.ui.ch_win32.isChecked(), self.ui.ch_win64.isChecked())
  898. ladspa, dssi, lv2, vst, sf2, sfz = (self.ui.ch_ladspa.isChecked(), self.ui.ch_dssi.isChecked(),
  899. self.ui.ch_lv2.isChecked(), self.ui.ch_vst.isChecked(),
  900. self.ui.ch_sf2.isChecked(), self.ui.ch_sfz.isChecked())
  901. # TODO
  902. vst3 = False
  903. au = False
  904. self.fThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64)
  905. self.fThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, vst3, au, sf2, sfz)
  906. self.fThread.start()
  907. # ------------------------------------------------------------------------------------------------------------------
  908. @pyqtSlot()
  909. def slot_skip(self):
  910. killDiscovery()
  911. # ------------------------------------------------------------------------------------------------------------------
  912. @pyqtSlot()
  913. def slot_checkTools(self):
  914. enabled1 = bool(self.ui.ch_native.isChecked() or
  915. self.ui.ch_posix32.isChecked() or self.ui.ch_posix64.isChecked() or
  916. self.ui.ch_win32.isChecked() or self.ui.ch_win64.isChecked())
  917. enabled2 = bool(self.ui.ch_ladspa.isChecked() or self.ui.ch_dssi.isChecked() or
  918. self.ui.ch_lv2.isChecked() or self.ui.ch_vst.isChecked() or
  919. self.ui.ch_sf2.isChecked() or self.ui.ch_sfz.isChecked())
  920. self.ui.b_start.setEnabled(enabled1 and enabled2)
  921. # ------------------------------------------------------------------------------------------------------------------
  922. @pyqtSlot(int, str)
  923. def slot_handlePluginLook(self, percent, plugin):
  924. self.ui.progressBar.setFormat("%s" % plugin)
  925. self.ui.progressBar.setValue(percent)
  926. # ------------------------------------------------------------------------------------------------------------------
  927. @pyqtSlot()
  928. def slot_handlePluginThreadFinished(self):
  929. self.ui.progressBar.setMinimum(0)
  930. self.ui.progressBar.setMaximum(1)
  931. self.ui.progressBar.setValue(1)
  932. self.ui.progressBar.setFormat(self.tr("Done"))
  933. self.ui.b_start.setEnabled(True)
  934. self.ui.b_skip.setVisible(False)
  935. self.ui.b_close.setVisible(True)
  936. self.ui.group_types.setEnabled(True)
  937. self.ui.group_options.setEnabled(True)
  938. # ------------------------------------------------------------------------------------------------------------------
  939. def closeEvent(self, event):
  940. if self.fThread.isRunning():
  941. self.fThread.stop()
  942. killDiscovery()
  943. #self.fThread.terminate()
  944. self.fThread.wait()
  945. if self.fThread.hasSomethingChanged():
  946. self.accept()
  947. else:
  948. self.reject()
  949. QDialog.closeEvent(self, event)
  950. # ------------------------------------------------------------------------------------------------------------------
  951. def done(self, r):
  952. QDialog.done(self, r)
  953. self.close()
  954. # ----------------------------------------------------------------------------------------------------------------------
  955. # Plugin Database Dialog
  956. class PluginDatabaseW(QDialog):
  957. def __init__(self, parent, host):
  958. QDialog.__init__(self, parent)
  959. self.host = host
  960. self.ui = ui_carla_database.Ui_PluginDatabaseW()
  961. self.ui.setupUi(self)
  962. if False:
  963. # kdevelop likes this :)
  964. host = CarlaHostNull()
  965. self.host = host
  966. # ----------------------------------------------------------------------------------------------------
  967. # Internal stuff
  968. self.fLastTableIndex = 0
  969. self.fRetPlugin = None
  970. self.fRealParent = parent
  971. # ----------------------------------------------------------------------------------------------------
  972. # Set-up GUI
  973. self.ui.b_add.setEnabled(False)
  974. if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32):
  975. self.ui.ch_bridged.setText(self.tr("Bridged (64bit)"))
  976. else:
  977. self.ui.ch_bridged.setText(self.tr("Bridged (32bit)"))
  978. if not (LINUX or MACOS):
  979. self.ui.ch_bridged_wine.setChecked(False)
  980. self.ui.ch_bridged_wine.setEnabled(False)
  981. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  982. # ----------------------------------------------------------------------------------------------------
  983. # Load settings
  984. self.loadSettings()
  985. # ----------------------------------------------------------------------------------------------------
  986. # Disable bridges if not enabled in settings
  987. # NOTE: We Assume win32 carla build will not run win64 plugins
  988. if (WINDOWS and not kIs64bit) or not host.showPluginBridges:
  989. self.ui.ch_native.setChecked(True)
  990. self.ui.ch_native.setEnabled(False)
  991. self.ui.ch_native.setVisible(False)
  992. self.ui.ch_bridged.setChecked(False)
  993. self.ui.ch_bridged.setEnabled(False)
  994. self.ui.ch_bridged.setVisible(False)
  995. self.ui.ch_bridged_wine.setChecked(False)
  996. self.ui.ch_bridged_wine.setEnabled(False)
  997. self.ui.ch_bridged_wine.setVisible(False)
  998. self.ui.l_arch.setVisible(False)
  999. elif not host.showWineBridges:
  1000. self.ui.ch_bridged_wine.setChecked(False)
  1001. self.ui.ch_bridged_wine.setEnabled(False)
  1002. self.ui.ch_bridged_wine.setVisible(False)
  1003. # ----------------------------------------------------------------------------------------------------
  1004. # Set-up connections
  1005. self.finished.connect(self.slot_saveSettings)
  1006. self.ui.b_add.clicked.connect(self.slot_addPlugin)
  1007. self.ui.b_cancel.clicked.connect(self.reject)
  1008. self.ui.b_refresh.clicked.connect(self.slot_refreshPlugins)
  1009. self.ui.tb_filters.clicked.connect(self.slot_maybeShowFilters)
  1010. self.ui.lineEdit.textChanged.connect(self.slot_checkFilters)
  1011. self.ui.tableWidget.currentCellChanged.connect(self.slot_checkPlugin)
  1012. self.ui.tableWidget.cellDoubleClicked.connect(self.slot_addPlugin)
  1013. self.ui.ch_effects.clicked.connect(self.slot_checkFilters)
  1014. self.ui.ch_instruments.clicked.connect(self.slot_checkFilters)
  1015. self.ui.ch_midi.clicked.connect(self.slot_checkFilters)
  1016. self.ui.ch_other.clicked.connect(self.slot_checkFilters)
  1017. self.ui.ch_internal.clicked.connect(self.slot_checkFilters)
  1018. self.ui.ch_ladspa.clicked.connect(self.slot_checkFilters)
  1019. self.ui.ch_dssi.clicked.connect(self.slot_checkFilters)
  1020. self.ui.ch_lv2.clicked.connect(self.slot_checkFilters)
  1021. self.ui.ch_vst.clicked.connect(self.slot_checkFilters)
  1022. self.ui.ch_kits.clicked.connect(self.slot_checkFilters)
  1023. self.ui.ch_native.clicked.connect(self.slot_checkFilters)
  1024. self.ui.ch_bridged.clicked.connect(self.slot_checkFilters)
  1025. self.ui.ch_bridged_wine.clicked.connect(self.slot_checkFilters)
  1026. self.ui.ch_rtsafe.clicked.connect(self.slot_checkFilters)
  1027. self.ui.ch_gui.clicked.connect(self.slot_checkFilters)
  1028. self.ui.ch_stereo.clicked.connect(self.slot_checkFilters)
  1029. # ----------------------------------------------------------------------------------------------------
  1030. # Post-connect setup
  1031. self._reAddPlugins()
  1032. # --------------------------------------------------------------------------------------------------------
  1033. @pyqtSlot()
  1034. def slot_addPlugin(self):
  1035. if self.ui.tableWidget.currentRow() >= 0:
  1036. self.fRetPlugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(), 0).data(Qt.UserRole)
  1037. self.accept()
  1038. else:
  1039. self.reject()
  1040. @pyqtSlot(int)
  1041. def slot_checkPlugin(self, row):
  1042. self.ui.b_add.setEnabled(row >= 0)
  1043. @pyqtSlot()
  1044. def slot_checkFilters(self):
  1045. self._checkFilters()
  1046. @pyqtSlot()
  1047. def slot_maybeShowFilters(self):
  1048. self._showFilters(not self.ui.frame.isVisible())
  1049. @pyqtSlot()
  1050. def slot_refreshPlugins(self):
  1051. if PluginRefreshW(self, self.host).exec_():
  1052. self._reAddPlugins()
  1053. if self.fRealParent:
  1054. self.fRealParent.setLoadRDFsNeeded()
  1055. # --------------------------------------------------------------------------------------------------------
  1056. @pyqtSlot()
  1057. def slot_saveSettings(self):
  1058. settings = QSettings("falkTX", "CarlaDatabase2")
  1059. settings.setValue("PluginDatabase/Geometry", self.saveGeometry())
  1060. settings.setValue("PluginDatabase/TableGeometry_5", self.ui.tableWidget.horizontalHeader().saveState())
  1061. settings.setValue("PluginDatabase/ShowFilters", (self.ui.tb_filters.arrowType() == Qt.UpArrow))
  1062. settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked())
  1063. settings.setValue("PluginDatabase/ShowInstruments", self.ui.ch_instruments.isChecked())
  1064. settings.setValue("PluginDatabase/ShowMIDI", self.ui.ch_midi.isChecked())
  1065. settings.setValue("PluginDatabase/ShowOther", self.ui.ch_other.isChecked())
  1066. settings.setValue("PluginDatabase/ShowInternal", self.ui.ch_internal.isChecked())
  1067. settings.setValue("PluginDatabase/ShowLADSPA", self.ui.ch_ladspa.isChecked())
  1068. settings.setValue("PluginDatabase/ShowDSSI", self.ui.ch_dssi.isChecked())
  1069. settings.setValue("PluginDatabase/ShowLV2", self.ui.ch_lv2.isChecked())
  1070. settings.setValue("PluginDatabase/ShowVST2", self.ui.ch_vst.isChecked())
  1071. settings.setValue("PluginDatabase/ShowKits", self.ui.ch_kits.isChecked())
  1072. settings.setValue("PluginDatabase/ShowNative", self.ui.ch_native.isChecked())
  1073. settings.setValue("PluginDatabase/ShowBridged", self.ui.ch_bridged.isChecked())
  1074. settings.setValue("PluginDatabase/ShowBridgedWine", self.ui.ch_bridged_wine.isChecked())
  1075. settings.setValue("PluginDatabase/ShowRtSafe", self.ui.ch_rtsafe.isChecked())
  1076. settings.setValue("PluginDatabase/ShowHasGUI", self.ui.ch_gui.isChecked())
  1077. settings.setValue("PluginDatabase/ShowStereoOnly", self.ui.ch_stereo.isChecked())
  1078. settings.setValue("PluginDatabase/SearchText", self.ui.lineEdit.text())
  1079. # --------------------------------------------------------------------------------------------------------
  1080. def loadSettings(self):
  1081. settings = QSettings("falkTX", "CarlaDatabase2")
  1082. self.restoreGeometry(settings.value("PluginDatabase/Geometry", b""))
  1083. self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, type=bool))
  1084. self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, type=bool))
  1085. self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, type=bool))
  1086. self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, type=bool))
  1087. self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, type=bool))
  1088. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, type=bool))
  1089. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, type=bool))
  1090. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, type=bool))
  1091. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST2", True, type=bool))
  1092. self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, type=bool))
  1093. self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, type=bool))
  1094. self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, type=bool))
  1095. self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, type=bool))
  1096. self.ui.ch_rtsafe.setChecked(settings.value("PluginDatabase/ShowRtSafe", False, type=bool))
  1097. self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, type=bool))
  1098. self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, type=bool))
  1099. self.ui.lineEdit.setText(settings.value("PluginDatabase/SearchText", "", type=str))
  1100. tableGeometry = settings.value("PluginDatabase/TableGeometry_5")
  1101. if tableGeometry:
  1102. self.ui.tableWidget.horizontalHeader().restoreState(tableGeometry)
  1103. else:
  1104. self.ui.tableWidget.sortByColumn(0, Qt.AscendingOrder)
  1105. self._showFilters(settings.value("PluginDatabase/ShowFilters", False, type=bool))
  1106. # --------------------------------------------------------------------------------------------------------
  1107. def _checkFilters(self):
  1108. text = self.ui.lineEdit.text().lower()
  1109. hideEffects = not self.ui.ch_effects.isChecked()
  1110. hideInstruments = not self.ui.ch_instruments.isChecked()
  1111. hideMidi = not self.ui.ch_midi.isChecked()
  1112. hideOther = not self.ui.ch_other.isChecked()
  1113. hideInternal = not self.ui.ch_internal.isChecked()
  1114. hideLadspa = not self.ui.ch_ladspa.isChecked()
  1115. hideDssi = not self.ui.ch_dssi.isChecked()
  1116. hideLV2 = not self.ui.ch_lv2.isChecked()
  1117. hideVST2 = not self.ui.ch_vst.isChecked()
  1118. hideKits = not self.ui.ch_kits.isChecked()
  1119. hideNative = not self.ui.ch_native.isChecked()
  1120. hideBridged = not self.ui.ch_bridged.isChecked()
  1121. hideBridgedWine = not self.ui.ch_bridged_wine.isChecked()
  1122. hideNonRtSafe = self.ui.ch_rtsafe.isChecked()
  1123. hideNonGui = self.ui.ch_gui.isChecked()
  1124. hideNonStereo = self.ui.ch_stereo.isChecked()
  1125. if HAIKU or LINUX or MACOS:
  1126. nativeBins = [BINARY_POSIX32, BINARY_POSIX64]
  1127. wineBins = [BINARY_WIN32, BINARY_WIN64]
  1128. elif WINDOWS:
  1129. nativeBins = [BINARY_WIN32, BINARY_WIN64]
  1130. wineBins = []
  1131. else:
  1132. nativeBins = []
  1133. wineBins = []
  1134. rowCount = self.ui.tableWidget.rowCount()
  1135. for i in range(self.fLastTableIndex):
  1136. plugin = self.ui.tableWidget.item(i, 0).data(Qt.UserRole)
  1137. aIns = plugin['audio.ins']
  1138. aOuts = plugin['audio.outs']
  1139. mIns = plugin['midi.ins']
  1140. mOuts = plugin['midi.outs']
  1141. ptype = self.ui.tableWidget.item(i, 12).text()
  1142. isSynth = bool(plugin['hints'] & PLUGIN_IS_SYNTH)
  1143. isEffect = bool(aIns > 0 < aOuts and not isSynth)
  1144. isMidi = bool(aIns == 0 and aOuts == 0 and mIns > 0 < mOuts)
  1145. isKit = bool(ptype in ("SF2", "SFZ"))
  1146. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  1147. isNative = bool(plugin['build'] == BINARY_NATIVE)
  1148. isRtSafe = bool(plugin['hints'] & PLUGIN_IS_RTSAFE)
  1149. isStereo = bool(aIns == 2 and aOuts == 2) or (isSynth and aOuts == 2)
  1150. hasGui = bool(plugin['hints'] & PLUGIN_HAS_CUSTOM_UI)
  1151. isBridged = bool(not isNative and plugin['build'] in nativeBins)
  1152. isBridgedWine = bool(not isNative and plugin['build'] in wineBins)
  1153. if hideEffects and isEffect:
  1154. self.ui.tableWidget.hideRow(i)
  1155. elif hideInstruments and isSynth:
  1156. self.ui.tableWidget.hideRow(i)
  1157. elif hideMidi and isMidi:
  1158. self.ui.tableWidget.hideRow(i)
  1159. elif hideOther and isOther:
  1160. self.ui.tableWidget.hideRow(i)
  1161. elif hideKits and isKit:
  1162. self.ui.tableWidget.hideRow(i)
  1163. elif hideInternal and ptype == self.tr("Internal"):
  1164. self.ui.tableWidget.hideRow(i)
  1165. elif hideLadspa and ptype == "LADSPA":
  1166. self.ui.tableWidget.hideRow(i)
  1167. elif hideDssi and ptype == "DSSI":
  1168. self.ui.tableWidget.hideRow(i)
  1169. elif hideLV2 and ptype == "LV2":
  1170. self.ui.tableWidget.hideRow(i)
  1171. elif hideVST2 and ptype == "VST2":
  1172. self.ui.tableWidget.hideRow(i)
  1173. elif hideNative and isNative:
  1174. self.ui.tableWidget.hideRow(i)
  1175. elif hideBridged and isBridged:
  1176. self.ui.tableWidget.hideRow(i)
  1177. elif hideBridgedWine and isBridgedWine:
  1178. self.ui.tableWidget.hideRow(i)
  1179. elif hideNonRtSafe and not isRtSafe:
  1180. self.ui.tableWidget.hideRow(i)
  1181. elif hideNonGui and not hasGui:
  1182. self.ui.tableWidget.hideRow(i)
  1183. elif hideNonStereo and not isStereo:
  1184. self.ui.tableWidget.hideRow(i)
  1185. elif (text and not (
  1186. text in self.ui.tableWidget.item(i, 0).text().lower() or
  1187. text in self.ui.tableWidget.item(i, 1).text().lower() or
  1188. text in self.ui.tableWidget.item(i, 2).text().lower() or
  1189. text in self.ui.tableWidget.item(i, 3).text().lower() or
  1190. text in self.ui.tableWidget.item(i, 13).text().lower())):
  1191. self.ui.tableWidget.hideRow(i)
  1192. else:
  1193. self.ui.tableWidget.showRow(i)
  1194. # --------------------------------------------------------------------------------------------------------
  1195. def _showFilters(self, yesNo):
  1196. self.ui.tb_filters.setArrowType(Qt.UpArrow if yesNo else Qt.DownArrow)
  1197. self.ui.frame.setVisible(yesNo)
  1198. # --------------------------------------------------------------------------------------------------------
  1199. def _addPluginToTable(self, plugin, ptype):
  1200. if plugin['API'] != PLUGIN_QUERY_API_VERSION and ptype == self.tr("Internal"):
  1201. return
  1202. if ptype in (self.tr("Internal"), "LV2", "SF2", "SFZ"):
  1203. plugin['build'] = BINARY_NATIVE
  1204. index = self.fLastTableIndex
  1205. if plugin['build'] == BINARY_NATIVE:
  1206. bridgeText = self.tr("No")
  1207. else:
  1208. if WINDOWS:
  1209. if plugin['build'] == BINARY_WIN32:
  1210. typeText = "32bit"
  1211. elif plugin['build'] == BINARY_WIN64:
  1212. typeText = "64bit"
  1213. else:
  1214. typeText = self.tr("Unknown")
  1215. else:
  1216. if plugin['build'] == BINARY_POSIX32:
  1217. typeText = "32bit"
  1218. elif plugin['build'] == BINARY_POSIX64:
  1219. typeText = "64bit"
  1220. elif plugin['build'] == BINARY_WIN32:
  1221. typeText = "Windows 32bit"
  1222. elif plugin['build'] == BINARY_WIN64:
  1223. typeText = "Windows 64bit"
  1224. else:
  1225. typeText = self.tr("Unknown")
  1226. bridgeText = self.tr("Yes (%s)" % typeText)
  1227. self.ui.tableWidget.setItem(index, 0, QTableWidgetItem(str(plugin['name'])))
  1228. self.ui.tableWidget.setItem(index, 1, QTableWidgetItem(str(plugin['label'])))
  1229. self.ui.tableWidget.setItem(index, 2, QTableWidgetItem(str(plugin['maker'])))
  1230. self.ui.tableWidget.setItem(index, 3, QTableWidgetItem(str(plugin['uniqueId'])))
  1231. self.ui.tableWidget.setItem(index, 4, QTableWidgetItem(str(plugin['audio.ins'])))
  1232. self.ui.tableWidget.setItem(index, 5, QTableWidgetItem(str(plugin['audio.outs'])))
  1233. self.ui.tableWidget.setItem(index, 6, QTableWidgetItem(str(plugin['parameters.ins'])))
  1234. self.ui.tableWidget.setItem(index, 7, QTableWidgetItem(str(plugin['parameters.outs'])))
  1235. self.ui.tableWidget.setItem(index, 9, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_HAS_CUSTOM_UI) else self.tr("No")))
  1236. self.ui.tableWidget.setItem(index, 10, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_IS_SYNTH) else self.tr("No")))
  1237. self.ui.tableWidget.setItem(index, 11, QTableWidgetItem(bridgeText))
  1238. self.ui.tableWidget.setItem(index, 12, QTableWidgetItem(ptype))
  1239. self.ui.tableWidget.setItem(index, 13, QTableWidgetItem(str(plugin['filename'])))
  1240. self.ui.tableWidget.item(index, 0).setData(Qt.UserRole, plugin)
  1241. self.fLastTableIndex += 1
  1242. # --------------------------------------------------------------------------------------------------------
  1243. def _reAddInternalHelper(self, settingsDB, ptype, path):
  1244. if ptype == PLUGIN_INTERNAL:
  1245. ptypeStr = "Internal"
  1246. ptypeStrTr = self.tr("Internal")
  1247. elif ptype == PLUGIN_LV2:
  1248. ptypeStr = "LV2"
  1249. ptypeStrTr = ptypeStr
  1250. #elif ptype == PLUGIN_SFZ:
  1251. #ptypeStr = "SFZ"
  1252. #ptypeStrTr = ptypeStr
  1253. else:
  1254. return 0
  1255. plugins = toList(settingsDB.value("Plugins/" + ptypeStr, []))
  1256. pluginCount = settingsDB.value("PluginCount/" + ptypeStr, 0, type=int)
  1257. pluginCountNew = gCarla.utils.get_cached_plugin_count(ptype, path)
  1258. if pluginCountNew != pluginCount or (len(plugins) > 0 and plugins[0]['API'] != PLUGIN_QUERY_API_VERSION):
  1259. plugins = []
  1260. pluginCount = pluginCountNew
  1261. QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50)
  1262. for i in range(pluginCountNew):
  1263. descInfo = gCarla.utils.get_cached_plugin_info(ptype, i)
  1264. if not descInfo['valid']:
  1265. continue
  1266. info = checkPluginCached(descInfo, ptype)
  1267. plugins.append(info)
  1268. if i % 50 == 0:
  1269. QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50)
  1270. settingsDB.setValue("Plugins/" + ptypeStr, plugins)
  1271. settingsDB.setValue("PluginCount/" + ptypeStr, pluginCount)
  1272. # prepare rows in advance
  1273. self.ui.tableWidget.setRowCount(self.fLastTableIndex + len(plugins))
  1274. for plugin in plugins:
  1275. self._addPluginToTable(plugin, ptypeStrTr)
  1276. return pluginCount
  1277. def _reAddPlugins(self):
  1278. settingsDB = QSettings("falkTX", "CarlaPlugins4")
  1279. for x in range(self.ui.tableWidget.rowCount()):
  1280. self.ui.tableWidget.removeRow(0)
  1281. self.fLastTableIndex = 0
  1282. self.ui.tableWidget.setSortingEnabled(False)
  1283. settings = QSettings("falkTX", "Carla2")
  1284. LV2_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH)))
  1285. del settings
  1286. # ----------------------------------------------------------------------------------------------------
  1287. # plugins handled through backend
  1288. internalCount = self._reAddInternalHelper(settingsDB, PLUGIN_INTERNAL, "")
  1289. lv2Count = self._reAddInternalHelper(settingsDB, PLUGIN_LV2, LV2_PATH)
  1290. # ----------------------------------------------------------------------------------------------------
  1291. # LADSPA
  1292. ladspaPlugins = []
  1293. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_native", []))
  1294. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix32", []))
  1295. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix64", []))
  1296. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win32", []))
  1297. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win64", []))
  1298. # ----------------------------------------------------------------------------------------------------
  1299. # DSSI
  1300. dssiPlugins = []
  1301. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_native", []))
  1302. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix32", []))
  1303. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix64", []))
  1304. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win32", []))
  1305. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win64", []))
  1306. # ----------------------------------------------------------------------------------------------------
  1307. # VST2
  1308. vst2Plugins = []
  1309. vst2Plugins += toList(settingsDB.value("Plugins/VST2_native", []))
  1310. vst2Plugins += toList(settingsDB.value("Plugins/VST2_posix32", []))
  1311. vst2Plugins += toList(settingsDB.value("Plugins/VST2_posix64", []))
  1312. vst2Plugins += toList(settingsDB.value("Plugins/VST2_win32", []))
  1313. vst2Plugins += toList(settingsDB.value("Plugins/VST2_win64", []))
  1314. # ----------------------------------------------------------------------------------------------------
  1315. # Kits
  1316. sf2s = toList(settingsDB.value("Plugins/SF2", []))
  1317. sfzs = toList(settingsDB.value("Plugins/SFZ", []))
  1318. # ----------------------------------------------------------------------------------------------------
  1319. # count plugins first, so we can create rows in advance
  1320. ladspaCount = 0
  1321. dssiCount = 0
  1322. vstCount = 0
  1323. sf2Count = 0
  1324. sfzCount = 0
  1325. for plugins in ladspaPlugins:
  1326. ladspaCount += len(plugins)
  1327. for plugins in dssiPlugins:
  1328. dssiCount += len(plugins)
  1329. for plugins in vst2Plugins:
  1330. vstCount += len(plugins)
  1331. for plugins in sf2s:
  1332. sf2Count += len(plugins)
  1333. sfzCount += len(sfzs)
  1334. self.ui.tableWidget.setRowCount(self.fLastTableIndex+ladspaCount+dssiCount+vstCount+sf2Count+sfzCount)
  1335. self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2 and %i VST plugins, plus %i Sound Kits" % (
  1336. internalCount, ladspaCount, dssiCount, lv2Count, vstCount, sf2Count+sfzCount)))
  1337. # ----------------------------------------------------------------------------------------------------
  1338. # now add all plugins to the table
  1339. for plugins in ladspaPlugins:
  1340. for plugin in plugins:
  1341. self._addPluginToTable(plugin, "LADSPA")
  1342. for plugins in dssiPlugins:
  1343. for plugin in plugins:
  1344. self._addPluginToTable(plugin, "DSSI")
  1345. for plugins in vst2Plugins:
  1346. for plugin in plugins:
  1347. self._addPluginToTable(plugin, "VST2")
  1348. for sf2 in sf2s:
  1349. for sf2_i in sf2:
  1350. self._addPluginToTable(sf2_i, "SF2")
  1351. for sfz in sfzs:
  1352. self._addPluginToTable(sfz, "SFZ")
  1353. # ----------------------------------------------------------------------------------------------------
  1354. self.ui.tableWidget.setSortingEnabled(True)
  1355. self._checkFilters()
  1356. # --------------------------------------------------------------------------------------------------------
  1357. def done(self, r):
  1358. QDialog.done(self, r)
  1359. self.close()
  1360. # ----------------------------------------------------------------------------------------------------------------------
  1361. # Jack Application Dialog
  1362. class JackApplicationW(QDialog):
  1363. SESSION_MGR_NONE = 0
  1364. SESSION_MGR_AUTO = 1
  1365. SESSION_MGR_JACK = 2
  1366. SESSION_MGR_LADISH = 3
  1367. SESSION_MGR_NSM = 4
  1368. FLAG_CONTROL_WINDOW = 0x01
  1369. FLAG_CAPTURE_FIRST_WINDOW = 0x02
  1370. FLAG_BUFFERS_ADDITION_MODE = 0x10
  1371. def __init__(self, parent, host):
  1372. QDialog.__init__(self, parent)
  1373. self.host = host
  1374. self.ui = ui_carla_add_jack.Ui_Dialog()
  1375. self.ui.setupUi(self)
  1376. if False:
  1377. # kdevelop likes this :)
  1378. self.host = host = CarlaHostNull()
  1379. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  1380. # --------------------------------------------------------------------------------------------------------------
  1381. # Load settings
  1382. self.loadSettings()
  1383. # --------------------------------------------------------------------------------------------------------------
  1384. # Set-up connections
  1385. self.finished.connect(self.slot_saveSettings)
  1386. self.ui.le_command.textChanged.connect(self.slot_commandChanged)
  1387. # ------------------------------------------------------------------------------------------------------------------
  1388. def getCommandAndFlags(self):
  1389. name = self.ui.le_name.text()
  1390. command = self.ui.le_command.text()
  1391. smgr = self.SESSION_MGR_NONE
  1392. flags = 0x0
  1393. if not name:
  1394. name = os.path.basename(command.split(" ",1)[0])
  1395. # TODO finalize flag definitions
  1396. uiSessionMgrIndex = self.ui.cb_session_mgr.currentIndex()
  1397. if uiSessionMgrIndex == 1:
  1398. smgr = self.SESSION_MGR_AUTO
  1399. elif uiSessionMgrIndex == 2:
  1400. smgr = self.SESSION_MGR_LADISH
  1401. #elif uiSessionMgrIndex == 2:
  1402. #smgr = self.SESSION_MGR_NSM
  1403. if self.ui.cb_manage_window.isChecked():
  1404. flags |= self.FLAG_CONTROL_WINDOW
  1405. if self.ui.cb_capture_first_window.isChecked():
  1406. flags |= self.FLAG_CAPTURE_FIRST_WINDOW
  1407. if self.ui.cb_buffers_addition_mode.isChecked():
  1408. flags |= self.FLAG_BUFFERS_ADDITION_MODE
  1409. baseIntVal = ord('0')
  1410. labelSetup = "%s%s%s%s%s%s" % (chr(baseIntVal+self.ui.sb_audio_ins.value()),
  1411. chr(baseIntVal+self.ui.sb_audio_outs.value()),
  1412. chr(baseIntVal+self.ui.sb_midi_ins.value()),
  1413. chr(baseIntVal+self.ui.sb_midi_outs.value()),
  1414. chr(baseIntVal+smgr),
  1415. chr(baseIntVal+flags))
  1416. return (command, name, labelSetup)
  1417. def loadSettings(self):
  1418. settings = QSettings("falkTX", "CarlaAddJackApp")
  1419. command = settings.value("Command", "", type=str)
  1420. self.ui.le_command.setText(command)
  1421. self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(len(command) > 0)
  1422. self.ui.le_name.setText(settings.value("Name", "", type=str))
  1423. self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, type=int))
  1424. self.ui.sb_audio_outs.setValue(settings.value("NumAudioOuts", 2, type=int))
  1425. self.ui.sb_midi_ins.setValue(settings.value("NumMidiIns", 0, type=int))
  1426. self.ui.sb_midi_outs.setValue(settings.value("NumMidiOuts", 0, type=int))
  1427. self.ui.cb_manage_window.setChecked(settings.value("ManageWindow", True, type=bool))
  1428. # ------------------------------------------------------------------------------------------------------------------
  1429. @pyqtSlot(str)
  1430. def slot_commandChanged(self, text):
  1431. self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(len(text) > 0)
  1432. @pyqtSlot()
  1433. def slot_saveSettings(self):
  1434. settings = QSettings("falkTX", "CarlaAddJackApp")
  1435. settings.setValue("Command", self.ui.le_command.text())
  1436. settings.setValue("Name", self.ui.le_name.text())
  1437. settings.setValue("NumAudioIns", self.ui.sb_audio_ins.value())
  1438. settings.setValue("NumAudioOuts", self.ui.sb_audio_outs.value())
  1439. settings.setValue("NumMidiIns", self.ui.sb_midi_ins.value())
  1440. settings.setValue("NumMidiOuts", self.ui.sb_midi_outs.value())
  1441. settings.setValue("ManageWindow", self.ui.cb_manage_window.isChecked())
  1442. # ------------------------------------------------------------------------------------------------------------------
  1443. def done(self, r):
  1444. QDialog.done(self, r)
  1445. self.close()
  1446. # ----------------------------------------------------------------------------------------------------------------------
  1447. # Main
  1448. if __name__ == '__main__':
  1449. from carla_app import CarlaApplication
  1450. from carla_host import initHost, loadHostSettings
  1451. initName, libPrefix = handleInitialCommandLineArguments(__file__ if "__file__" in dir() else None)
  1452. app = CarlaApplication("Carla2-Database", libPrefix)
  1453. host = initHost("Carla2-Database", libPrefix, False, False, False)
  1454. loadHostSettings(host)
  1455. gui = PluginDatabaseW(None, host)
  1456. gui.show()
  1457. app.exit_exec()
  1458. # ------------------------------------------------------------------------------------------------------------