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.

2420 lines
99KB

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