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.

2493 lines
102KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin database code
  4. # Copyright (C) 2011-2021 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, QByteArray, QEventLoop, QThread
  22. from PyQt5.QtGui import QPixmap
  23. from PyQt5.QtWidgets import QApplication, QDialog, QDialogButtonBox, QHeaderView, QTableWidgetItem
  24. # ---------------------------------------------------------------------------------------------------------------------
  25. # Imports (Custom)
  26. import ui_carla_add_jack
  27. import ui_carla_database
  28. import ui_carla_refresh
  29. from carla_backend import *
  30. from carla_shared import *
  31. from carla_utils import getPluginTypeAsString, getPluginCategoryAsString
  32. # ---------------------------------------------------------------------------------------------------------------------
  33. # Try Import LADSPA-RDF
  34. if WINDOWS:
  35. haveLRDF = False
  36. elif not CXFREEZE:
  37. try:
  38. import ladspa_rdf
  39. import json
  40. haveLRDF = True
  41. except:
  42. qWarning("LRDF Support not available (LADSPA-RDF will be disabled)")
  43. haveLRDF = False
  44. else:
  45. qWarning("LRDF Support disabled for static build (LADSPA-RDF will be disabled)")
  46. haveLRDF = False
  47. # ---------------------------------------------------------------------------------------------------------------------
  48. # Set LADSPA-RDF Path
  49. if haveLRDF and readEnvVars:
  50. LADSPA_RDF_PATH_env = os.getenv("LADSPA_RDF_PATH")
  51. if LADSPA_RDF_PATH_env:
  52. try:
  53. ladspa_rdf.set_rdf_path(LADSPA_RDF_PATH_env.split(splitter))
  54. except:
  55. pass
  56. del LADSPA_RDF_PATH_env
  57. # ---------------------------------------------------------------------------------------------------------------------
  58. # Plugin Query (helper functions)
  59. def findBinaries(binPath, pluginType, OS):
  60. binaries = []
  61. if OS == "HAIKU":
  62. extensions = ("") if pluginType == PLUGIN_VST2 else (".so",)
  63. elif OS == "MACOS":
  64. extensions = (".dylib", ".so")
  65. elif OS == "WINDOWS":
  66. extensions = (".dll",)
  67. else:
  68. extensions = (".so",)
  69. for root, dirs, files in os.walk(binPath):
  70. for name in tuple(name for name in files if name.lower().endswith(extensions)):
  71. binaries.append(os.path.join(root, name))
  72. return binaries
  73. def findVST3Binaries(binPath):
  74. binaries = []
  75. for root, dirs, files in os.walk(binPath):
  76. for name in tuple(name for name in (files+dirs) if name.lower().endswith(".vst3")):
  77. binaries.append(os.path.join(root, name))
  78. return binaries
  79. def findLV2Bundles(bundlePath):
  80. bundles = []
  81. for root, dirs, files in os.walk(bundlePath, followlinks=True):
  82. if root == bundlePath: continue
  83. if os.path.exists(os.path.join(root, "manifest.ttl")):
  84. bundles.append(root)
  85. return bundles
  86. def findMacVSTBundles(bundlePath, isVST3):
  87. bundles = []
  88. extension = ".vst3" if isVST3 else ".vst"
  89. for root, dirs, files in os.walk(bundlePath, followlinks=True):
  90. #if root == bundlePath: continue # FIXME
  91. for name in tuple(name for name in dirs if name.lower().endswith(extension)):
  92. bundles.append(os.path.join(root, name))
  93. return bundles
  94. def findFilenames(filePath, stype):
  95. filenames = []
  96. if stype == "sf2":
  97. extensions = (".sf2",".sf3",)
  98. else:
  99. return []
  100. for root, dirs, files in os.walk(filePath):
  101. for name in tuple(name for name in files if name.lower().endswith(extensions)):
  102. filenames.append(os.path.join(root, name))
  103. return filenames
  104. # ---------------------------------------------------------------------------------------------------------------------
  105. # Plugin Query
  106. PLUGIN_QUERY_API_VERSION = 12
  107. PyPluginInfo = {
  108. 'API': PLUGIN_QUERY_API_VERSION,
  109. 'valid': False,
  110. 'build': BINARY_NONE,
  111. 'type': PLUGIN_NONE,
  112. 'hints': 0x0,
  113. 'category': "",
  114. 'filename': "",
  115. 'name': "",
  116. 'label': "",
  117. 'maker': "",
  118. 'uniqueId': 0,
  119. 'audio.ins': 0,
  120. 'audio.outs': 0,
  121. 'cv.ins': 0,
  122. 'cv.outs': 0,
  123. 'midi.ins': 0,
  124. 'midi.outs': 0,
  125. 'parameters.ins': 0,
  126. 'parameters.outs': 0
  127. }
  128. gDiscoveryProcess = None
  129. def findWinePrefix(filename, recursionLimit = 10):
  130. if recursionLimit == 0 or len(filename) < 5 or "/" not in filename:
  131. return ""
  132. path = filename[:filename.rfind("/")]
  133. if os.path.isdir(path + "/dosdevices"):
  134. return path
  135. return findWinePrefix(path, recursionLimit-1)
  136. def runCarlaDiscovery(itype, stype, filename, tool, wineSettings=None):
  137. if not os.path.exists(tool):
  138. qWarning("runCarlaDiscovery() - tool '%s' does not exist" % tool)
  139. return
  140. command = []
  141. if LINUX or MACOS:
  142. command.append("env")
  143. command.append("LANG=C")
  144. command.append("LD_PRELOAD=")
  145. if wineSettings is not None:
  146. command.append("WINEDEBUG=-all")
  147. if wineSettings['autoPrefix']:
  148. winePrefix = findWinePrefix(filename)
  149. else:
  150. winePrefix = ""
  151. if not winePrefix:
  152. envWinePrefix = os.getenv("WINEPREFIX")
  153. if envWinePrefix:
  154. winePrefix = envWinePrefix
  155. elif wineSettings['fallbackPrefix']:
  156. winePrefix = os.path.expanduser(wineSettings['fallbackPrefix'])
  157. else:
  158. winePrefix = os.path.expanduser("~/.wine")
  159. wineCMD = wineSettings['executable'] if wineSettings['executable'] else "wine"
  160. if tool.endswith("64.exe") and os.path.exists(wineCMD + "64"):
  161. wineCMD += "64"
  162. command.append("WINEPREFIX=" + winePrefix)
  163. command.append(wineCMD)
  164. command.append(tool)
  165. command.append(stype)
  166. command.append(filename)
  167. global gDiscoveryProcess
  168. gDiscoveryProcess = Popen(command, stdout=PIPE)
  169. pinfo = None
  170. plugins = []
  171. fakeLabel = os.path.basename(filename).rsplit(".", 1)[0]
  172. while True:
  173. try:
  174. line = gDiscoveryProcess.stdout.readline().decode("utf-8", errors="ignore")
  175. except:
  176. print("ERROR: discovery readline failed")
  177. break
  178. # line is valid, strip it
  179. if line:
  180. line = line.strip()
  181. # line is invalid, try poll() again
  182. elif gDiscoveryProcess.poll() is None:
  183. continue
  184. # line is invalid and poll() failed, stop here
  185. else:
  186. break
  187. if line == "carla-discovery::init::-----------":
  188. pinfo = deepcopy(PyPluginInfo)
  189. pinfo['type'] = itype
  190. pinfo['filename'] = filename if filename != ":all" else ""
  191. elif line == "carla-discovery::end::------------":
  192. if pinfo is not None:
  193. plugins.append(pinfo)
  194. del pinfo
  195. pinfo = None
  196. elif line == "Segmentation fault":
  197. print("carla-discovery::crash::%s crashed during discovery" % filename)
  198. elif line.startswith("err:module:import_dll Library"):
  199. print(line)
  200. elif line.startswith("carla-discovery::info::"):
  201. print("%s - %s" % (line, filename))
  202. elif line.startswith("carla-discovery::warning::"):
  203. print("%s - %s" % (line, filename))
  204. elif line.startswith("carla-discovery::error::"):
  205. print("%s - %s" % (line, filename))
  206. elif line.startswith("carla-discovery::"):
  207. if pinfo == None:
  208. continue
  209. try:
  210. prop, value = line.replace("carla-discovery::", "").split("::", 1)
  211. except:
  212. continue
  213. if prop == "build":
  214. if value.isdigit(): pinfo['build'] = int(value)
  215. elif prop == "name":
  216. pinfo['name'] = value if value else fakeLabel
  217. elif prop == "label":
  218. pinfo['label'] = value if value else fakeLabel
  219. elif prop == "filename":
  220. pinfo['filename'] = value
  221. elif prop == "maker":
  222. pinfo['maker'] = value
  223. elif prop == "category":
  224. pinfo['category'] = value
  225. elif prop == "uniqueId":
  226. if value.isdigit(): pinfo['uniqueId'] = int(value)
  227. elif prop == "hints":
  228. if value.isdigit(): pinfo['hints'] = int(value)
  229. elif prop == "audio.ins":
  230. if value.isdigit(): pinfo['audio.ins'] = int(value)
  231. elif prop == "audio.outs":
  232. if value.isdigit(): pinfo['audio.outs'] = int(value)
  233. elif prop == "cv.ins":
  234. if value.isdigit(): pinfo['cv.ins'] = int(value)
  235. elif prop == "cv.outs":
  236. if value.isdigit(): pinfo['cv.outs'] = int(value)
  237. elif prop == "midi.ins":
  238. if value.isdigit(): pinfo['midi.ins'] = int(value)
  239. elif prop == "midi.outs":
  240. if value.isdigit(): pinfo['midi.outs'] = int(value)
  241. elif prop == "parameters.ins":
  242. if value.isdigit(): pinfo['parameters.ins'] = int(value)
  243. elif prop == "parameters.outs":
  244. if value.isdigit(): pinfo['parameters.outs'] = int(value)
  245. elif prop == "uri":
  246. if value:
  247. pinfo['label'] = value
  248. else:
  249. # cannot use empty URIs
  250. del pinfo
  251. pinfo = None
  252. continue
  253. else:
  254. print("%s - %s (unknown property)" % (line, filename))
  255. tmp = gDiscoveryProcess
  256. gDiscoveryProcess = None
  257. del tmp
  258. return plugins
  259. def killDiscovery():
  260. global gDiscoveryProcess
  261. if gDiscoveryProcess is not None:
  262. gDiscoveryProcess.kill()
  263. def checkPluginCached(desc, ptype):
  264. pinfo = deepcopy(PyPluginInfo)
  265. pinfo['build'] = BINARY_NATIVE
  266. pinfo['type'] = ptype
  267. pinfo['hints'] = desc['hints']
  268. pinfo['name'] = desc['name']
  269. pinfo['label'] = desc['label']
  270. pinfo['maker'] = desc['maker']
  271. pinfo['category'] = getPluginCategoryAsString(desc['category'])
  272. pinfo['audio.ins'] = desc['audioIns']
  273. pinfo['audio.outs'] = desc['audioOuts']
  274. pinfo['cv.ins'] = desc['cvIns']
  275. pinfo['cv.outs'] = desc['cvOuts']
  276. pinfo['midi.ins'] = desc['midiIns']
  277. pinfo['midi.outs'] = desc['midiOuts']
  278. pinfo['parameters.ins'] = desc['parameterIns']
  279. pinfo['parameters.outs'] = desc['parameterOuts']
  280. if ptype == PLUGIN_LV2:
  281. pinfo['filename'], pinfo['label'] = pinfo['label'].split('\\' if WINDOWS else '/',1)
  282. elif ptype == PLUGIN_SFZ:
  283. pinfo['filename'] = pinfo['label']
  284. pinfo['label'] = pinfo['name']
  285. return pinfo
  286. def checkPluginLADSPA(filename, tool, wineSettings=None):
  287. return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, wineSettings)
  288. def checkPluginDSSI(filename, tool, wineSettings=None):
  289. return runCarlaDiscovery(PLUGIN_DSSI, "DSSI", filename, tool, wineSettings)
  290. def checkPluginLV2(filename, tool, wineSettings=None):
  291. return runCarlaDiscovery(PLUGIN_LV2, "LV2", filename, tool, wineSettings)
  292. def checkPluginVST2(filename, tool, wineSettings=None):
  293. return runCarlaDiscovery(PLUGIN_VST2, "VST2", filename, tool, wineSettings)
  294. def checkPluginVST3(filename, tool, wineSettings=None):
  295. return runCarlaDiscovery(PLUGIN_VST3, "VST3", filename, tool, wineSettings)
  296. def checkFileSF2(filename, tool):
  297. return runCarlaDiscovery(PLUGIN_SF2, "SF2", filename, tool)
  298. def checkFileSFZ(filename, tool):
  299. return runCarlaDiscovery(PLUGIN_SFZ, "SFZ", filename, tool)
  300. def checkAllPluginsAU(tool):
  301. return runCarlaDiscovery(PLUGIN_AU, "AU", ":all", tool)
  302. # ---------------------------------------------------------------------------------------------------------------------
  303. # Separate Thread for Plugin Search
  304. class SearchPluginsThread(QThread):
  305. pluginLook = pyqtSignal(float, str)
  306. def __init__(self, parent, pathBinaries):
  307. QThread.__init__(self, parent)
  308. self.fContinueChecking = False
  309. self.fPathBinaries = pathBinaries
  310. self.fCheckNative = False
  311. self.fCheckPosix32 = False
  312. self.fCheckPosix64 = False
  313. self.fCheckWin32 = False
  314. self.fCheckWin64 = False
  315. self.fCheckLADSPA = False
  316. self.fCheckDSSI = False
  317. self.fCheckLV2 = False
  318. self.fCheckVST2 = False
  319. self.fCheckVST3 = False
  320. self.fCheckAU = False
  321. self.fCheckSF2 = False
  322. self.fCheckSFZ = False
  323. self.fCheckJSFX = False
  324. if WINDOWS:
  325. toolNative = "carla-discovery-native.exe"
  326. self.fWineSettings = None
  327. else:
  328. toolNative = "carla-discovery-native"
  329. settings = QSafeSettings("falkTX", "Carla2")
  330. self.fWineSettings = {
  331. 'executable' : settings.value(CARLA_KEY_WINE_EXECUTABLE, CARLA_DEFAULT_WINE_EXECUTABLE, str),
  332. 'autoPrefix' : settings.value(CARLA_KEY_WINE_AUTO_PREFIX, CARLA_DEFAULT_WINE_AUTO_PREFIX, bool),
  333. 'fallbackPrefix': settings.value(CARLA_KEY_WINE_FALLBACK_PREFIX, CARLA_DEFAULT_WINE_FALLBACK_PREFIX, str)
  334. }
  335. del settings
  336. self.fToolNative = os.path.join(pathBinaries, toolNative)
  337. if not os.path.exists(self.fToolNative):
  338. self.fToolNative = ""
  339. self.fCurCount = 0
  340. self.fCurPercentValue = 0
  341. self.fLastCheckValue = 0
  342. self.fSomethingChanged = False
  343. # -------------------------------------------------------------
  344. def hasSomethingChanged(self):
  345. return self.fSomethingChanged
  346. def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64):
  347. self.fCheckNative = native
  348. self.fCheckPosix32 = posix32
  349. self.fCheckPosix64 = posix64
  350. self.fCheckWin32 = win32
  351. self.fCheckWin64 = win64
  352. def setSearchPluginTypes(self, ladspa, dssi, lv2, vst2, vst3, au, sf2, sfz, jsfx):
  353. self.fCheckLADSPA = ladspa
  354. self.fCheckDSSI = dssi
  355. self.fCheckLV2 = lv2
  356. self.fCheckVST2 = vst2
  357. self.fCheckVST3 = vst3 and (LINUX or MACOS or WINDOWS)
  358. self.fCheckAU = au and MACOS
  359. self.fCheckSF2 = sf2
  360. self.fCheckSFZ = sfz
  361. self.fCheckJSFX = jsfx
  362. def stop(self):
  363. self.fContinueChecking = False
  364. def run(self):
  365. settingsDB = QSafeSettings("falkTX", "CarlaPlugins5")
  366. self.fContinueChecking = True
  367. self.fCurCount = 0
  368. # looking for plugins via external discovery
  369. pluginCount = 0
  370. if self.fCheckLADSPA: pluginCount += 1
  371. if self.fCheckDSSI: pluginCount += 1
  372. if self.fCheckVST2: pluginCount += 1
  373. if self.fCheckVST3: pluginCount += 1
  374. # Increase count by the number of externally discoverable plugin types
  375. if self.fCheckNative:
  376. self.fCurCount += pluginCount
  377. # Linux, MacOS and Windows are the only VST3 supported OSes
  378. if self.fCheckVST3 and not (LINUX or MACOS or WINDOWS):
  379. self.fCurCount -= 1
  380. if self.fCheckPosix32:
  381. self.fCurCount += pluginCount
  382. if self.fCheckVST3 and not (LINUX or MACOS):
  383. self.fCurCount -= 1
  384. if self.fCheckPosix64:
  385. self.fCurCount += pluginCount
  386. if self.fCheckVST3 and not (LINUX or MACOS):
  387. self.fCurCount -= 1
  388. if self.fCheckWin32:
  389. self.fCurCount += pluginCount
  390. if self.fCheckWin64:
  391. self.fCurCount += pluginCount
  392. # Special case for cached plugins, only "search" for native plugins (does not need tool)
  393. if self.fCheckLV2:
  394. if self.fCheckNative:
  395. self.fCurCount += 1
  396. else:
  397. self.fCheckLV2 = False
  398. if self.fCheckAU:
  399. if self.fCheckNative or self.fCheckPosix32:
  400. self.fCurCount += int(self.fCheckNative) + int(self.fCheckPosix32)
  401. else:
  402. self.fCheckAU = False
  403. if self.fCheckSFZ:
  404. if self.fCheckNative:
  405. self.fCurCount += 1
  406. else:
  407. self.fCheckSFZ = False
  408. # Special case for Sound Kits, only search native
  409. if self.fCheckNative and self.fToolNative:
  410. if self.fCheckSF2: self.fCurCount += 1
  411. else:
  412. self.fCheckSF2 = False
  413. if self.fCheckJSFX:
  414. if self.fCheckNative:
  415. self.fCurCount += 1
  416. else:
  417. self.fCheckJSFX = False
  418. if self.fCurCount == 0:
  419. return
  420. self.fCurPercentValue = 100.0 / self.fCurCount
  421. self.fLastCheckValue = 0.0
  422. del pluginCount
  423. if HAIKU:
  424. OS = "HAIKU"
  425. elif LINUX:
  426. OS = "LINUX"
  427. elif MACOS:
  428. OS = "MACOS"
  429. elif WINDOWS:
  430. OS = "WINDOWS"
  431. else:
  432. OS = "UNKNOWN"
  433. if not self.fContinueChecking: return
  434. self.fSomethingChanged = True
  435. if self.fCheckLADSPA:
  436. checkValue = 0.0
  437. if haveLRDF:
  438. if self.fCheckNative: checkValue += 0.1
  439. if self.fCheckPosix32: checkValue += 0.1
  440. if self.fCheckPosix64: checkValue += 0.1
  441. if self.fCheckWin32: checkValue += 0.1
  442. if self.fCheckWin64: checkValue += 0.1
  443. rdfPadValue = self.fCurPercentValue * checkValue
  444. if self.fCheckNative:
  445. plugins = self._checkLADSPA(OS, self.fToolNative)
  446. settingsDB.setValue("Plugins/LADSPA_native", plugins)
  447. if not self.fContinueChecking: return
  448. if self.fCheckPosix32:
  449. plugins = self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  450. settingsDB.setValue("Plugins/LADSPA_posix32", plugins)
  451. if not self.fContinueChecking: return
  452. if self.fCheckPosix64:
  453. plugins = self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  454. settingsDB.setValue("Plugins/LADSPA_posix64", plugins)
  455. if not self.fContinueChecking: return
  456. if self.fCheckWin32:
  457. plugins = self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  458. settingsDB.setValue("Plugins/LADSPA_win32", plugins)
  459. if not self.fContinueChecking: return
  460. if self.fCheckWin64:
  461. plugins = self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  462. settingsDB.setValue("Plugins/LADSPA_win64", plugins)
  463. settingsDB.sync()
  464. if not self.fContinueChecking: return
  465. if haveLRDF and checkValue > 0:
  466. startValue = self.fLastCheckValue - rdfPadValue
  467. self._pluginLook(startValue, "LADSPA RDFs...")
  468. try:
  469. ladspaRdfInfo = ladspa_rdf.recheck_all_plugins(self, startValue, self.fCurPercentValue, checkValue)
  470. except:
  471. ladspaRdfInfo = None
  472. if ladspaRdfInfo is not None:
  473. settingsDir = os.path.join(HOME, ".config", "falkTX")
  474. fdLadspa = open(os.path.join(settingsDir, "ladspa_rdf.db"), 'w')
  475. json.dump(ladspaRdfInfo, fdLadspa)
  476. fdLadspa.close()
  477. if not self.fContinueChecking: return
  478. if self.fCheckDSSI:
  479. if self.fCheckNative:
  480. plugins = self._checkDSSI(OS, self.fToolNative)
  481. settingsDB.setValue("Plugins/DSSI_native", plugins)
  482. if not self.fContinueChecking: return
  483. if self.fCheckPosix32:
  484. plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  485. settingsDB.setValue("Plugins/DSSI_posix32", plugins)
  486. if not self.fContinueChecking: return
  487. if self.fCheckPosix64:
  488. plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  489. settingsDB.setValue("Plugins/DSSI_posix64", plugins)
  490. if not self.fContinueChecking: return
  491. if self.fCheckWin32:
  492. plugins = self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  493. settingsDB.setValue("Plugins/DSSI_win32", plugins)
  494. if not self.fContinueChecking: return
  495. if self.fCheckWin64:
  496. plugins = self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  497. settingsDB.setValue("Plugins/DSSI_win64", plugins)
  498. settingsDB.sync()
  499. if not self.fContinueChecking: return
  500. if self.fCheckLV2:
  501. plugins = self._checkCached(True)
  502. settingsDB.setValue("Plugins/LV2", plugins)
  503. settingsDB.sync()
  504. if not self.fContinueChecking: return
  505. if self.fCheckVST2:
  506. if self.fCheckNative:
  507. plugins = self._checkVST2(OS, self.fToolNative)
  508. settingsDB.setValue("Plugins/VST2_native", plugins)
  509. if not self.fContinueChecking: return
  510. if self.fCheckPosix32:
  511. plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  512. settingsDB.setValue("Plugins/VST2_posix32", plugins)
  513. if not self.fContinueChecking: return
  514. if self.fCheckPosix64:
  515. plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  516. settingsDB.setValue("Plugins/VST2_posix64", plugins)
  517. if not self.fContinueChecking: return
  518. if self.fCheckWin32:
  519. plugins = self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  520. settingsDB.setValue("Plugins/VST2_win32", plugins)
  521. if not self.fContinueChecking: return
  522. if self.fCheckWin64:
  523. plugins = self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  524. settingsDB.setValue("Plugins/VST2_win64", plugins)
  525. if not self.fContinueChecking: return
  526. settingsDB.sync()
  527. if not self.fContinueChecking: return
  528. if self.fCheckVST3:
  529. if self.fCheckNative and (LINUX or MACOS or WINDOWS):
  530. plugins = self._checkVST3(OS, self.fToolNative)
  531. settingsDB.setValue("Plugins/VST3_native", plugins)
  532. if not self.fContinueChecking: return
  533. if self.fCheckPosix32:
  534. plugins = self._checkVST3(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  535. settingsDB.setValue("Plugins/VST3_posix32", plugins)
  536. if not self.fContinueChecking: return
  537. if self.fCheckPosix64:
  538. plugins = self._checkVST3(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  539. settingsDB.setValue("Plugins/VST3_posix64", plugins)
  540. if not self.fContinueChecking: return
  541. if self.fCheckWin32:
  542. plugins = self._checkVST3("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  543. settingsDB.setValue("Plugins/VST3_win32", plugins)
  544. if not self.fContinueChecking: return
  545. if self.fCheckWin64:
  546. plugins = self._checkVST3("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  547. settingsDB.setValue("Plugins/VST3_win64", plugins)
  548. if not self.fContinueChecking: return
  549. settingsDB.sync()
  550. if not self.fContinueChecking: return
  551. if self.fCheckAU:
  552. if self.fCheckNative:
  553. plugins = self._checkCached(False)
  554. settingsDB.setValue("Plugins/AU", plugins)
  555. settingsDB.sync()
  556. if not self.fContinueChecking: return
  557. if self.fCheckPosix32:
  558. plugins = self._checkAU(os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  559. settingsDB.setValue("Plugins/AU_posix32", self.fAuPlugins)
  560. if not self.fContinueChecking: return
  561. settingsDB.sync()
  562. if not self.fContinueChecking: return
  563. if self.fCheckSF2:
  564. settings = QSafeSettings("falkTX", "Carla2")
  565. SF2_PATH = settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH, list)
  566. del settings
  567. kits = self._checkKIT(SF2_PATH, "sf2")
  568. settingsDB.setValue("Plugins/SF2", kits)
  569. settingsDB.sync()
  570. if not self.fContinueChecking: return
  571. if self.fCheckSFZ:
  572. kits = self._checkSfzCached()
  573. settingsDB.setValue("Plugins/SFZ", kits)
  574. settingsDB.sync()
  575. if self.fCheckJSFX:
  576. kits = self._checkJsfxCached()
  577. settingsDB.setValue("Plugins/JSFX", kits)
  578. settingsDB.sync()
  579. def _checkLADSPA(self, OS, tool, isWine=False):
  580. ladspaBinaries = []
  581. ladspaPlugins = []
  582. self._pluginLook(self.fLastCheckValue, "LADSPA plugins...")
  583. settings = QSafeSettings("falkTX", "Carla2")
  584. LADSPA_PATH = settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH, list)
  585. del settings
  586. for iPATH in LADSPA_PATH:
  587. binaries = findBinaries(iPATH, PLUGIN_LADSPA, OS)
  588. for binary in binaries:
  589. if binary not in ladspaBinaries:
  590. ladspaBinaries.append(binary)
  591. ladspaBinaries.sort()
  592. if not self.fContinueChecking:
  593. return ladspaPlugins
  594. for i in range(len(ladspaBinaries)):
  595. ladspa = ladspaBinaries[i]
  596. percent = ( float(i) / len(ladspaBinaries) ) * self.fCurPercentValue
  597. self._pluginLook((self.fLastCheckValue + percent) * 0.9, ladspa)
  598. plugins = checkPluginLADSPA(ladspa, tool, self.fWineSettings if isWine else None)
  599. if plugins:
  600. ladspaPlugins.append(plugins)
  601. if not self.fContinueChecking:
  602. break
  603. self.fLastCheckValue += self.fCurPercentValue
  604. return ladspaPlugins
  605. def _checkDSSI(self, OS, tool, isWine=False):
  606. dssiBinaries = []
  607. dssiPlugins = []
  608. self._pluginLook(self.fLastCheckValue, "DSSI plugins...")
  609. settings = QSafeSettings("falkTX", "Carla2")
  610. DSSI_PATH = settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH, list)
  611. del settings
  612. for iPATH in DSSI_PATH:
  613. binaries = findBinaries(iPATH, PLUGIN_DSSI, OS)
  614. for binary in binaries:
  615. if binary not in dssiBinaries:
  616. dssiBinaries.append(binary)
  617. dssiBinaries.sort()
  618. if not self.fContinueChecking:
  619. return dssiPlugins
  620. for i in range(len(dssiBinaries)):
  621. dssi = dssiBinaries[i]
  622. percent = ( float(i) / len(dssiBinaries) ) * self.fCurPercentValue
  623. self._pluginLook(self.fLastCheckValue + percent, dssi)
  624. plugins = checkPluginDSSI(dssi, tool, self.fWineSettings if isWine else None)
  625. if plugins:
  626. dssiPlugins.append(plugins)
  627. if not self.fContinueChecking:
  628. break
  629. self.fLastCheckValue += self.fCurPercentValue
  630. return dssiPlugins
  631. def _checkVST2(self, OS, tool, isWine=False):
  632. vst2Binaries = []
  633. vst2Plugins = []
  634. if MACOS and not isWine:
  635. self._pluginLook(self.fLastCheckValue, "VST2 bundles...")
  636. else:
  637. self._pluginLook(self.fLastCheckValue, "VST2 plugins...")
  638. settings = QSafeSettings("falkTX", "Carla2")
  639. VST2_PATH = settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH, list)
  640. del settings
  641. for iPATH in VST2_PATH:
  642. if MACOS and not isWine:
  643. binaries = findMacVSTBundles(iPATH, False)
  644. else:
  645. binaries = findBinaries(iPATH, PLUGIN_VST2, OS)
  646. for binary in binaries:
  647. if binary not in vst2Binaries:
  648. vst2Binaries.append(binary)
  649. vst2Binaries.sort()
  650. if not self.fContinueChecking:
  651. return vst2Plugins
  652. for i in range(len(vst2Binaries)):
  653. vst2 = vst2Binaries[i]
  654. percent = ( float(i) / len(vst2Binaries) ) * self.fCurPercentValue
  655. self._pluginLook(self.fLastCheckValue + percent, vst2)
  656. plugins = checkPluginVST2(vst2, tool, self.fWineSettings if isWine else None)
  657. if plugins:
  658. vst2Plugins.append(plugins)
  659. if not self.fContinueChecking:
  660. break
  661. self.fLastCheckValue += self.fCurPercentValue
  662. return vst2Plugins
  663. def _checkVST3(self, OS, tool, isWine=False):
  664. vst3Binaries = []
  665. vst3Plugins = []
  666. if MACOS and not isWine:
  667. self._pluginLook(self.fLastCheckValue, "VST2 bundles...")
  668. else:
  669. self._pluginLook(self.fLastCheckValue, "VST2 plugins...")
  670. settings = QSafeSettings("falkTX", "Carla2")
  671. VST3_PATH = settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH, list)
  672. del settings
  673. for iPATH in VST3_PATH:
  674. if MACOS and not isWine:
  675. binaries = findMacVSTBundles(iPATH, True)
  676. else:
  677. binaries = findVST3Binaries(iPATH)
  678. for binary in binaries:
  679. if binary not in vst3Binaries:
  680. vst3Binaries.append(binary)
  681. vst3Binaries.sort()
  682. if not self.fContinueChecking:
  683. return vst3Plugins
  684. for i in range(len(vst3Binaries)):
  685. vst3 = vst3Binaries[i]
  686. percent = ( float(i) / len(vst3Binaries) ) * self.fCurPercentValue
  687. self._pluginLook(self.fLastCheckValue + percent, vst3)
  688. plugins = checkPluginVST3(vst3, tool, self.fWineSettings if isWine else None)
  689. if plugins:
  690. vst3Plugins.append(plugins)
  691. if not self.fContinueChecking:
  692. break
  693. self.fLastCheckValue += self.fCurPercentValue
  694. return vst3Plugins
  695. def _checkAU(self, tool):
  696. auPlugins = []
  697. plugins = checkAllPluginsAU(tool)
  698. if plugins:
  699. auPlugins.append(plugins)
  700. self.fLastCheckValue += self.fCurPercentValue
  701. return auPlugins
  702. def _checkKIT(self, kitPATH, kitExtension):
  703. kitFiles = []
  704. kitPlugins = []
  705. for iPATH in kitPATH:
  706. files = findFilenames(iPATH, kitExtension)
  707. for file_ in files:
  708. if file_ not in kitFiles:
  709. kitFiles.append(file_)
  710. kitFiles.sort()
  711. if not self.fContinueChecking:
  712. return kitPlugins
  713. for i in range(len(kitFiles)):
  714. kit = kitFiles[i]
  715. percent = ( float(i) / len(kitFiles) ) * self.fCurPercentValue
  716. self._pluginLook(self.fLastCheckValue + percent, kit)
  717. if kitExtension == "sf2":
  718. plugins = checkFileSF2(kit, self.fToolNative)
  719. else:
  720. plugins = None
  721. if plugins:
  722. kitPlugins.append(plugins)
  723. if not self.fContinueChecking:
  724. break
  725. self.fLastCheckValue += self.fCurPercentValue
  726. return kitPlugins
  727. def _checkCached(self, isLV2):
  728. if isLV2:
  729. settings = QSafeSettings("falkTX", "Carla2")
  730. PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list))
  731. del settings
  732. PLUG_TEXT = "LV2"
  733. PLUG_TYPE = PLUGIN_LV2
  734. else: # AU
  735. PLUG_PATH = ""
  736. PLUG_TEXT = "AU"
  737. PLUG_TYPE = PLUGIN_AU
  738. plugins = []
  739. self._pluginLook(self.fLastCheckValue, "{} plugins...".format(PLUG_TEXT))
  740. if not isLV2:
  741. gCarla.utils.juce_init()
  742. count = gCarla.utils.get_cached_plugin_count(PLUG_TYPE, PLUG_PATH)
  743. if not self.fContinueChecking:
  744. return plugins
  745. for i in range(count):
  746. descInfo = gCarla.utils.get_cached_plugin_info(PLUG_TYPE, i)
  747. percent = ( float(i) / count ) * self.fCurPercentValue
  748. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  749. if not descInfo['valid']:
  750. continue
  751. plugins.append(checkPluginCached(descInfo, PLUG_TYPE))
  752. if not self.fContinueChecking:
  753. break
  754. if not isLV2:
  755. gCarla.utils.juce_cleanup()
  756. self.fLastCheckValue += self.fCurPercentValue
  757. return plugins
  758. def _checkSfzCached(self):
  759. settings = QSafeSettings("falkTX", "Carla2")
  760. PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH, list))
  761. del settings
  762. sfzKits = []
  763. self._pluginLook(self.fLastCheckValue, "SFZ kits...")
  764. count = gCarla.utils.get_cached_plugin_count(PLUGIN_SFZ, PLUG_PATH)
  765. if not self.fContinueChecking:
  766. return sfzKits
  767. for i in range(count):
  768. descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_SFZ, i)
  769. percent = ( float(i) / count ) * self.fCurPercentValue
  770. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  771. if not descInfo['valid']:
  772. continue
  773. sfzKits.append(checkPluginCached(descInfo, PLUGIN_SFZ))
  774. if not self.fContinueChecking:
  775. break
  776. self.fLastCheckValue += self.fCurPercentValue
  777. return sfzKits
  778. def _checkJsfxCached(self):
  779. settings = QSafeSettings("falkTX", "Carla2")
  780. PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_JSFX, CARLA_DEFAULT_JSFX_PATH, list))
  781. del settings
  782. jsfxPlugins = []
  783. self._pluginLook(self.fLastCheckValue, "JSFX plugins...")
  784. count = gCarla.utils.get_cached_plugin_count(PLUGIN_JSFX, PLUG_PATH)
  785. if not self.fContinueChecking:
  786. return jsfxPlugins
  787. for i in range(count):
  788. descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_JSFX, i)
  789. percent = ( float(i) / count ) * self.fCurPercentValue
  790. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  791. if not descInfo['valid']:
  792. continue
  793. jsfxPlugins.append(checkPluginCached(descInfo, PLUGIN_JSFX))
  794. if not self.fContinueChecking:
  795. break
  796. self.fLastCheckValue += self.fCurPercentValue
  797. return jsfxPlugins
  798. def _pluginLook(self, percent, plugin):
  799. self.pluginLook.emit(percent, plugin)
  800. # ---------------------------------------------------------------------------------------------------------------------
  801. # Plugin Refresh Dialog
  802. class PluginRefreshW(QDialog):
  803. def __init__(self, parent, host, useSystemIcons, hasLoadedLv2Plugins):
  804. QDialog.__init__(self, parent)
  805. self.host = host
  806. self.ui = ui_carla_refresh.Ui_PluginRefreshW()
  807. self.ui.setupUi(self)
  808. # -------------------------------------------------------------------------------------------------------------
  809. # Internal stuff
  810. toolNative = "carla-discovery-native.exe" if WINDOWS else "carla-discovery-native"
  811. hasNative = os.path.exists(os.path.join(self.host.pathBinaries, toolNative))
  812. hasPosix32 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-posix32"))
  813. hasPosix64 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-posix64"))
  814. hasWin32 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-win32.exe"))
  815. hasWin64 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-win64.exe"))
  816. self.fThread = SearchPluginsThread(self, host.pathBinaries)
  817. # -------------------------------------------------------------------------------------------------------------
  818. # Set-up Icons
  819. if useSystemIcons:
  820. self.ui.b_start.setIcon(getIcon('arrow-right', 16, 'svgz'))
  821. self.ui.b_close.setIcon(getIcon('window-close', 16, 'svgz'))
  822. if QT_VERSION >= 0x50600:
  823. size = int(16 * self.devicePixelRatioF())
  824. else:
  825. size = 16
  826. self.fIconYes = QPixmap(getIcon('dialog-ok-apply', 16, 'svgz').pixmap(size))
  827. self.fIconNo = QPixmap(getIcon('dialog-error', 16, 'svgz').pixmap(size))
  828. else:
  829. self.fIconYes = QPixmap(":/16x16/dialog-ok-apply.svgz")
  830. self.fIconNo = QPixmap(":/16x16/dialog-error.svgz")
  831. # -------------------------------------------------------------------------------------------------------------
  832. # Set-up GUI
  833. self.ui.b_skip.setVisible(False)
  834. if HAIKU:
  835. self.ui.ch_posix32.setText("Haiku 32bit")
  836. self.ui.ch_posix64.setText("Haiku 64bit")
  837. elif LINUX:
  838. self.ui.ch_posix32.setText("Linux 32bit")
  839. self.ui.ch_posix64.setText("Linux 64bit")
  840. elif MACOS:
  841. self.ui.ch_posix32.setText("MacOS 32bit")
  842. self.ui.ch_posix64.setText("MacOS 64bit")
  843. if hasPosix32 and not WINDOWS:
  844. self.ui.ico_posix32.setPixmap(self.fIconYes)
  845. else:
  846. self.ui.ico_posix32.setPixmap(self.fIconNo)
  847. self.ui.ch_posix32.setEnabled(False)
  848. if hasPosix64 and not WINDOWS:
  849. self.ui.ico_posix64.setPixmap(self.fIconYes)
  850. else:
  851. self.ui.ico_posix64.setPixmap(self.fIconNo)
  852. self.ui.ch_posix64.setEnabled(False)
  853. if hasWin32:
  854. self.ui.ico_win32.setPixmap(self.fIconYes)
  855. else:
  856. self.ui.ico_win32.setPixmap(self.fIconNo)
  857. self.ui.ch_win32.setEnabled(False)
  858. if hasWin64:
  859. self.ui.ico_win64.setPixmap(self.fIconYes)
  860. else:
  861. self.ui.ico_win64.setPixmap(self.fIconNo)
  862. self.ui.ch_win64.setEnabled(False)
  863. if haveLRDF:
  864. self.ui.ico_rdflib.setPixmap(self.fIconYes)
  865. else:
  866. self.ui.ico_rdflib.setPixmap(self.fIconNo)
  867. if WINDOWS:
  868. if kIs64bit:
  869. hasNonNative = hasWin32
  870. self.ui.ch_win64.setEnabled(False)
  871. self.ui.ch_win64.setVisible(False)
  872. self.ui.ico_win64.setVisible(False)
  873. self.ui.label_win64.setVisible(False)
  874. else:
  875. hasNonNative = hasWin64
  876. self.ui.ch_win32.setEnabled(False)
  877. self.ui.ch_win32.setVisible(False)
  878. self.ui.ico_win32.setVisible(False)
  879. self.ui.label_win32.setVisible(False)
  880. self.ui.ch_posix32.setEnabled(False)
  881. self.ui.ch_posix32.setVisible(False)
  882. self.ui.ch_posix64.setEnabled(False)
  883. self.ui.ch_posix64.setVisible(False)
  884. self.ui.ico_posix32.hide()
  885. self.ui.ico_posix64.hide()
  886. self.ui.label_posix32.hide()
  887. self.ui.label_posix64.hide()
  888. self.ui.ico_rdflib.hide()
  889. self.ui.label_rdflib.hide()
  890. else:
  891. if kIs64bit:
  892. hasNonNative = bool(hasPosix32 or hasWin32 or hasWin64)
  893. self.ui.ch_posix64.setEnabled(False)
  894. self.ui.ch_posix64.setVisible(False)
  895. self.ui.ico_posix64.setVisible(False)
  896. self.ui.label_posix64.setVisible(False)
  897. else:
  898. hasNonNative = bool(hasPosix64 or hasWin32 or hasWin64)
  899. self.ui.ch_posix32.setEnabled(False)
  900. self.ui.ch_posix32.setVisible(False)
  901. self.ui.ico_posix32.setVisible(False)
  902. self.ui.label_posix32.setVisible(False)
  903. if not (LINUX or hasWin32 or hasWin64):
  904. self.ui.ch_vst3.setEnabled(False)
  905. self.ui.ch_vst3.setVisible(False)
  906. if MACOS:
  907. self.setWindowModality(Qt.WindowModal)
  908. else:
  909. self.ui.ch_au.setEnabled(False)
  910. self.ui.ch_au.setVisible(False)
  911. if hasNative:
  912. self.ui.ico_native.setPixmap(self.fIconYes)
  913. else:
  914. self.ui.ico_native.setPixmap(self.fIconNo)
  915. self.ui.ch_native.setEnabled(False)
  916. self.ui.ch_sf2.setEnabled(False)
  917. if not hasNonNative:
  918. self.ui.ch_ladspa.setEnabled(False)
  919. self.ui.ch_dssi.setEnabled(False)
  920. self.ui.ch_vst.setEnabled(False)
  921. self.ui.ch_vst3.setEnabled(False)
  922. if not hasLoadedLv2Plugins:
  923. self.ui.lv2_restart_notice.hide()
  924. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  925. # -------------------------------------------------------------------------------------------------------------
  926. # Load settings
  927. self.loadSettings()
  928. # -------------------------------------------------------------------------------------------------------------
  929. # Hide bridges if disabled
  930. # NOTE: We Assume win32 carla build will not run win64 plugins
  931. if (WINDOWS and not kIs64bit) or not host.showPluginBridges:
  932. self.ui.ch_native.setChecked(True)
  933. self.ui.ch_native.setEnabled(False)
  934. self.ui.ch_native.setVisible(False)
  935. self.ui.ch_posix32.setChecked(False)
  936. self.ui.ch_posix32.setEnabled(False)
  937. self.ui.ch_posix32.setVisible(False)
  938. self.ui.ch_posix64.setChecked(False)
  939. self.ui.ch_posix64.setEnabled(False)
  940. self.ui.ch_posix64.setVisible(False)
  941. self.ui.ch_win32.setChecked(False)
  942. self.ui.ch_win32.setEnabled(False)
  943. self.ui.ch_win32.setVisible(False)
  944. self.ui.ch_win64.setChecked(False)
  945. self.ui.ch_win64.setEnabled(False)
  946. self.ui.ch_win64.setVisible(False)
  947. self.ui.ico_posix32.hide()
  948. self.ui.ico_posix64.hide()
  949. self.ui.ico_win32.hide()
  950. self.ui.ico_win64.hide()
  951. self.ui.label_posix32.hide()
  952. self.ui.label_posix64.hide()
  953. self.ui.label_win32.hide()
  954. self.ui.label_win64.hide()
  955. self.ui.sep_format.hide()
  956. elif not (WINDOWS or host.showWineBridges):
  957. self.ui.ch_win32.setChecked(False)
  958. self.ui.ch_win32.setEnabled(False)
  959. self.ui.ch_win32.setVisible(False)
  960. self.ui.ch_win64.setChecked(False)
  961. self.ui.ch_win64.setEnabled(False)
  962. self.ui.ch_win64.setVisible(False)
  963. self.ui.ico_win32.hide()
  964. self.ui.ico_win64.hide()
  965. self.ui.label_win32.hide()
  966. self.ui.label_win64.hide()
  967. # Disable non-supported features
  968. features = gCarla.utils.get_supported_features()
  969. if "sf2" not in features:
  970. self.ui.ch_sf2.setChecked(False)
  971. self.ui.ch_sf2.setEnabled(False)
  972. if MACOS and "juce" not in features:
  973. self.ui.ch_au.setChecked(False)
  974. self.ui.ch_au.setEnabled(False)
  975. # -------------------------------------------------------------------------------------------------------------
  976. # Resize to minimum size, as it's very likely UI stuff was hidden
  977. self.resize(self.minimumSize())
  978. # -------------------------------------------------------------------------------------------------------------
  979. # Set-up connections
  980. self.finished.connect(self.slot_saveSettings)
  981. self.ui.b_start.clicked.connect(self.slot_start)
  982. self.ui.b_skip.clicked.connect(self.slot_skip)
  983. self.ui.ch_native.clicked.connect(self.slot_checkTools)
  984. self.ui.ch_posix32.clicked.connect(self.slot_checkTools)
  985. self.ui.ch_posix64.clicked.connect(self.slot_checkTools)
  986. self.ui.ch_win32.clicked.connect(self.slot_checkTools)
  987. self.ui.ch_win64.clicked.connect(self.slot_checkTools)
  988. self.ui.ch_ladspa.clicked.connect(self.slot_checkTools)
  989. self.ui.ch_dssi.clicked.connect(self.slot_checkTools)
  990. self.ui.ch_lv2.clicked.connect(self.slot_checkTools)
  991. self.ui.ch_vst.clicked.connect(self.slot_checkTools)
  992. self.ui.ch_vst3.clicked.connect(self.slot_checkTools)
  993. self.ui.ch_au.clicked.connect(self.slot_checkTools)
  994. self.ui.ch_sf2.clicked.connect(self.slot_checkTools)
  995. self.ui.ch_sfz.clicked.connect(self.slot_checkTools)
  996. self.ui.ch_jsfx.clicked.connect(self.slot_checkTools)
  997. self.fThread.pluginLook.connect(self.slot_handlePluginLook)
  998. self.fThread.finished.connect(self.slot_handlePluginThreadFinished)
  999. # -------------------------------------------------------------------------------------------------------------
  1000. # Post-connect setup
  1001. self.slot_checkTools()
  1002. # -----------------------------------------------------------------------------------------------------------------
  1003. def loadSettings(self):
  1004. settings = QSafeSettings("falkTX", "CarlaRefresh2")
  1005. check = settings.value("PluginDatabase/SearchLADSPA", True, bool) and self.ui.ch_ladspa.isEnabled()
  1006. self.ui.ch_ladspa.setChecked(check)
  1007. check = settings.value("PluginDatabase/SearchDSSI", True, bool) and self.ui.ch_dssi.isEnabled()
  1008. self.ui.ch_dssi.setChecked(check)
  1009. check = settings.value("PluginDatabase/SearchLV2", True, bool) and self.ui.ch_lv2.isEnabled()
  1010. self.ui.ch_lv2.setChecked(check)
  1011. check = settings.value("PluginDatabase/SearchVST2", True, bool) and self.ui.ch_vst.isEnabled()
  1012. self.ui.ch_vst.setChecked(check)
  1013. check = settings.value("PluginDatabase/SearchVST3", True, bool) and self.ui.ch_vst3.isEnabled()
  1014. self.ui.ch_vst3.setChecked(check)
  1015. if MACOS:
  1016. check = settings.value("PluginDatabase/SearchAU", True, bool) and self.ui.ch_au.isEnabled()
  1017. else:
  1018. check = False
  1019. self.ui.ch_au.setChecked(check)
  1020. check = settings.value("PluginDatabase/SearchSF2", False, bool) and self.ui.ch_sf2.isEnabled()
  1021. self.ui.ch_sf2.setChecked(check)
  1022. check = settings.value("PluginDatabase/SearchSFZ", False, bool) and self.ui.ch_sfz.isEnabled()
  1023. self.ui.ch_sfz.setChecked(check)
  1024. check = settings.value("PluginDatabase/SearchJSFX", True, bool) and self.ui.ch_jsfx.isEnabled()
  1025. self.ui.ch_jsfx.setChecked(check)
  1026. check = settings.value("PluginDatabase/SearchNative", True, bool) and self.ui.ch_native.isEnabled()
  1027. self.ui.ch_native.setChecked(check)
  1028. check = settings.value("PluginDatabase/SearchPOSIX32", False, bool) and self.ui.ch_posix32.isEnabled()
  1029. self.ui.ch_posix32.setChecked(check)
  1030. check = settings.value("PluginDatabase/SearchPOSIX64", False, bool) and self.ui.ch_posix64.isEnabled()
  1031. self.ui.ch_posix64.setChecked(check)
  1032. check = settings.value("PluginDatabase/SearchWin32", False, bool) and self.ui.ch_win32.isEnabled()
  1033. self.ui.ch_win32.setChecked(check)
  1034. check = settings.value("PluginDatabase/SearchWin64", False, bool) and self.ui.ch_win64.isEnabled()
  1035. self.ui.ch_win64.setChecked(check)
  1036. self.ui.ch_do_checks.setChecked(settings.value("PluginDatabase/DoChecks", False, bool))
  1037. # -----------------------------------------------------------------------------------------------------------------
  1038. @pyqtSlot()
  1039. def slot_saveSettings(self):
  1040. settings = QSafeSettings("falkTX", "CarlaRefresh2")
  1041. settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked())
  1042. settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked())
  1043. settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked())
  1044. settings.setValue("PluginDatabase/SearchVST2", self.ui.ch_vst.isChecked())
  1045. settings.setValue("PluginDatabase/SearchVST3", self.ui.ch_vst3.isChecked())
  1046. settings.setValue("PluginDatabase/SearchAU", self.ui.ch_au.isChecked())
  1047. settings.setValue("PluginDatabase/SearchSF2", self.ui.ch_sf2.isChecked())
  1048. settings.setValue("PluginDatabase/SearchSFZ", self.ui.ch_sfz.isChecked())
  1049. settings.setValue("PluginDatabase/SearchJSFX", self.ui.ch_jsfx.isChecked())
  1050. settings.setValue("PluginDatabase/SearchNative", self.ui.ch_native.isChecked())
  1051. settings.setValue("PluginDatabase/SearchPOSIX32", self.ui.ch_posix32.isChecked())
  1052. settings.setValue("PluginDatabase/SearchPOSIX64", self.ui.ch_posix64.isChecked())
  1053. settings.setValue("PluginDatabase/SearchWin32", self.ui.ch_win32.isChecked())
  1054. settings.setValue("PluginDatabase/SearchWin64", self.ui.ch_win64.isChecked())
  1055. settings.setValue("PluginDatabase/DoChecks", self.ui.ch_do_checks.isChecked())
  1056. # -----------------------------------------------------------------------------------------------------------------
  1057. @pyqtSlot()
  1058. def slot_start(self):
  1059. self.ui.progressBar.setMinimum(0)
  1060. self.ui.progressBar.setMaximum(100)
  1061. self.ui.progressBar.setValue(0)
  1062. self.ui.b_start.setEnabled(False)
  1063. self.ui.b_skip.setVisible(True)
  1064. self.ui.b_close.setVisible(False)
  1065. self.ui.group_types.setEnabled(False)
  1066. self.ui.group_options.setEnabled(False)
  1067. if self.ui.ch_do_checks.isChecked():
  1068. gCarla.utils.unsetenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS")
  1069. else:
  1070. gCarla.utils.setenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS", "true")
  1071. native, posix32, posix64, win32, win64 = (self.ui.ch_native.isChecked(),
  1072. self.ui.ch_posix32.isChecked(), self.ui.ch_posix64.isChecked(),
  1073. self.ui.ch_win32.isChecked(), self.ui.ch_win64.isChecked())
  1074. ladspa, dssi, lv2, vst, vst3, au, sf2, sfz, jsfx = (self.ui.ch_ladspa.isChecked(), self.ui.ch_dssi.isChecked(),
  1075. self.ui.ch_lv2.isChecked(), self.ui.ch_vst.isChecked(),
  1076. self.ui.ch_vst3.isChecked(), self.ui.ch_au.isChecked(),
  1077. self.ui.ch_sf2.isChecked(), self.ui.ch_sfz.isChecked(),
  1078. self.ui.ch_jsfx.isChecked())
  1079. self.fThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64)
  1080. self.fThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, vst3, au, sf2, sfz, jsfx)
  1081. self.fThread.start()
  1082. # -----------------------------------------------------------------------------------------------------------------
  1083. @pyqtSlot()
  1084. def slot_skip(self):
  1085. killDiscovery()
  1086. # -----------------------------------------------------------------------------------------------------------------
  1087. @pyqtSlot()
  1088. def slot_checkTools(self):
  1089. enabled1 = bool(self.ui.ch_native.isChecked() or
  1090. self.ui.ch_posix32.isChecked() or self.ui.ch_posix64.isChecked() or
  1091. self.ui.ch_win32.isChecked() or self.ui.ch_win64.isChecked())
  1092. enabled2 = bool(self.ui.ch_ladspa.isChecked() or self.ui.ch_dssi.isChecked() or
  1093. self.ui.ch_lv2.isChecked() or self.ui.ch_vst.isChecked() or
  1094. self.ui.ch_vst3.isChecked() or self.ui.ch_au.isChecked() or
  1095. self.ui.ch_sf2.isChecked() or self.ui.ch_sfz.isChecked() or
  1096. self.ui.ch_jsfx.isChecked())
  1097. self.ui.b_start.setEnabled(enabled1 and enabled2)
  1098. # -----------------------------------------------------------------------------------------------------------------
  1099. @pyqtSlot(float, str)
  1100. def slot_handlePluginLook(self, percent, plugin):
  1101. self.ui.progressBar.setFormat("%s" % plugin)
  1102. self.ui.progressBar.setValue(int(percent))
  1103. # -----------------------------------------------------------------------------------------------------------------
  1104. @pyqtSlot()
  1105. def slot_handlePluginThreadFinished(self):
  1106. self.ui.progressBar.setMinimum(0)
  1107. self.ui.progressBar.setMaximum(1)
  1108. self.ui.progressBar.setValue(1)
  1109. self.ui.progressBar.setFormat(self.tr("Done"))
  1110. self.ui.b_start.setEnabled(True)
  1111. self.ui.b_skip.setVisible(False)
  1112. self.ui.b_close.setVisible(True)
  1113. self.ui.group_types.setEnabled(True)
  1114. self.ui.group_options.setEnabled(True)
  1115. # -----------------------------------------------------------------------------------------------------------------
  1116. def closeEvent(self, event):
  1117. if self.fThread.isRunning():
  1118. self.fThread.stop()
  1119. killDiscovery()
  1120. #self.fThread.terminate()
  1121. self.fThread.wait()
  1122. if self.fThread.hasSomethingChanged():
  1123. self.accept()
  1124. else:
  1125. self.reject()
  1126. QDialog.closeEvent(self, event)
  1127. # ---------------------------------------------------------------------------------------------------------------------
  1128. # Plugin Database Dialog
  1129. class PluginDatabaseW(QDialog):
  1130. TABLEWIDGET_ITEM_FAVORITE = 0
  1131. TABLEWIDGET_ITEM_NAME = 1
  1132. TABLEWIDGET_ITEM_LABEL = 2
  1133. TABLEWIDGET_ITEM_MAKER = 3
  1134. TABLEWIDGET_ITEM_BINARY = 4
  1135. def __init__(self, parent, host, useSystemIcons):
  1136. QDialog.__init__(self, parent)
  1137. self.host = host
  1138. self.ui = ui_carla_database.Ui_PluginDatabaseW()
  1139. self.ui.setupUi(self)
  1140. # To be changed by parent
  1141. self.hasLoadedLv2Plugins = False
  1142. # ----------------------------------------------------------------------------------------------------
  1143. # Internal stuff
  1144. self.fLastTableIndex = 0
  1145. self.fRetPlugin = None
  1146. self.fRealParent = parent
  1147. self.fFavoritePlugins = []
  1148. self.fFavoritePluginsChanged = False
  1149. self.fUseSystemIcons = useSystemIcons
  1150. self.fTrYes = self.tr("Yes")
  1151. self.fTrNo = self.tr("No")
  1152. self.fTrNative = self.tr("Native")
  1153. # ----------------------------------------------------------------------------------------------------
  1154. # Set-up GUI
  1155. self.ui.b_add.setEnabled(False)
  1156. self.addAction(self.ui.act_focus_search)
  1157. self.ui.act_focus_search.triggered.connect(self.slot_focusSearchFieldAndSelectAll)
  1158. if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32):
  1159. self.ui.ch_bridged.setText(self.tr("Bridged (64bit)"))
  1160. else:
  1161. self.ui.ch_bridged.setText(self.tr("Bridged (32bit)"))
  1162. if not (LINUX or MACOS):
  1163. self.ui.ch_bridged_wine.setChecked(False)
  1164. self.ui.ch_bridged_wine.setEnabled(False)
  1165. if MACOS:
  1166. self.setWindowModality(Qt.WindowModal)
  1167. else:
  1168. self.ui.ch_au.setChecked(False)
  1169. self.ui.ch_au.setEnabled(False)
  1170. self.ui.ch_au.setVisible(False)
  1171. self.ui.tab_info.tabBar().hide()
  1172. self.ui.tab_reqs.tabBar().hide()
  1173. # FIXME, why /2 needed?
  1174. self.ui.tab_info.setMinimumWidth(int(self.ui.la_id.width()/2) +
  1175. fontMetricsHorizontalAdvance(self.ui.l_id.fontMetrics(), "9999999999") + 6*3)
  1176. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  1177. # ----------------------------------------------------------------------------------------------------
  1178. # Load settings
  1179. self.loadSettings()
  1180. # ----------------------------------------------------------------------------------------------------
  1181. # Disable bridges if not enabled in settings
  1182. # NOTE: We Assume win32 carla build will not run win64 plugins
  1183. if (WINDOWS and not kIs64bit) or not host.showPluginBridges:
  1184. self.ui.ch_native.setChecked(True)
  1185. self.ui.ch_native.setEnabled(False)
  1186. self.ui.ch_native.setVisible(True)
  1187. self.ui.ch_bridged.setChecked(False)
  1188. self.ui.ch_bridged.setEnabled(False)
  1189. self.ui.ch_bridged.setVisible(False)
  1190. self.ui.ch_bridged_wine.setChecked(False)
  1191. self.ui.ch_bridged_wine.setEnabled(False)
  1192. self.ui.ch_bridged_wine.setVisible(False)
  1193. self.ui.l_arch.setVisible(False)
  1194. elif not host.showWineBridges:
  1195. self.ui.ch_bridged_wine.setChecked(False)
  1196. self.ui.ch_bridged_wine.setEnabled(False)
  1197. self.ui.ch_bridged_wine.setVisible(False)
  1198. # ----------------------------------------------------------------------------------------------------
  1199. # Set-up Icons
  1200. if useSystemIcons:
  1201. self.ui.b_add.setIcon(getIcon('list-add', 16, 'svgz'))
  1202. self.ui.b_cancel.setIcon(getIcon('dialog-cancel', 16, 'svgz'))
  1203. self.ui.b_clear_filters.setIcon(getIcon('edit-clear', 16, 'svgz'))
  1204. self.ui.b_refresh.setIcon(getIcon('view-refresh', 16, 'svgz'))
  1205. self.ui.tableWidget.horizontalHeaderItem(self.TABLEWIDGET_ITEM_FAVORITE).setIcon(getIcon('bookmarks', 16, 'svgz'))
  1206. # ----------------------------------------------------------------------------------------------------
  1207. # Set-up connections
  1208. self.finished.connect(self.slot_saveSettings)
  1209. self.ui.b_add.clicked.connect(self.slot_addPlugin)
  1210. self.ui.b_cancel.clicked.connect(self.reject)
  1211. self.ui.b_refresh.clicked.connect(self.slot_refreshPlugins)
  1212. self.ui.b_clear_filters.clicked.connect(self.slot_clearFilters)
  1213. self.ui.lineEdit.textChanged.connect(self.slot_checkFilters)
  1214. self.ui.tableWidget.currentCellChanged.connect(self.slot_checkPlugin)
  1215. self.ui.tableWidget.cellClicked.connect(self.slot_cellClicked)
  1216. self.ui.tableWidget.cellDoubleClicked.connect(self.slot_cellDoubleClicked)
  1217. self.ui.ch_internal.clicked.connect(self.slot_checkFilters)
  1218. self.ui.ch_ladspa.clicked.connect(self.slot_checkFilters)
  1219. self.ui.ch_dssi.clicked.connect(self.slot_checkFilters)
  1220. self.ui.ch_lv2.clicked.connect(self.slot_checkFilters)
  1221. self.ui.ch_vst.clicked.connect(self.slot_checkFilters)
  1222. self.ui.ch_vst3.clicked.connect(self.slot_checkFilters)
  1223. self.ui.ch_au.clicked.connect(self.slot_checkFilters)
  1224. self.ui.ch_jsfx.clicked.connect(self.slot_checkFilters)
  1225. self.ui.ch_kits.clicked.connect(self.slot_checkFilters)
  1226. self.ui.ch_effects.clicked.connect(self.slot_checkFilters)
  1227. self.ui.ch_instruments.clicked.connect(self.slot_checkFilters)
  1228. self.ui.ch_midi.clicked.connect(self.slot_checkFilters)
  1229. self.ui.ch_other.clicked.connect(self.slot_checkFilters)
  1230. self.ui.ch_native.clicked.connect(self.slot_checkFilters)
  1231. self.ui.ch_bridged.clicked.connect(self.slot_checkFilters)
  1232. self.ui.ch_bridged_wine.clicked.connect(self.slot_checkFilters)
  1233. self.ui.ch_favorites.clicked.connect(self.slot_checkFilters)
  1234. self.ui.ch_rtsafe.clicked.connect(self.slot_checkFilters)
  1235. self.ui.ch_cv.clicked.connect(self.slot_checkFilters)
  1236. self.ui.ch_gui.clicked.connect(self.slot_checkFilters)
  1237. self.ui.ch_inline_display.clicked.connect(self.slot_checkFilters)
  1238. self.ui.ch_stereo.clicked.connect(self.slot_checkFilters)
  1239. self.ui.ch_cat_all.clicked.connect(self.slot_checkFiltersCategoryAll)
  1240. self.ui.ch_cat_delay.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1241. self.ui.ch_cat_distortion.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1242. self.ui.ch_cat_dynamics.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1243. self.ui.ch_cat_eq.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1244. self.ui.ch_cat_filter.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1245. self.ui.ch_cat_modulator.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1246. self.ui.ch_cat_synth.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1247. self.ui.ch_cat_utility.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1248. self.ui.ch_cat_other.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1249. # ----------------------------------------------------------------------------------------------------
  1250. # Post-connect setup
  1251. self._reAddPlugins()
  1252. self.slot_focusSearchFieldAndSelectAll()
  1253. # --------------------------------------------------------------------------------------------------------
  1254. @pyqtSlot(int, int)
  1255. def slot_cellClicked(self, row, column):
  1256. if column == self.TABLEWIDGET_ITEM_FAVORITE:
  1257. widget = self.ui.tableWidget.item(row, self.TABLEWIDGET_ITEM_FAVORITE)
  1258. plugin = self.ui.tableWidget.item(row, self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+1)
  1259. plugin = self._createFavoritePluginDict(plugin)
  1260. if widget.checkState() == Qt.Checked:
  1261. if not plugin in self.fFavoritePlugins:
  1262. self.fFavoritePlugins.append(plugin)
  1263. self.fFavoritePluginsChanged = True
  1264. else:
  1265. try:
  1266. self.fFavoritePlugins.remove(plugin)
  1267. self.fFavoritePluginsChanged = True
  1268. except ValueError:
  1269. pass
  1270. @pyqtSlot(int, int)
  1271. def slot_cellDoubleClicked(self, row, column):
  1272. if column != self.TABLEWIDGET_ITEM_FAVORITE:
  1273. self.slot_addPlugin()
  1274. @pyqtSlot()
  1275. def slot_focusSearchFieldAndSelectAll(self):
  1276. self.ui.lineEdit.setFocus()
  1277. self.ui.lineEdit.selectAll()
  1278. @pyqtSlot()
  1279. def slot_addPlugin(self):
  1280. if self.ui.tableWidget.currentRow() >= 0:
  1281. self.fRetPlugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(),
  1282. self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+1)
  1283. self.accept()
  1284. else:
  1285. self.reject()
  1286. @pyqtSlot(int)
  1287. def slot_checkPlugin(self, row):
  1288. if row >= 0:
  1289. self.ui.b_add.setEnabled(True)
  1290. plugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(),
  1291. self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+1)
  1292. isSynth = bool(plugin['hints'] & PLUGIN_IS_SYNTH)
  1293. isEffect = bool(plugin['audio.ins'] > 0 < plugin['audio.outs'] and not isSynth)
  1294. isMidi = bool(plugin['audio.ins'] == 0 and plugin['audio.outs'] == 0 and plugin['midi.ins'] > 0 < plugin['midi.outs'])
  1295. isKit = bool(plugin['type'] in (PLUGIN_SF2, PLUGIN_SFZ))
  1296. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  1297. if isSynth:
  1298. ptype = "Instrument"
  1299. elif isEffect:
  1300. ptype = "Effect"
  1301. elif isMidi:
  1302. ptype = "MIDI Plugin"
  1303. else:
  1304. ptype = "Other"
  1305. if plugin['build'] == BINARY_NATIVE:
  1306. parch = self.fTrNative
  1307. elif plugin['build'] == BINARY_POSIX32:
  1308. parch = "posix32"
  1309. elif plugin['build'] == BINARY_POSIX64:
  1310. parch = "posix64"
  1311. elif plugin['build'] == BINARY_WIN32:
  1312. parch = "win32"
  1313. elif plugin['build'] == BINARY_WIN64:
  1314. parch = "win64"
  1315. elif plugin['build'] == BINARY_OTHER:
  1316. parch = self.tr("Other")
  1317. elif plugin['build'] == BINARY_WIN32:
  1318. parch = self.tr("Unknown")
  1319. self.ui.l_format.setText(getPluginTypeAsString(plugin['type']))
  1320. self.ui.l_type.setText(ptype)
  1321. self.ui.l_arch.setText(parch)
  1322. self.ui.l_id.setText(str(plugin['uniqueId']))
  1323. self.ui.l_ains.setText(str(plugin['audio.ins']))
  1324. self.ui.l_aouts.setText(str(plugin['audio.outs']))
  1325. self.ui.l_cvins.setText(str(plugin['cv.ins']))
  1326. self.ui.l_cvouts.setText(str(plugin['cv.outs']))
  1327. self.ui.l_mins.setText(str(plugin['midi.ins']))
  1328. self.ui.l_mouts.setText(str(plugin['midi.outs']))
  1329. self.ui.l_pins.setText(str(plugin['parameters.ins']))
  1330. self.ui.l_pouts.setText(str(plugin['parameters.outs']))
  1331. self.ui.l_gui.setText(self.fTrYes if plugin['hints'] & PLUGIN_HAS_CUSTOM_UI else self.fTrNo)
  1332. self.ui.l_idisp.setText(self.fTrYes if plugin['hints'] & PLUGIN_HAS_INLINE_DISPLAY else self.fTrNo)
  1333. self.ui.l_bridged.setText(self.fTrYes if plugin['hints'] & PLUGIN_IS_BRIDGE else self.fTrNo)
  1334. self.ui.l_synth.setText(self.fTrYes if isSynth else self.fTrNo)
  1335. else:
  1336. self.ui.b_add.setEnabled(False)
  1337. self.ui.l_format.setText("---")
  1338. self.ui.l_type.setText("---")
  1339. self.ui.l_arch.setText("---")
  1340. self.ui.l_id.setText("---")
  1341. self.ui.l_ains.setText("---")
  1342. self.ui.l_aouts.setText("---")
  1343. self.ui.l_cvins.setText("---")
  1344. self.ui.l_cvouts.setText("---")
  1345. self.ui.l_mins.setText("---")
  1346. self.ui.l_mouts.setText("---")
  1347. self.ui.l_pins.setText("---")
  1348. self.ui.l_pouts.setText("---")
  1349. self.ui.l_gui.setText("---")
  1350. self.ui.l_idisp.setText("---")
  1351. self.ui.l_bridged.setText("---")
  1352. self.ui.l_synth.setText("---")
  1353. @pyqtSlot()
  1354. def slot_checkFilters(self):
  1355. self._checkFilters()
  1356. @pyqtSlot(bool)
  1357. def slot_checkFiltersCategoryAll(self, clicked):
  1358. self.ui.ch_cat_delay.setChecked(not clicked)
  1359. self.ui.ch_cat_distortion.setChecked(not clicked)
  1360. self.ui.ch_cat_dynamics.setChecked(not clicked)
  1361. self.ui.ch_cat_eq.setChecked(not clicked)
  1362. self.ui.ch_cat_filter.setChecked(not clicked)
  1363. self.ui.ch_cat_modulator.setChecked(not clicked)
  1364. self.ui.ch_cat_synth.setChecked(not clicked)
  1365. self.ui.ch_cat_utility.setChecked(not clicked)
  1366. self.ui.ch_cat_other.setChecked(not clicked)
  1367. self._checkFilters()
  1368. @pyqtSlot(bool)
  1369. def slot_checkFiltersCategorySpecific(self, clicked):
  1370. if clicked:
  1371. self.ui.ch_cat_all.setChecked(False)
  1372. elif not (self.ui.ch_cat_delay.isChecked() or
  1373. self.ui.ch_cat_distortion.isChecked() or
  1374. self.ui.ch_cat_dynamics.isChecked() or
  1375. self.ui.ch_cat_eq.isChecked() or
  1376. self.ui.ch_cat_filter.isChecked() or
  1377. self.ui.ch_cat_modulator.isChecked() or
  1378. self.ui.ch_cat_synth.isChecked() or
  1379. self.ui.ch_cat_utility.isChecked() or
  1380. self.ui.ch_cat_other.isChecked()):
  1381. self.ui.ch_cat_all.setChecked(True)
  1382. self._checkFilters()
  1383. @pyqtSlot()
  1384. def slot_refreshPlugins(self):
  1385. if PluginRefreshW(self, self.host, self.fUseSystemIcons, self.hasLoadedLv2Plugins).exec_():
  1386. self._reAddPlugins()
  1387. if self.fRealParent:
  1388. self.fRealParent.setLoadRDFsNeeded()
  1389. @pyqtSlot()
  1390. def slot_clearFilters(self):
  1391. self.blockSignals(True)
  1392. self.ui.ch_internal.setChecked(True)
  1393. self.ui.ch_ladspa.setChecked(True)
  1394. self.ui.ch_dssi.setChecked(True)
  1395. self.ui.ch_lv2.setChecked(True)
  1396. self.ui.ch_vst.setChecked(True)
  1397. self.ui.ch_jsfx.setChecked(True)
  1398. self.ui.ch_kits.setChecked(True)
  1399. self.ui.ch_instruments.setChecked(True)
  1400. self.ui.ch_effects.setChecked(True)
  1401. self.ui.ch_midi.setChecked(True)
  1402. self.ui.ch_other.setChecked(True)
  1403. self.ui.ch_native.setChecked(True)
  1404. self.ui.ch_bridged.setChecked(False)
  1405. self.ui.ch_bridged_wine.setChecked(False)
  1406. self.ui.ch_favorites.setChecked(False)
  1407. self.ui.ch_rtsafe.setChecked(False)
  1408. self.ui.ch_stereo.setChecked(False)
  1409. self.ui.ch_cv.setChecked(False)
  1410. self.ui.ch_gui.setChecked(False)
  1411. self.ui.ch_inline_display.setChecked(False)
  1412. if self.ui.ch_vst3.isEnabled():
  1413. self.ui.ch_vst3.setChecked(True)
  1414. if self.ui.ch_au.isEnabled():
  1415. self.ui.ch_au.setChecked(True)
  1416. self.ui.ch_cat_all.setChecked(True)
  1417. self.ui.ch_cat_delay.setChecked(False)
  1418. self.ui.ch_cat_distortion.setChecked(False)
  1419. self.ui.ch_cat_dynamics.setChecked(False)
  1420. self.ui.ch_cat_eq.setChecked(False)
  1421. self.ui.ch_cat_filter.setChecked(False)
  1422. self.ui.ch_cat_modulator.setChecked(False)
  1423. self.ui.ch_cat_synth.setChecked(False)
  1424. self.ui.ch_cat_utility.setChecked(False)
  1425. self.ui.ch_cat_other.setChecked(False)
  1426. self.ui.lineEdit.clear()
  1427. self.blockSignals(False)
  1428. self._checkFilters()
  1429. # --------------------------------------------------------------------------------------------------------
  1430. @pyqtSlot()
  1431. def slot_saveSettings(self):
  1432. settings = QSafeSettings("falkTX", "CarlaDatabase2")
  1433. settings.setValue("PluginDatabase/Geometry", self.saveGeometry())
  1434. settings.setValue("PluginDatabase/TableGeometry_6", self.ui.tableWidget.horizontalHeader().saveState())
  1435. settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked())
  1436. settings.setValue("PluginDatabase/ShowInstruments", self.ui.ch_instruments.isChecked())
  1437. settings.setValue("PluginDatabase/ShowMIDI", self.ui.ch_midi.isChecked())
  1438. settings.setValue("PluginDatabase/ShowOther", self.ui.ch_other.isChecked())
  1439. settings.setValue("PluginDatabase/ShowInternal", self.ui.ch_internal.isChecked())
  1440. settings.setValue("PluginDatabase/ShowLADSPA", self.ui.ch_ladspa.isChecked())
  1441. settings.setValue("PluginDatabase/ShowDSSI", self.ui.ch_dssi.isChecked())
  1442. settings.setValue("PluginDatabase/ShowLV2", self.ui.ch_lv2.isChecked())
  1443. settings.setValue("PluginDatabase/ShowVST2", self.ui.ch_vst.isChecked())
  1444. settings.setValue("PluginDatabase/ShowVST3", self.ui.ch_vst3.isChecked())
  1445. settings.setValue("PluginDatabase/ShowAU", self.ui.ch_au.isChecked())
  1446. settings.setValue("PluginDatabase/ShowJSFX", self.ui.ch_jsfx.isChecked())
  1447. settings.setValue("PluginDatabase/ShowKits", self.ui.ch_kits.isChecked())
  1448. settings.setValue("PluginDatabase/ShowNative", self.ui.ch_native.isChecked())
  1449. settings.setValue("PluginDatabase/ShowBridged", self.ui.ch_bridged.isChecked())
  1450. settings.setValue("PluginDatabase/ShowBridgedWine", self.ui.ch_bridged_wine.isChecked())
  1451. settings.setValue("PluginDatabase/ShowFavorites", self.ui.ch_favorites.isChecked())
  1452. settings.setValue("PluginDatabase/ShowRtSafe", self.ui.ch_rtsafe.isChecked())
  1453. settings.setValue("PluginDatabase/ShowHasCV", self.ui.ch_cv.isChecked())
  1454. settings.setValue("PluginDatabase/ShowHasGUI", self.ui.ch_gui.isChecked())
  1455. settings.setValue("PluginDatabase/ShowHasInlineDisplay", self.ui.ch_inline_display.isChecked())
  1456. settings.setValue("PluginDatabase/ShowStereoOnly", self.ui.ch_stereo.isChecked())
  1457. settings.setValue("PluginDatabase/SearchText", self.ui.lineEdit.text())
  1458. if self.ui.ch_cat_all.isChecked():
  1459. settings.setValue("PluginDatabase/ShowCategory", "all")
  1460. else:
  1461. categoryhash = ""
  1462. if self.ui.ch_cat_delay.isChecked():
  1463. categoryhash += ":delay"
  1464. if self.ui.ch_cat_distortion.isChecked():
  1465. categoryhash += ":distortion"
  1466. if self.ui.ch_cat_dynamics.isChecked():
  1467. categoryhash += ":dynamics"
  1468. if self.ui.ch_cat_eq.isChecked():
  1469. categoryhash += ":eq"
  1470. if self.ui.ch_cat_filter.isChecked():
  1471. categoryhash += ":filter"
  1472. if self.ui.ch_cat_modulator.isChecked():
  1473. categoryhash += ":modulator"
  1474. if self.ui.ch_cat_synth.isChecked():
  1475. categoryhash += ":synth"
  1476. if self.ui.ch_cat_utility.isChecked():
  1477. categoryhash += ":utility"
  1478. if self.ui.ch_cat_other.isChecked():
  1479. categoryhash += ":other"
  1480. if categoryhash:
  1481. categoryhash += ":"
  1482. settings.setValue("PluginDatabase/ShowCategory", categoryhash)
  1483. if self.fFavoritePluginsChanged:
  1484. settings.setValue("PluginDatabase/Favorites", self.fFavoritePlugins)
  1485. # --------------------------------------------------------------------------------------------------------
  1486. def loadSettings(self):
  1487. settings = QSafeSettings("falkTX", "CarlaDatabase2")
  1488. self.fFavoritePlugins = settings.value("PluginDatabase/Favorites", [], list)
  1489. self.fFavoritePluginsChanged = False
  1490. self.restoreGeometry(settings.value("PluginDatabase/Geometry", QByteArray(), QByteArray))
  1491. self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, bool))
  1492. self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, bool))
  1493. self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, bool))
  1494. self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, bool))
  1495. self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, bool))
  1496. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, bool))
  1497. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, bool))
  1498. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, bool))
  1499. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST2", True, bool))
  1500. self.ui.ch_vst3.setChecked(settings.value("PluginDatabase/ShowVST3", (MACOS or WINDOWS), bool))
  1501. self.ui.ch_au.setChecked(settings.value("PluginDatabase/ShowAU", MACOS, bool))
  1502. self.ui.ch_jsfx.setChecked(settings.value("PluginDatabase/ShowJSFX", True, bool))
  1503. self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, bool))
  1504. self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, bool))
  1505. self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, bool))
  1506. self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, bool))
  1507. self.ui.ch_favorites.setChecked(settings.value("PluginDatabase/ShowFavorites", False, bool))
  1508. self.ui.ch_rtsafe.setChecked(settings.value("PluginDatabase/ShowRtSafe", False, bool))
  1509. self.ui.ch_cv.setChecked(settings.value("PluginDatabase/ShowHasCV", False, bool))
  1510. self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, bool))
  1511. self.ui.ch_inline_display.setChecked(settings.value("PluginDatabase/ShowHasInlineDisplay", False, bool))
  1512. self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, bool))
  1513. self.ui.lineEdit.setText(settings.value("PluginDatabase/SearchText", "", str))
  1514. categoryhash = settings.value("PluginDatabase/ShowCategory", "all", str)
  1515. if categoryhash == "all" or len(categoryhash) < 2:
  1516. self.ui.ch_cat_all.setChecked(True)
  1517. self.ui.ch_cat_delay.setChecked(False)
  1518. self.ui.ch_cat_distortion.setChecked(False)
  1519. self.ui.ch_cat_dynamics.setChecked(False)
  1520. self.ui.ch_cat_eq.setChecked(False)
  1521. self.ui.ch_cat_filter.setChecked(False)
  1522. self.ui.ch_cat_modulator.setChecked(False)
  1523. self.ui.ch_cat_synth.setChecked(False)
  1524. self.ui.ch_cat_utility.setChecked(False)
  1525. self.ui.ch_cat_other.setChecked(False)
  1526. else:
  1527. self.ui.ch_cat_all.setChecked(False)
  1528. self.ui.ch_cat_delay.setChecked(":delay:" in categoryhash)
  1529. self.ui.ch_cat_distortion.setChecked(":distortion:" in categoryhash)
  1530. self.ui.ch_cat_dynamics.setChecked(":dynamics:" in categoryhash)
  1531. self.ui.ch_cat_eq.setChecked(":eq:" in categoryhash)
  1532. self.ui.ch_cat_filter.setChecked(":filter:" in categoryhash)
  1533. self.ui.ch_cat_modulator.setChecked(":modulator:" in categoryhash)
  1534. self.ui.ch_cat_synth.setChecked(":synth:" in categoryhash)
  1535. self.ui.ch_cat_utility.setChecked(":utility:" in categoryhash)
  1536. self.ui.ch_cat_other.setChecked(":other:" in categoryhash)
  1537. tableGeometry = settings.value("PluginDatabase/TableGeometry_6", QByteArray(), QByteArray)
  1538. horizontalHeader = self.ui.tableWidget.horizontalHeader()
  1539. if not tableGeometry.isNull():
  1540. horizontalHeader.restoreState(tableGeometry)
  1541. else:
  1542. horizontalHeader.setSectionResizeMode(self.TABLEWIDGET_ITEM_FAVORITE, QHeaderView.Fixed)
  1543. self.ui.tableWidget.setColumnWidth(self.TABLEWIDGET_ITEM_FAVORITE, 24)
  1544. self.ui.tableWidget.setColumnWidth(self.TABLEWIDGET_ITEM_NAME, 250)
  1545. self.ui.tableWidget.setColumnWidth(self.TABLEWIDGET_ITEM_LABEL, 200)
  1546. self.ui.tableWidget.setColumnWidth(self.TABLEWIDGET_ITEM_MAKER, 150)
  1547. self.ui.tableWidget.sortByColumn(self.TABLEWIDGET_ITEM_NAME, Qt.AscendingOrder)
  1548. # --------------------------------------------------------------------------------------------------------
  1549. def _createFavoritePluginDict(self, plugin):
  1550. return {
  1551. 'name' : plugin['name'],
  1552. 'build' : plugin['build'],
  1553. 'type' : plugin['type'],
  1554. 'filename': plugin['filename'],
  1555. 'label' : plugin['label'],
  1556. 'uniqueId': plugin['uniqueId'],
  1557. }
  1558. def _checkFilters(self):
  1559. text = self.ui.lineEdit.text().lower()
  1560. hideEffects = not self.ui.ch_effects.isChecked()
  1561. hideInstruments = not self.ui.ch_instruments.isChecked()
  1562. hideMidi = not self.ui.ch_midi.isChecked()
  1563. hideOther = not self.ui.ch_other.isChecked()
  1564. hideInternal = not self.ui.ch_internal.isChecked()
  1565. hideLadspa = not self.ui.ch_ladspa.isChecked()
  1566. hideDssi = not self.ui.ch_dssi.isChecked()
  1567. hideLV2 = not self.ui.ch_lv2.isChecked()
  1568. hideVST2 = not self.ui.ch_vst.isChecked()
  1569. hideVST3 = not self.ui.ch_vst3.isChecked()
  1570. hideAU = not self.ui.ch_au.isChecked()
  1571. hideJSFX = not self.ui.ch_jsfx.isChecked()
  1572. hideKits = not self.ui.ch_kits.isChecked()
  1573. hideNative = not self.ui.ch_native.isChecked()
  1574. hideBridged = not self.ui.ch_bridged.isChecked()
  1575. hideBridgedWine = not self.ui.ch_bridged_wine.isChecked()
  1576. hideNonFavs = self.ui.ch_favorites.isChecked()
  1577. hideNonRtSafe = self.ui.ch_rtsafe.isChecked()
  1578. hideNonCV = self.ui.ch_cv.isChecked()
  1579. hideNonGui = self.ui.ch_gui.isChecked()
  1580. hideNonIDisp = self.ui.ch_inline_display.isChecked()
  1581. hideNonStereo = self.ui.ch_stereo.isChecked()
  1582. if HAIKU or LINUX or MACOS:
  1583. nativeBins = [BINARY_POSIX32, BINARY_POSIX64]
  1584. wineBins = [BINARY_WIN32, BINARY_WIN64]
  1585. elif WINDOWS:
  1586. nativeBins = [BINARY_WIN32, BINARY_WIN64]
  1587. wineBins = []
  1588. else:
  1589. nativeBins = []
  1590. wineBins = []
  1591. self.ui.tableWidget.setRowCount(self.fLastTableIndex)
  1592. for i in range(self.fLastTableIndex):
  1593. plugin = self.ui.tableWidget.item(i, self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+1)
  1594. ptext = self.ui.tableWidget.item(i, self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+2)
  1595. aIns = plugin['audio.ins']
  1596. aOuts = plugin['audio.outs']
  1597. cvIns = plugin['cv.ins']
  1598. cvOuts = plugin['cv.outs']
  1599. mIns = plugin['midi.ins']
  1600. mOuts = plugin['midi.outs']
  1601. phints = plugin['hints']
  1602. ptype = plugin['type']
  1603. categ = plugin['category']
  1604. isSynth = bool(phints & PLUGIN_IS_SYNTH)
  1605. isEffect = bool(aIns > 0 < aOuts and not isSynth)
  1606. isMidi = bool(aIns == 0 and aOuts == 0 and mIns > 0 < mOuts)
  1607. isKit = bool(ptype in (PLUGIN_SF2, PLUGIN_SFZ))
  1608. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  1609. isNative = bool(plugin['build'] == BINARY_NATIVE)
  1610. isRtSafe = bool(phints & PLUGIN_IS_RTSAFE)
  1611. isStereo = bool(aIns == 2 and aOuts == 2) or (isSynth and aOuts == 2)
  1612. hasCV = bool(cvIns + cvOuts > 0)
  1613. hasGui = bool(phints & PLUGIN_HAS_CUSTOM_UI)
  1614. hasIDisp = bool(phints & PLUGIN_HAS_INLINE_DISPLAY)
  1615. isBridged = bool(not isNative and plugin['build'] in nativeBins)
  1616. isBridgedWine = bool(not isNative and plugin['build'] in wineBins)
  1617. if hideEffects and isEffect:
  1618. self.ui.tableWidget.hideRow(i)
  1619. elif hideInstruments and isSynth:
  1620. self.ui.tableWidget.hideRow(i)
  1621. elif hideMidi and isMidi:
  1622. self.ui.tableWidget.hideRow(i)
  1623. elif hideOther and isOther:
  1624. self.ui.tableWidget.hideRow(i)
  1625. elif hideKits and isKit:
  1626. self.ui.tableWidget.hideRow(i)
  1627. elif hideInternal and ptype == PLUGIN_INTERNAL:
  1628. self.ui.tableWidget.hideRow(i)
  1629. elif hideLadspa and ptype == PLUGIN_LADSPA:
  1630. self.ui.tableWidget.hideRow(i)
  1631. elif hideDssi and ptype == PLUGIN_DSSI:
  1632. self.ui.tableWidget.hideRow(i)
  1633. elif hideLV2 and ptype == PLUGIN_LV2:
  1634. self.ui.tableWidget.hideRow(i)
  1635. elif hideVST2 and ptype == PLUGIN_VST2:
  1636. self.ui.tableWidget.hideRow(i)
  1637. elif hideVST3 and ptype == PLUGIN_VST3:
  1638. self.ui.tableWidget.hideRow(i)
  1639. elif hideAU and ptype == PLUGIN_AU:
  1640. self.ui.tableWidget.hideRow(i)
  1641. elif hideJSFX and ptype == PLUGIN_JSFX:
  1642. self.ui.tableWidget.hideRow(i)
  1643. elif hideNative and isNative:
  1644. self.ui.tableWidget.hideRow(i)
  1645. elif hideBridged and isBridged:
  1646. self.ui.tableWidget.hideRow(i)
  1647. elif hideBridgedWine and isBridgedWine:
  1648. self.ui.tableWidget.hideRow(i)
  1649. elif hideNonRtSafe and not isRtSafe:
  1650. self.ui.tableWidget.hideRow(i)
  1651. elif hideNonCV and not hasCV:
  1652. self.ui.tableWidget.hideRow(i)
  1653. elif hideNonGui and not hasGui:
  1654. self.ui.tableWidget.hideRow(i)
  1655. elif hideNonIDisp and not hasIDisp:
  1656. self.ui.tableWidget.hideRow(i)
  1657. elif hideNonStereo and not isStereo:
  1658. self.ui.tableWidget.hideRow(i)
  1659. elif text and not all(t in ptext for t in text.strip().split(' ')):
  1660. self.ui.tableWidget.hideRow(i)
  1661. elif hideNonFavs and self._createFavoritePluginDict(plugin) not in self.fFavoritePlugins:
  1662. self.ui.tableWidget.hideRow(i)
  1663. elif (self.ui.ch_cat_all.isChecked() or
  1664. (self.ui.ch_cat_delay.isChecked() and categ == "delay") or
  1665. (self.ui.ch_cat_distortion.isChecked() and categ == "distortion") or
  1666. (self.ui.ch_cat_dynamics.isChecked() and categ == "dynamics") or
  1667. (self.ui.ch_cat_eq.isChecked() and categ == "eq") or
  1668. (self.ui.ch_cat_filter.isChecked() and categ == "filter") or
  1669. (self.ui.ch_cat_modulator.isChecked() and categ == "modulator") or
  1670. (self.ui.ch_cat_synth.isChecked() and categ == "synth") or
  1671. (self.ui.ch_cat_utility.isChecked() and categ == "utility") or
  1672. (self.ui.ch_cat_other.isChecked() and categ == "other")):
  1673. self.ui.tableWidget.showRow(i)
  1674. else:
  1675. self.ui.tableWidget.hideRow(i)
  1676. # --------------------------------------------------------------------------------------------------------
  1677. def _addPluginToTable(self, plugin, ptype):
  1678. if plugin['API'] != PLUGIN_QUERY_API_VERSION:
  1679. return
  1680. if ptype in (self.tr("Internal"), "LV2", "SF2", "SFZ", "JSFX"):
  1681. plugin['build'] = BINARY_NATIVE
  1682. index = self.fLastTableIndex
  1683. isFav = bool(self._createFavoritePluginDict(plugin) in self.fFavoritePlugins)
  1684. favItem = QTableWidgetItem()
  1685. favItem.setCheckState(Qt.Checked if isFav else Qt.Unchecked)
  1686. favItem.setText(" " if isFav else " ")
  1687. pluginText = (plugin['name']+plugin['label']+plugin['maker']+plugin['filename']).lower()
  1688. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_FAVORITE, favItem)
  1689. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_NAME, QTableWidgetItem(plugin['name']))
  1690. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_LABEL, QTableWidgetItem(plugin['label']))
  1691. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_MAKER, QTableWidgetItem(plugin['maker']))
  1692. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_BINARY, QTableWidgetItem(os.path.basename(plugin['filename'])))
  1693. self.ui.tableWidget.item(index, self.TABLEWIDGET_ITEM_NAME).setData(Qt.UserRole+1, plugin)
  1694. self.ui.tableWidget.item(index, self.TABLEWIDGET_ITEM_NAME).setData(Qt.UserRole+2, pluginText)
  1695. self.fLastTableIndex += 1
  1696. # --------------------------------------------------------------------------------------------------------
  1697. def _reAddInternalHelper(self, settingsDB, ptype, path):
  1698. if ptype == PLUGIN_INTERNAL:
  1699. ptypeStr = "Internal"
  1700. ptypeStrTr = self.tr("Internal")
  1701. elif ptype == PLUGIN_LV2:
  1702. ptypeStr = "LV2"
  1703. ptypeStrTr = ptypeStr
  1704. elif ptype == PLUGIN_AU:
  1705. ptypeStr = "AU"
  1706. ptypeStrTr = ptypeStr
  1707. #elif ptype == PLUGIN_SFZ:
  1708. #ptypeStr = "SFZ"
  1709. #ptypeStrTr = ptypeStr
  1710. # TODO(jsfx) what to do here?
  1711. else:
  1712. return 0
  1713. plugins = settingsDB.value("Plugins/" + ptypeStr, [], list)
  1714. pluginCount = settingsDB.value("PluginCount/" + ptypeStr, 0, int)
  1715. if ptype == PLUGIN_AU:
  1716. gCarla.utils.juce_init()
  1717. pluginCountNew = gCarla.utils.get_cached_plugin_count(ptype, path)
  1718. if pluginCountNew != pluginCount or len(plugins) != pluginCount or (len(plugins) > 0 and plugins[0]['API'] != PLUGIN_QUERY_API_VERSION):
  1719. plugins = []
  1720. pluginCount = pluginCountNew
  1721. QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50)
  1722. if ptype == PLUGIN_AU:
  1723. gCarla.utils.juce_idle()
  1724. for i in range(pluginCountNew):
  1725. descInfo = gCarla.utils.get_cached_plugin_info(ptype, i)
  1726. if not descInfo['valid']:
  1727. continue
  1728. info = checkPluginCached(descInfo, ptype)
  1729. plugins.append(info)
  1730. if i % 50 == 0:
  1731. QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50)
  1732. if ptype == PLUGIN_AU:
  1733. gCarla.utils.juce_idle()
  1734. settingsDB.setValue("Plugins/" + ptypeStr, plugins)
  1735. settingsDB.setValue("PluginCount/" + ptypeStr, pluginCount)
  1736. if ptype == PLUGIN_AU:
  1737. gCarla.utils.juce_cleanup()
  1738. # prepare rows in advance
  1739. self.ui.tableWidget.setRowCount(self.fLastTableIndex + len(plugins))
  1740. for plugin in plugins:
  1741. self._addPluginToTable(plugin, ptypeStrTr)
  1742. return pluginCount
  1743. def _reAddPlugins(self):
  1744. settingsDB = QSafeSettings("falkTX", "CarlaPlugins5")
  1745. self.fLastTableIndex = 0
  1746. self.ui.tableWidget.setSortingEnabled(False)
  1747. self.ui.tableWidget.clearContents()
  1748. settings = QSafeSettings("falkTX", "Carla2")
  1749. LV2_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list))
  1750. del settings
  1751. # ----------------------------------------------------------------------------------------------------
  1752. # plugins handled through backend
  1753. internalCount = self._reAddInternalHelper(settingsDB, PLUGIN_INTERNAL, "")
  1754. lv2Count = self._reAddInternalHelper(settingsDB, PLUGIN_LV2, LV2_PATH)
  1755. auCount = self._reAddInternalHelper(settingsDB, PLUGIN_AU, "") if MACOS else 0
  1756. # ----------------------------------------------------------------------------------------------------
  1757. # LADSPA
  1758. ladspaPlugins = []
  1759. ladspaPlugins += settingsDB.value("Plugins/LADSPA_native", [], list)
  1760. ladspaPlugins += settingsDB.value("Plugins/LADSPA_posix32", [], list)
  1761. ladspaPlugins += settingsDB.value("Plugins/LADSPA_posix64", [], list)
  1762. ladspaPlugins += settingsDB.value("Plugins/LADSPA_win32", [], list)
  1763. ladspaPlugins += settingsDB.value("Plugins/LADSPA_win64", [], list)
  1764. # ----------------------------------------------------------------------------------------------------
  1765. # DSSI
  1766. dssiPlugins = []
  1767. dssiPlugins += settingsDB.value("Plugins/DSSI_native", [], list)
  1768. dssiPlugins += settingsDB.value("Plugins/DSSI_posix32", [], list)
  1769. dssiPlugins += settingsDB.value("Plugins/DSSI_posix64", [], list)
  1770. dssiPlugins += settingsDB.value("Plugins/DSSI_win32", [], list)
  1771. dssiPlugins += settingsDB.value("Plugins/DSSI_win64", [], list)
  1772. # ----------------------------------------------------------------------------------------------------
  1773. # VST2
  1774. vst2Plugins = []
  1775. vst2Plugins += settingsDB.value("Plugins/VST2_native", [], list)
  1776. vst2Plugins += settingsDB.value("Plugins/VST2_posix32", [], list)
  1777. vst2Plugins += settingsDB.value("Plugins/VST2_posix64", [], list)
  1778. vst2Plugins += settingsDB.value("Plugins/VST2_win32", [], list)
  1779. vst2Plugins += settingsDB.value("Plugins/VST2_win64", [], list)
  1780. # ----------------------------------------------------------------------------------------------------
  1781. # VST3
  1782. vst3Plugins = []
  1783. vst3Plugins += settingsDB.value("Plugins/VST3_native", [], list)
  1784. vst3Plugins += settingsDB.value("Plugins/VST3_posix32", [], list)
  1785. vst3Plugins += settingsDB.value("Plugins/VST3_posix64", [], list)
  1786. vst3Plugins += settingsDB.value("Plugins/VST3_win32", [], list)
  1787. vst3Plugins += settingsDB.value("Plugins/VST3_win64", [], list)
  1788. # ----------------------------------------------------------------------------------------------------
  1789. # AU (extra non-cached)
  1790. auPlugins32 = settingsDB.value("Plugins/AU_posix32", [], list) if MACOS else []
  1791. # ----------------------------------------------------------------------------------------------------
  1792. # JSFX
  1793. jsfxPlugins = settingsDB.value("Plugins/JSFX", [], list)
  1794. # ----------------------------------------------------------------------------------------------------
  1795. # Kits
  1796. sf2s = settingsDB.value("Plugins/SF2", [], list)
  1797. sfzs = settingsDB.value("Plugins/SFZ", [], list)
  1798. # ----------------------------------------------------------------------------------------------------
  1799. # count plugins first, so we can create rows in advance
  1800. ladspaCount = 0
  1801. dssiCount = 0
  1802. vstCount = 0
  1803. vst3Count = 0
  1804. au32Count = 0
  1805. jsfxCount = len(jsfxPlugins)
  1806. sf2Count = 0
  1807. sfzCount = len(sfzs)
  1808. for plugins in ladspaPlugins:
  1809. ladspaCount += len(plugins)
  1810. for plugins in dssiPlugins:
  1811. dssiCount += len(plugins)
  1812. for plugins in vst2Plugins:
  1813. vstCount += len(plugins)
  1814. for plugins in vst3Plugins:
  1815. vst3Count += len(plugins)
  1816. for plugins in auPlugins32:
  1817. au32Count += len(plugins)
  1818. for plugins in sf2s:
  1819. sf2Count += len(plugins)
  1820. self.ui.tableWidget.setRowCount(self.fLastTableIndex +
  1821. ladspaCount + dssiCount + vstCount + vst3Count + au32Count + jsfxCount +
  1822. sf2Count + sfzCount)
  1823. if MACOS:
  1824. self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2, %i VST2, %i VST3, %i AudioUnit plugins and %i JSFX plugins, plus %i Sound Kits" % (
  1825. internalCount, ladspaCount, dssiCount, lv2Count, vstCount, vst3Count, auCount+au32Count, jsfxCount, sf2Count+sfzCount)))
  1826. else:
  1827. self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2, %i VST2, %i VST3 plugins and %i JSFX plugins, plus %i Sound Kits" % (
  1828. internalCount, ladspaCount, dssiCount, lv2Count, vstCount, vst3Count, jsfxCount, sf2Count+sfzCount)))
  1829. # ----------------------------------------------------------------------------------------------------
  1830. # now add all plugins to the table
  1831. for plugins in ladspaPlugins:
  1832. for plugin in plugins:
  1833. self._addPluginToTable(plugin, "LADSPA")
  1834. for plugins in dssiPlugins:
  1835. for plugin in plugins:
  1836. self._addPluginToTable(plugin, "DSSI")
  1837. for plugins in vst2Plugins:
  1838. for plugin in plugins:
  1839. self._addPluginToTable(plugin, "VST2")
  1840. for plugins in vst3Plugins:
  1841. for plugin in plugins:
  1842. self._addPluginToTable(plugin, "VST3")
  1843. for plugins in auPlugins32:
  1844. for plugin in plugins:
  1845. self._addPluginToTable(plugin, "AU")
  1846. for plugin in jsfxPlugins:
  1847. self._addPluginToTable(plugin, "JSFX")
  1848. for sf2 in sf2s:
  1849. for sf2_i in sf2:
  1850. self._addPluginToTable(sf2_i, "SF2")
  1851. for sfz in sfzs:
  1852. self._addPluginToTable(sfz, "SFZ")
  1853. # ----------------------------------------------------------------------------------------------------
  1854. self.ui.tableWidget.setSortingEnabled(True)
  1855. self._checkFilters()
  1856. self.slot_checkPlugin(self.ui.tableWidget.currentRow())
  1857. # --------------------------------------------------------------------------------------------------------
  1858. def showEvent(self, event):
  1859. self.slot_focusSearchFieldAndSelectAll()
  1860. QDialog.showEvent(self, event)
  1861. # ---------------------------------------------------------------------------------------------------------------------
  1862. # Jack Application Dialog
  1863. class JackApplicationW(QDialog):
  1864. SESSION_MGR_NONE = 0
  1865. SESSION_MGR_AUTO = 1
  1866. SESSION_MGR_JACK = 2
  1867. SESSION_MGR_LADISH = 3
  1868. SESSION_MGR_NSM = 4
  1869. UI_SESSION_NONE = 0
  1870. UI_SESSION_LADISH = 1
  1871. UI_SESSION_NSM = 2
  1872. FLAG_CONTROL_WINDOW = 0x01
  1873. FLAG_CAPTURE_FIRST_WINDOW = 0x02
  1874. FLAG_BUFFERS_ADDITION_MODE = 0x10
  1875. FLAG_MIDI_OUTPUT_CHANNEL_MIXDOWN = 0x20
  1876. FLAG_EXTERNAL_START = 0x40
  1877. def __init__(self, parent, projectFilename):
  1878. QDialog.__init__(self, parent)
  1879. self.ui = ui_carla_add_jack.Ui_Dialog()
  1880. self.ui.setupUi(self)
  1881. print("Add JACK Application: current project filename is '%s'" % (projectFilename,))
  1882. self.fProjectFilename = projectFilename
  1883. self.ui.group_error.setVisible(False)
  1884. self.adjustSize()
  1885. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  1886. # --------------------------------------------------------------------------------------------------------------
  1887. # Load settings
  1888. self.loadSettings()
  1889. # --------------------------------------------------------------------------------------------------------------
  1890. # Set-up connections
  1891. self.finished.connect(self.slot_saveSettings)
  1892. self.ui.cb_session_mgr.currentIndexChanged.connect(self.slot_sessionManagerChanged)
  1893. self.ui.le_command.textChanged.connect(self.slot_commandChanged)
  1894. # -----------------------------------------------------------------------------------------------------------------
  1895. def getCommandAndFlags(self):
  1896. name = self.ui.le_name.text()
  1897. command = self.ui.le_command.text()
  1898. smgr = self.SESSION_MGR_NONE
  1899. flags = 0x0
  1900. if not name:
  1901. name = os.path.basename(command.split(" ",1)[0]).title()
  1902. uiSessionMgrIndex = self.ui.cb_session_mgr.currentIndex()
  1903. if uiSessionMgrIndex == self.UI_SESSION_LADISH:
  1904. smgr = self.SESSION_MGR_LADISH
  1905. elif uiSessionMgrIndex == self.UI_SESSION_NSM:
  1906. smgr = self.SESSION_MGR_NSM
  1907. if self.ui.cb_manage_window.isChecked():
  1908. flags |= self.FLAG_CONTROL_WINDOW
  1909. if self.ui.cb_capture_first_window.isChecked():
  1910. flags |= self.FLAG_CAPTURE_FIRST_WINDOW
  1911. if self.ui.cb_buffers_addition_mode.isChecked():
  1912. flags |= self.FLAG_BUFFERS_ADDITION_MODE
  1913. if self.ui.cb_out_midi_mixdown.isChecked():
  1914. flags |= self.FLAG_MIDI_OUTPUT_CHANNEL_MIXDOWN
  1915. if self.ui.cb_external_start.isChecked():
  1916. flags |= self.FLAG_EXTERNAL_START
  1917. baseIntVal = ord('0')
  1918. labelSetup = "%s%s%s%s%s%s" % (chr(baseIntVal+self.ui.sb_audio_ins.value()),
  1919. chr(baseIntVal+self.ui.sb_audio_outs.value()),
  1920. chr(baseIntVal+self.ui.sb_midi_ins.value()),
  1921. chr(baseIntVal+self.ui.sb_midi_outs.value()),
  1922. chr(baseIntVal+smgr),
  1923. chr(baseIntVal+flags))
  1924. return (command, name, labelSetup)
  1925. def checkIfButtonBoxShouldBeEnabled(self, index, text):
  1926. enabled = len(text) > 0
  1927. showErr = ""
  1928. # NSM applications must not be abstract or absolute paths, and must not contain arguments
  1929. if enabled and index == self.UI_SESSION_NSM:
  1930. if text[0] in (".", "/"):
  1931. showErr = self.tr("NSM applications cannot use abstract or absolute paths")
  1932. elif " " in text or ";" in text or "&" in text:
  1933. showErr = self.tr("NSM applications cannot use CLI arguments")
  1934. elif len(self.fProjectFilename) == 0:
  1935. showErr = self.tr("You need to save the current Carla project before NSM can be used")
  1936. if showErr:
  1937. enabled = False
  1938. self.ui.l_error.setText(showErr)
  1939. self.ui.group_error.setVisible(True)
  1940. else:
  1941. self.ui.group_error.setVisible(False)
  1942. self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
  1943. def loadSettings(self):
  1944. settings = QSafeSettings("falkTX", "CarlaAddJackApp")
  1945. smName = settings.value("SessionManager", "", str)
  1946. if smName == "LADISH (SIGUSR1)":
  1947. self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_LADISH)
  1948. elif smName == "NSM":
  1949. self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_NSM)
  1950. else:
  1951. self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_NONE)
  1952. self.ui.le_command.setText(settings.value("Command", "", str))
  1953. self.ui.le_name.setText(settings.value("Name", "", str))
  1954. self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, int))
  1955. self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, int))
  1956. self.ui.sb_audio_outs.setValue(settings.value("NumAudioOuts", 2, int))
  1957. self.ui.sb_midi_ins.setValue(settings.value("NumMidiIns", 0, int))
  1958. self.ui.sb_midi_outs.setValue(settings.value("NumMidiOuts", 0, int))
  1959. self.ui.cb_manage_window.setChecked(settings.value("ManageWindow", True, bool))
  1960. self.ui.cb_capture_first_window.setChecked(settings.value("CaptureFirstWindow", False, bool))
  1961. self.ui.cb_out_midi_mixdown.setChecked(settings.value("MidiOutMixdown", False, bool))
  1962. self.checkIfButtonBoxShouldBeEnabled(self.ui.cb_session_mgr.currentIndex(),
  1963. self.ui.le_command.text())
  1964. # -----------------------------------------------------------------------------------------------------------------
  1965. @pyqtSlot(str)
  1966. def slot_commandChanged(self, text):
  1967. self.checkIfButtonBoxShouldBeEnabled(self.ui.cb_session_mgr.currentIndex(), text)
  1968. @pyqtSlot(int)
  1969. def slot_sessionManagerChanged(self, index):
  1970. self.checkIfButtonBoxShouldBeEnabled(index, self.ui.le_command.text())
  1971. @pyqtSlot()
  1972. def slot_saveSettings(self):
  1973. settings = QSafeSettings("falkTX", "CarlaAddJackApp")
  1974. settings.setValue("Command", self.ui.le_command.text())
  1975. settings.setValue("Name", self.ui.le_name.text())
  1976. settings.setValue("SessionManager", self.ui.cb_session_mgr.currentText())
  1977. settings.setValue("NumAudioIns", self.ui.sb_audio_ins.value())
  1978. settings.setValue("NumAudioOuts", self.ui.sb_audio_outs.value())
  1979. settings.setValue("NumMidiIns", self.ui.sb_midi_ins.value())
  1980. settings.setValue("NumMidiOuts", self.ui.sb_midi_outs.value())
  1981. settings.setValue("ManageWindow", self.ui.cb_manage_window.isChecked())
  1982. settings.setValue("CaptureFirstWindow", self.ui.cb_capture_first_window.isChecked())
  1983. settings.setValue("MidiOutMixdown", self.ui.cb_out_midi_mixdown.isChecked())
  1984. # ---------------------------------------------------------------------------------------------------------------------
  1985. # Main
  1986. if __name__ == '__main__':
  1987. from carla_app import CarlaApplication
  1988. from carla_host import initHost as _initHost, loadHostSettings as _loadHostSettings
  1989. # pylint: disable=ungrouped-imports
  1990. from carla_shared import handleInitialCommandLineArguments
  1991. # pylint: enable=ungrouped-imports
  1992. initName, libPrefix = handleInitialCommandLineArguments(__file__ if "__file__" in dir() else None)
  1993. app = CarlaApplication("Carla2-Database", libPrefix)
  1994. host = _initHost("Carla2-Database", libPrefix, False, False, False)
  1995. _loadHostSettings(host)
  1996. gui = PluginDatabaseW(None, host, True)
  1997. #gui = PluginRefreshW(None, host, True, False)
  1998. gui.show()
  1999. app.exit_exec()
  2000. # ------------------------------------------------------------------------------------------------------------