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.

2416 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 not MACOS:
  876. self.ui.ch_au.setEnabled(False)
  877. self.ui.ch_au.setVisible(False)
  878. if hasNative:
  879. self.ui.ico_native.setPixmap(self.fIconYes)
  880. else:
  881. self.ui.ico_native.setPixmap(self.fIconNo)
  882. self.ui.ch_native.setEnabled(False)
  883. self.ui.ch_sf2.setEnabled(False)
  884. if not hasNonNative:
  885. self.ui.ch_ladspa.setEnabled(False)
  886. self.ui.ch_dssi.setEnabled(False)
  887. self.ui.ch_vst.setEnabled(False)
  888. self.ui.ch_vst3.setEnabled(False)
  889. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  890. # -------------------------------------------------------------------------------------------------------------
  891. # Load settings
  892. self.loadSettings()
  893. # -------------------------------------------------------------------------------------------------------------
  894. # Hide bridges if disabled
  895. # NOTE: We Assume win32 carla build will not run win64 plugins
  896. if (WINDOWS and not kIs64bit) or not host.showPluginBridges:
  897. self.ui.ch_native.setChecked(True)
  898. self.ui.ch_native.setEnabled(False)
  899. self.ui.ch_native.setVisible(False)
  900. self.ui.ch_posix32.setChecked(False)
  901. self.ui.ch_posix32.setEnabled(False)
  902. self.ui.ch_posix32.setVisible(False)
  903. self.ui.ch_posix64.setChecked(False)
  904. self.ui.ch_posix64.setEnabled(False)
  905. self.ui.ch_posix64.setVisible(False)
  906. self.ui.ch_win32.setChecked(False)
  907. self.ui.ch_win32.setEnabled(False)
  908. self.ui.ch_win32.setVisible(False)
  909. self.ui.ch_win64.setChecked(False)
  910. self.ui.ch_win64.setEnabled(False)
  911. self.ui.ch_win64.setVisible(False)
  912. self.ui.ico_posix32.hide()
  913. self.ui.ico_posix64.hide()
  914. self.ui.ico_win32.hide()
  915. self.ui.ico_win64.hide()
  916. self.ui.label_posix32.hide()
  917. self.ui.label_posix64.hide()
  918. self.ui.label_win32.hide()
  919. self.ui.label_win64.hide()
  920. self.ui.sep_format.hide()
  921. elif not (WINDOWS or host.showWineBridges):
  922. self.ui.ch_win32.setChecked(False)
  923. self.ui.ch_win32.setEnabled(False)
  924. self.ui.ch_win32.setVisible(False)
  925. self.ui.ch_win64.setChecked(False)
  926. self.ui.ch_win64.setEnabled(False)
  927. self.ui.ch_win64.setVisible(False)
  928. self.ui.ico_win32.hide()
  929. self.ui.ico_win64.hide()
  930. self.ui.label_win32.hide()
  931. self.ui.label_win64.hide()
  932. # Disable non-supported features
  933. features = gCarla.utils.get_supported_features()
  934. if "sf2" not in features:
  935. self.ui.ch_sf2.setChecked(False)
  936. self.ui.ch_sf2.setEnabled(False)
  937. if MACOS and "juce" not in features:
  938. self.ui.ch_au.setChecked(False)
  939. self.ui.ch_au.setEnabled(False)
  940. # -------------------------------------------------------------------------------------------------------------
  941. # Resize to minimum size, as it's very likely UI stuff was hidden
  942. self.resize(self.minimumSize())
  943. # -------------------------------------------------------------------------------------------------------------
  944. # Set-up connections
  945. self.finished.connect(self.slot_saveSettings)
  946. self.ui.b_start.clicked.connect(self.slot_start)
  947. self.ui.b_skip.clicked.connect(self.slot_skip)
  948. self.ui.ch_native.clicked.connect(self.slot_checkTools)
  949. self.ui.ch_posix32.clicked.connect(self.slot_checkTools)
  950. self.ui.ch_posix64.clicked.connect(self.slot_checkTools)
  951. self.ui.ch_win32.clicked.connect(self.slot_checkTools)
  952. self.ui.ch_win64.clicked.connect(self.slot_checkTools)
  953. self.ui.ch_ladspa.clicked.connect(self.slot_checkTools)
  954. self.ui.ch_dssi.clicked.connect(self.slot_checkTools)
  955. self.ui.ch_lv2.clicked.connect(self.slot_checkTools)
  956. self.ui.ch_vst.clicked.connect(self.slot_checkTools)
  957. self.ui.ch_vst3.clicked.connect(self.slot_checkTools)
  958. self.ui.ch_au.clicked.connect(self.slot_checkTools)
  959. self.ui.ch_sf2.clicked.connect(self.slot_checkTools)
  960. self.ui.ch_sfz.clicked.connect(self.slot_checkTools)
  961. self.fThread.pluginLook.connect(self.slot_handlePluginLook)
  962. self.fThread.finished.connect(self.slot_handlePluginThreadFinished)
  963. # -------------------------------------------------------------------------------------------------------------
  964. # Post-connect setup
  965. self.slot_checkTools()
  966. # -----------------------------------------------------------------------------------------------------------------
  967. def loadSettings(self):
  968. settings = QSafeSettings("falkTX", "CarlaRefresh2")
  969. check = settings.value("PluginDatabase/SearchLADSPA", True, bool) and self.ui.ch_ladspa.isEnabled()
  970. self.ui.ch_ladspa.setChecked(check)
  971. check = settings.value("PluginDatabase/SearchDSSI", True, bool) and self.ui.ch_dssi.isEnabled()
  972. self.ui.ch_dssi.setChecked(check)
  973. check = settings.value("PluginDatabase/SearchLV2", True, bool) and self.ui.ch_lv2.isEnabled()
  974. self.ui.ch_lv2.setChecked(check)
  975. check = settings.value("PluginDatabase/SearchVST2", True, bool) and self.ui.ch_vst.isEnabled()
  976. self.ui.ch_vst.setChecked(check)
  977. check = settings.value("PluginDatabase/SearchVST3", True, bool) and self.ui.ch_vst3.isEnabled()
  978. self.ui.ch_vst3.setChecked(check)
  979. if MACOS:
  980. check = settings.value("PluginDatabase/SearchAU", True, bool) and self.ui.ch_au.isEnabled()
  981. else:
  982. check = False
  983. self.ui.ch_au.setChecked(check)
  984. check = settings.value("PluginDatabase/SearchSF2", False, bool) and self.ui.ch_sf2.isEnabled()
  985. self.ui.ch_sf2.setChecked(check)
  986. check = settings.value("PluginDatabase/SearchSFZ", False, bool) and self.ui.ch_sfz.isEnabled()
  987. self.ui.ch_sfz.setChecked(check)
  988. check = settings.value("PluginDatabase/SearchNative", True, bool) and self.ui.ch_native.isEnabled()
  989. self.ui.ch_native.setChecked(check)
  990. check = settings.value("PluginDatabase/SearchPOSIX32", False, bool) and self.ui.ch_posix32.isEnabled()
  991. self.ui.ch_posix32.setChecked(check)
  992. check = settings.value("PluginDatabase/SearchPOSIX64", False, bool) and self.ui.ch_posix64.isEnabled()
  993. self.ui.ch_posix64.setChecked(check)
  994. check = settings.value("PluginDatabase/SearchWin32", False, bool) and self.ui.ch_win32.isEnabled()
  995. self.ui.ch_win32.setChecked(check)
  996. check = settings.value("PluginDatabase/SearchWin64", False, bool) and self.ui.ch_win64.isEnabled()
  997. self.ui.ch_win64.setChecked(check)
  998. self.ui.ch_do_checks.setChecked(settings.value("PluginDatabase/DoChecks", False, bool))
  999. # -----------------------------------------------------------------------------------------------------------------
  1000. @pyqtSlot()
  1001. def slot_saveSettings(self):
  1002. settings = QSafeSettings("falkTX", "CarlaRefresh2")
  1003. settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked())
  1004. settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked())
  1005. settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked())
  1006. settings.setValue("PluginDatabase/SearchVST2", self.ui.ch_vst.isChecked())
  1007. settings.setValue("PluginDatabase/SearchVST3", self.ui.ch_vst3.isChecked())
  1008. settings.setValue("PluginDatabase/SearchAU", self.ui.ch_au.isChecked())
  1009. settings.setValue("PluginDatabase/SearchSF2", self.ui.ch_sf2.isChecked())
  1010. settings.setValue("PluginDatabase/SearchSFZ", self.ui.ch_sfz.isChecked())
  1011. settings.setValue("PluginDatabase/SearchNative", self.ui.ch_native.isChecked())
  1012. settings.setValue("PluginDatabase/SearchPOSIX32", self.ui.ch_posix32.isChecked())
  1013. settings.setValue("PluginDatabase/SearchPOSIX64", self.ui.ch_posix64.isChecked())
  1014. settings.setValue("PluginDatabase/SearchWin32", self.ui.ch_win32.isChecked())
  1015. settings.setValue("PluginDatabase/SearchWin64", self.ui.ch_win64.isChecked())
  1016. settings.setValue("PluginDatabase/DoChecks", self.ui.ch_do_checks.isChecked())
  1017. # -----------------------------------------------------------------------------------------------------------------
  1018. @pyqtSlot()
  1019. def slot_start(self):
  1020. self.ui.progressBar.setMinimum(0)
  1021. self.ui.progressBar.setMaximum(100)
  1022. self.ui.progressBar.setValue(0)
  1023. self.ui.b_start.setEnabled(False)
  1024. self.ui.b_skip.setVisible(True)
  1025. self.ui.b_close.setVisible(False)
  1026. self.ui.group_types.setEnabled(False)
  1027. self.ui.group_options.setEnabled(False)
  1028. if self.ui.ch_do_checks.isChecked():
  1029. gCarla.utils.unsetenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS")
  1030. else:
  1031. gCarla.utils.setenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS", "true")
  1032. native, posix32, posix64, win32, win64 = (self.ui.ch_native.isChecked(),
  1033. self.ui.ch_posix32.isChecked(), self.ui.ch_posix64.isChecked(),
  1034. self.ui.ch_win32.isChecked(), self.ui.ch_win64.isChecked())
  1035. ladspa, dssi, lv2, vst, vst3, au, sf2, sfz = (self.ui.ch_ladspa.isChecked(), self.ui.ch_dssi.isChecked(),
  1036. self.ui.ch_lv2.isChecked(), self.ui.ch_vst.isChecked(),
  1037. self.ui.ch_vst3.isChecked(), self.ui.ch_au.isChecked(),
  1038. self.ui.ch_sf2.isChecked(), self.ui.ch_sfz.isChecked())
  1039. self.fThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64)
  1040. self.fThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, vst3, au, sf2, sfz)
  1041. self.fThread.start()
  1042. # -----------------------------------------------------------------------------------------------------------------
  1043. @pyqtSlot()
  1044. def slot_skip(self):
  1045. killDiscovery()
  1046. # -----------------------------------------------------------------------------------------------------------------
  1047. @pyqtSlot()
  1048. def slot_checkTools(self):
  1049. enabled1 = bool(self.ui.ch_native.isChecked() or
  1050. self.ui.ch_posix32.isChecked() or self.ui.ch_posix64.isChecked() or
  1051. self.ui.ch_win32.isChecked() or self.ui.ch_win64.isChecked())
  1052. enabled2 = bool(self.ui.ch_ladspa.isChecked() or self.ui.ch_dssi.isChecked() or
  1053. self.ui.ch_lv2.isChecked() or self.ui.ch_vst.isChecked() or
  1054. self.ui.ch_vst3.isChecked() or self.ui.ch_au.isChecked() or
  1055. self.ui.ch_sf2.isChecked() or self.ui.ch_sfz.isChecked())
  1056. self.ui.b_start.setEnabled(enabled1 and enabled2)
  1057. # -----------------------------------------------------------------------------------------------------------------
  1058. @pyqtSlot(int, str)
  1059. def slot_handlePluginLook(self, percent, plugin):
  1060. self.ui.progressBar.setFormat("%s" % plugin)
  1061. self.ui.progressBar.setValue(percent)
  1062. # -----------------------------------------------------------------------------------------------------------------
  1063. @pyqtSlot()
  1064. def slot_handlePluginThreadFinished(self):
  1065. self.ui.progressBar.setMinimum(0)
  1066. self.ui.progressBar.setMaximum(1)
  1067. self.ui.progressBar.setValue(1)
  1068. self.ui.progressBar.setFormat(self.tr("Done"))
  1069. self.ui.b_start.setEnabled(True)
  1070. self.ui.b_skip.setVisible(False)
  1071. self.ui.b_close.setVisible(True)
  1072. self.ui.group_types.setEnabled(True)
  1073. self.ui.group_options.setEnabled(True)
  1074. # -----------------------------------------------------------------------------------------------------------------
  1075. def closeEvent(self, event):
  1076. if self.fThread.isRunning():
  1077. self.fThread.stop()
  1078. killDiscovery()
  1079. #self.fThread.terminate()
  1080. self.fThread.wait()
  1081. if self.fThread.hasSomethingChanged():
  1082. self.accept()
  1083. else:
  1084. self.reject()
  1085. QDialog.closeEvent(self, event)
  1086. # ---------------------------------------------------------------------------------------------------------------------
  1087. # Plugin Database Dialog
  1088. class PluginDatabaseW(QDialog):
  1089. TABLEWIDGET_ITEM_FAVORITE = 0
  1090. TABLEWIDGET_ITEM_NAME = 1
  1091. TABLEWIDGET_ITEM_LABEL = 2
  1092. TABLEWIDGET_ITEM_MAKER = 3
  1093. TABLEWIDGET_ITEM_BINARY = 4
  1094. def __init__(self, parent, host, useSystemIcons):
  1095. QDialog.__init__(self, parent)
  1096. self.host = host
  1097. self.ui = ui_carla_database.Ui_PluginDatabaseW()
  1098. self.ui.setupUi(self)
  1099. # ----------------------------------------------------------------------------------------------------
  1100. # Internal stuff
  1101. self.fLastTableIndex = 0
  1102. self.fRetPlugin = None
  1103. self.fRealParent = parent
  1104. self.fFavoritePlugins = []
  1105. self.fFavoritePluginsChanged = False
  1106. self.fUseSystemIcons = useSystemIcons
  1107. self.fTrYes = self.tr("Yes")
  1108. self.fTrNo = self.tr("No")
  1109. self.fTrNative = self.tr("Native")
  1110. # ----------------------------------------------------------------------------------------------------
  1111. # Set-up GUI
  1112. self.ui.b_add.setEnabled(False)
  1113. self.addAction(self.ui.act_focus_search)
  1114. self.ui.act_focus_search.triggered.connect(self.slot_focusSearchFieldAndSelectAll)
  1115. if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32):
  1116. self.ui.ch_bridged.setText(self.tr("Bridged (64bit)"))
  1117. else:
  1118. self.ui.ch_bridged.setText(self.tr("Bridged (32bit)"))
  1119. if not (LINUX or MACOS):
  1120. self.ui.ch_bridged_wine.setChecked(False)
  1121. self.ui.ch_bridged_wine.setEnabled(False)
  1122. if not MACOS:
  1123. self.ui.ch_au.setChecked(False)
  1124. self.ui.ch_au.setEnabled(False)
  1125. self.ui.ch_au.setVisible(False)
  1126. self.ui.tab_info.tabBar().hide()
  1127. self.ui.tab_reqs.tabBar().hide()
  1128. # FIXME, why /2 needed?
  1129. self.ui.tab_info.setMinimumWidth(int(self.ui.la_id.width()/2) +
  1130. fontMetricsHorizontalAdvance(self.ui.l_id.fontMetrics(), "9999999999") + 6*3)
  1131. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  1132. # ----------------------------------------------------------------------------------------------------
  1133. # Load settings
  1134. self.loadSettings()
  1135. # ----------------------------------------------------------------------------------------------------
  1136. # Disable bridges if not enabled in settings
  1137. # NOTE: We Assume win32 carla build will not run win64 plugins
  1138. if (WINDOWS and not kIs64bit) or not host.showPluginBridges:
  1139. self.ui.ch_native.setChecked(True)
  1140. self.ui.ch_native.setEnabled(False)
  1141. self.ui.ch_native.setVisible(True)
  1142. self.ui.ch_bridged.setChecked(False)
  1143. self.ui.ch_bridged.setEnabled(False)
  1144. self.ui.ch_bridged.setVisible(False)
  1145. self.ui.ch_bridged_wine.setChecked(False)
  1146. self.ui.ch_bridged_wine.setEnabled(False)
  1147. self.ui.ch_bridged_wine.setVisible(False)
  1148. self.ui.l_arch.setVisible(False)
  1149. elif not host.showWineBridges:
  1150. self.ui.ch_bridged_wine.setChecked(False)
  1151. self.ui.ch_bridged_wine.setEnabled(False)
  1152. self.ui.ch_bridged_wine.setVisible(False)
  1153. # ----------------------------------------------------------------------------------------------------
  1154. # Set-up Icons
  1155. if useSystemIcons:
  1156. self.ui.b_add.setIcon(getIcon('list-add', 16, 'svgz'))
  1157. self.ui.b_cancel.setIcon(getIcon('dialog-cancel', 16, 'svgz'))
  1158. self.ui.b_clear_filters.setIcon(getIcon('edit-clear', 16, 'svgz'))
  1159. self.ui.b_refresh.setIcon(getIcon('view-refresh', 16, 'svgz'))
  1160. self.ui.tableWidget.horizontalHeaderItem(self.TABLEWIDGET_ITEM_FAVORITE).setIcon(getIcon('bookmarks', 16, 'svgz'))
  1161. # ----------------------------------------------------------------------------------------------------
  1162. # Set-up connections
  1163. self.finished.connect(self.slot_saveSettings)
  1164. self.ui.b_add.clicked.connect(self.slot_addPlugin)
  1165. self.ui.b_cancel.clicked.connect(self.reject)
  1166. self.ui.b_refresh.clicked.connect(self.slot_refreshPlugins)
  1167. self.ui.b_clear_filters.clicked.connect(self.slot_clearFilters)
  1168. self.ui.lineEdit.textChanged.connect(self.slot_checkFilters)
  1169. self.ui.tableWidget.currentCellChanged.connect(self.slot_checkPlugin)
  1170. self.ui.tableWidget.cellClicked.connect(self.slot_cellClicked)
  1171. self.ui.tableWidget.cellDoubleClicked.connect(self.slot_cellDoubleClicked)
  1172. self.ui.ch_internal.clicked.connect(self.slot_checkFilters)
  1173. self.ui.ch_ladspa.clicked.connect(self.slot_checkFilters)
  1174. self.ui.ch_dssi.clicked.connect(self.slot_checkFilters)
  1175. self.ui.ch_lv2.clicked.connect(self.slot_checkFilters)
  1176. self.ui.ch_vst.clicked.connect(self.slot_checkFilters)
  1177. self.ui.ch_vst3.clicked.connect(self.slot_checkFilters)
  1178. self.ui.ch_au.clicked.connect(self.slot_checkFilters)
  1179. self.ui.ch_kits.clicked.connect(self.slot_checkFilters)
  1180. self.ui.ch_effects.clicked.connect(self.slot_checkFilters)
  1181. self.ui.ch_instruments.clicked.connect(self.slot_checkFilters)
  1182. self.ui.ch_midi.clicked.connect(self.slot_checkFilters)
  1183. self.ui.ch_other.clicked.connect(self.slot_checkFilters)
  1184. self.ui.ch_native.clicked.connect(self.slot_checkFilters)
  1185. self.ui.ch_bridged.clicked.connect(self.slot_checkFilters)
  1186. self.ui.ch_bridged_wine.clicked.connect(self.slot_checkFilters)
  1187. self.ui.ch_favorites.clicked.connect(self.slot_checkFilters)
  1188. self.ui.ch_rtsafe.clicked.connect(self.slot_checkFilters)
  1189. self.ui.ch_cv.clicked.connect(self.slot_checkFilters)
  1190. self.ui.ch_gui.clicked.connect(self.slot_checkFilters)
  1191. self.ui.ch_inline_display.clicked.connect(self.slot_checkFilters)
  1192. self.ui.ch_stereo.clicked.connect(self.slot_checkFilters)
  1193. self.ui.ch_cat_all.clicked.connect(self.slot_checkFiltersCategoryAll)
  1194. self.ui.ch_cat_delay.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1195. self.ui.ch_cat_distortion.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1196. self.ui.ch_cat_dynamics.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1197. self.ui.ch_cat_eq.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1198. self.ui.ch_cat_filter.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1199. self.ui.ch_cat_modulator.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1200. self.ui.ch_cat_synth.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1201. self.ui.ch_cat_utility.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1202. self.ui.ch_cat_other.clicked.connect(self.slot_checkFiltersCategorySpecific)
  1203. # ----------------------------------------------------------------------------------------------------
  1204. # Post-connect setup
  1205. self._reAddPlugins()
  1206. self.slot_focusSearchFieldAndSelectAll()
  1207. # --------------------------------------------------------------------------------------------------------
  1208. @pyqtSlot(int, int)
  1209. def slot_cellClicked(self, row, column):
  1210. if column == self.TABLEWIDGET_ITEM_FAVORITE:
  1211. widget = self.ui.tableWidget.item(row, self.TABLEWIDGET_ITEM_FAVORITE)
  1212. plugin = self.ui.tableWidget.item(row, self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+1)
  1213. plugin = self._createFavoritePluginDict(plugin)
  1214. if widget.checkState() == Qt.Checked:
  1215. if not plugin in self.fFavoritePlugins:
  1216. self.fFavoritePlugins.append(plugin)
  1217. self.fFavoritePluginsChanged = True
  1218. else:
  1219. try:
  1220. self.fFavoritePlugins.remove(plugin)
  1221. self.fFavoritePluginsChanged = True
  1222. except ValueError:
  1223. pass
  1224. @pyqtSlot(int, int)
  1225. def slot_cellDoubleClicked(self, row, column):
  1226. if column != self.TABLEWIDGET_ITEM_FAVORITE:
  1227. self.slot_addPlugin()
  1228. @pyqtSlot()
  1229. def slot_focusSearchFieldAndSelectAll(self):
  1230. self.ui.lineEdit.setFocus()
  1231. self.ui.lineEdit.selectAll()
  1232. @pyqtSlot()
  1233. def slot_addPlugin(self):
  1234. if self.ui.tableWidget.currentRow() >= 0:
  1235. self.fRetPlugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(),
  1236. self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+1)
  1237. self.accept()
  1238. else:
  1239. self.reject()
  1240. @pyqtSlot(int)
  1241. def slot_checkPlugin(self, row):
  1242. if row >= 0:
  1243. self.ui.b_add.setEnabled(True)
  1244. plugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(),
  1245. self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+1)
  1246. isSynth = bool(plugin['hints'] & PLUGIN_IS_SYNTH)
  1247. isEffect = bool(plugin['audio.ins'] > 0 < plugin['audio.outs'] and not isSynth)
  1248. isMidi = bool(plugin['audio.ins'] == 0 and plugin['audio.outs'] == 0 and plugin['midi.ins'] > 0 < plugin['midi.outs'])
  1249. isKit = bool(plugin['type'] in (PLUGIN_SF2, PLUGIN_SFZ))
  1250. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  1251. if isSynth:
  1252. ptype = "Instrument"
  1253. elif isEffect:
  1254. ptype = "Effect"
  1255. elif isMidi:
  1256. ptype = "MIDI Plugin"
  1257. else:
  1258. ptype = "Other"
  1259. if plugin['build'] == BINARY_NATIVE:
  1260. parch = self.fTrNative
  1261. elif plugin['build'] == BINARY_POSIX32:
  1262. parch = "posix32"
  1263. elif plugin['build'] == BINARY_POSIX64:
  1264. parch = "posix64"
  1265. elif plugin['build'] == BINARY_WIN32:
  1266. parch = "win32"
  1267. elif plugin['build'] == BINARY_WIN64:
  1268. parch = "win64"
  1269. elif plugin['build'] == BINARY_OTHER:
  1270. parch = self.tr("Other")
  1271. elif plugin['build'] == BINARY_WIN32:
  1272. parch = self.tr("Unknown")
  1273. self.ui.l_format.setText(getPluginTypeAsString(plugin['type']))
  1274. self.ui.l_type.setText(ptype)
  1275. self.ui.l_arch.setText(parch)
  1276. self.ui.l_id.setText(str(plugin['uniqueId']))
  1277. self.ui.l_ains.setText(str(plugin['audio.ins']))
  1278. self.ui.l_aouts.setText(str(plugin['audio.outs']))
  1279. self.ui.l_cvins.setText(str(plugin['cv.ins']))
  1280. self.ui.l_cvouts.setText(str(plugin['cv.outs']))
  1281. self.ui.l_mins.setText(str(plugin['midi.ins']))
  1282. self.ui.l_mouts.setText(str(plugin['midi.outs']))
  1283. self.ui.l_pins.setText(str(plugin['parameters.ins']))
  1284. self.ui.l_pouts.setText(str(plugin['parameters.outs']))
  1285. self.ui.l_gui.setText(self.fTrYes if plugin['hints'] & PLUGIN_HAS_CUSTOM_UI else self.fTrNo)
  1286. self.ui.l_idisp.setText(self.fTrYes if plugin['hints'] & PLUGIN_HAS_INLINE_DISPLAY else self.fTrNo)
  1287. self.ui.l_bridged.setText(self.fTrYes if plugin['hints'] & PLUGIN_IS_BRIDGE else self.fTrNo)
  1288. self.ui.l_synth.setText(self.fTrYes if isSynth else self.fTrNo)
  1289. else:
  1290. self.ui.b_add.setEnabled(False)
  1291. self.ui.l_format.setText("---")
  1292. self.ui.l_type.setText("---")
  1293. self.ui.l_arch.setText("---")
  1294. self.ui.l_id.setText("---")
  1295. self.ui.l_ains.setText("---")
  1296. self.ui.l_aouts.setText("---")
  1297. self.ui.l_cvins.setText("---")
  1298. self.ui.l_cvouts.setText("---")
  1299. self.ui.l_mins.setText("---")
  1300. self.ui.l_mouts.setText("---")
  1301. self.ui.l_pins.setText("---")
  1302. self.ui.l_pouts.setText("---")
  1303. self.ui.l_gui.setText("---")
  1304. self.ui.l_idisp.setText("---")
  1305. self.ui.l_bridged.setText("---")
  1306. self.ui.l_synth.setText("---")
  1307. @pyqtSlot()
  1308. def slot_checkFilters(self):
  1309. self._checkFilters()
  1310. @pyqtSlot(bool)
  1311. def slot_checkFiltersCategoryAll(self, clicked):
  1312. self.ui.ch_cat_delay.setChecked(not clicked)
  1313. self.ui.ch_cat_distortion.setChecked(not clicked)
  1314. self.ui.ch_cat_dynamics.setChecked(not clicked)
  1315. self.ui.ch_cat_eq.setChecked(not clicked)
  1316. self.ui.ch_cat_filter.setChecked(not clicked)
  1317. self.ui.ch_cat_modulator.setChecked(not clicked)
  1318. self.ui.ch_cat_synth.setChecked(not clicked)
  1319. self.ui.ch_cat_utility.setChecked(not clicked)
  1320. self.ui.ch_cat_other.setChecked(not clicked)
  1321. self._checkFilters()
  1322. @pyqtSlot(bool)
  1323. def slot_checkFiltersCategorySpecific(self, clicked):
  1324. if clicked:
  1325. self.ui.ch_cat_all.setChecked(False)
  1326. elif not (self.ui.ch_cat_delay.isChecked() or
  1327. self.ui.ch_cat_distortion.isChecked() or
  1328. self.ui.ch_cat_dynamics.isChecked() or
  1329. self.ui.ch_cat_eq.isChecked() or
  1330. self.ui.ch_cat_filter.isChecked() or
  1331. self.ui.ch_cat_modulator.isChecked() or
  1332. self.ui.ch_cat_synth.isChecked() or
  1333. self.ui.ch_cat_utility.isChecked() or
  1334. self.ui.ch_cat_other.isChecked()):
  1335. self.ui.ch_cat_all.setChecked(True)
  1336. self._checkFilters()
  1337. @pyqtSlot()
  1338. def slot_refreshPlugins(self):
  1339. if PluginRefreshW(self, self.host, self.fUseSystemIcons).exec_():
  1340. self._reAddPlugins()
  1341. if self.fRealParent:
  1342. self.fRealParent.setLoadRDFsNeeded()
  1343. @pyqtSlot()
  1344. def slot_clearFilters(self):
  1345. self.blockSignals(True)
  1346. self.ui.ch_internal.setChecked(True)
  1347. self.ui.ch_ladspa.setChecked(True)
  1348. self.ui.ch_dssi.setChecked(True)
  1349. self.ui.ch_lv2.setChecked(True)
  1350. self.ui.ch_vst.setChecked(True)
  1351. self.ui.ch_kits.setChecked(True)
  1352. self.ui.ch_instruments.setChecked(True)
  1353. self.ui.ch_effects.setChecked(True)
  1354. self.ui.ch_midi.setChecked(True)
  1355. self.ui.ch_other.setChecked(True)
  1356. self.ui.ch_native.setChecked(True)
  1357. self.ui.ch_bridged.setChecked(False)
  1358. self.ui.ch_bridged_wine.setChecked(False)
  1359. self.ui.ch_favorites.setChecked(False)
  1360. self.ui.ch_rtsafe.setChecked(False)
  1361. self.ui.ch_stereo.setChecked(False)
  1362. self.ui.ch_cv.setChecked(False)
  1363. self.ui.ch_gui.setChecked(False)
  1364. self.ui.ch_inline_display.setChecked(False)
  1365. if self.ui.ch_vst3.isEnabled():
  1366. self.ui.ch_vst3.setChecked(True)
  1367. if self.ui.ch_au.isEnabled():
  1368. self.ui.ch_au.setChecked(True)
  1369. self.ui.ch_cat_all.setChecked(True)
  1370. self.ui.ch_cat_delay.setChecked(False)
  1371. self.ui.ch_cat_distortion.setChecked(False)
  1372. self.ui.ch_cat_dynamics.setChecked(False)
  1373. self.ui.ch_cat_eq.setChecked(False)
  1374. self.ui.ch_cat_filter.setChecked(False)
  1375. self.ui.ch_cat_modulator.setChecked(False)
  1376. self.ui.ch_cat_synth.setChecked(False)
  1377. self.ui.ch_cat_utility.setChecked(False)
  1378. self.ui.ch_cat_other.setChecked(False)
  1379. self.ui.lineEdit.clear()
  1380. self.blockSignals(False)
  1381. self._checkFilters()
  1382. # --------------------------------------------------------------------------------------------------------
  1383. @pyqtSlot()
  1384. def slot_saveSettings(self):
  1385. settings = QSafeSettings("falkTX", "CarlaDatabase2")
  1386. settings.setValue("PluginDatabase/Geometry", self.saveGeometry())
  1387. settings.setValue("PluginDatabase/TableGeometry_6", self.ui.tableWidget.horizontalHeader().saveState())
  1388. settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked())
  1389. settings.setValue("PluginDatabase/ShowInstruments", self.ui.ch_instruments.isChecked())
  1390. settings.setValue("PluginDatabase/ShowMIDI", self.ui.ch_midi.isChecked())
  1391. settings.setValue("PluginDatabase/ShowOther", self.ui.ch_other.isChecked())
  1392. settings.setValue("PluginDatabase/ShowInternal", self.ui.ch_internal.isChecked())
  1393. settings.setValue("PluginDatabase/ShowLADSPA", self.ui.ch_ladspa.isChecked())
  1394. settings.setValue("PluginDatabase/ShowDSSI", self.ui.ch_dssi.isChecked())
  1395. settings.setValue("PluginDatabase/ShowLV2", self.ui.ch_lv2.isChecked())
  1396. settings.setValue("PluginDatabase/ShowVST2", self.ui.ch_vst.isChecked())
  1397. settings.setValue("PluginDatabase/ShowVST3", self.ui.ch_vst3.isChecked())
  1398. settings.setValue("PluginDatabase/ShowAU", self.ui.ch_au.isChecked())
  1399. settings.setValue("PluginDatabase/ShowKits", self.ui.ch_kits.isChecked())
  1400. settings.setValue("PluginDatabase/ShowNative", self.ui.ch_native.isChecked())
  1401. settings.setValue("PluginDatabase/ShowBridged", self.ui.ch_bridged.isChecked())
  1402. settings.setValue("PluginDatabase/ShowBridgedWine", self.ui.ch_bridged_wine.isChecked())
  1403. settings.setValue("PluginDatabase/ShowFavorites", self.ui.ch_favorites.isChecked())
  1404. settings.setValue("PluginDatabase/ShowRtSafe", self.ui.ch_rtsafe.isChecked())
  1405. settings.setValue("PluginDatabase/ShowHasCV", self.ui.ch_cv.isChecked())
  1406. settings.setValue("PluginDatabase/ShowHasGUI", self.ui.ch_gui.isChecked())
  1407. settings.setValue("PluginDatabase/ShowHasInlineDisplay", self.ui.ch_inline_display.isChecked())
  1408. settings.setValue("PluginDatabase/ShowStereoOnly", self.ui.ch_stereo.isChecked())
  1409. settings.setValue("PluginDatabase/SearchText", self.ui.lineEdit.text())
  1410. if self.ui.ch_cat_all.isChecked():
  1411. settings.setValue("PluginDatabase/ShowCategory", "all")
  1412. else:
  1413. categoryhash = ""
  1414. if self.ui.ch_cat_delay.isChecked():
  1415. categoryhash += ":delay"
  1416. if self.ui.ch_cat_distortion.isChecked():
  1417. categoryhash += ":distortion"
  1418. if self.ui.ch_cat_dynamics.isChecked():
  1419. categoryhash += ":dynamics"
  1420. if self.ui.ch_cat_eq.isChecked():
  1421. categoryhash += ":eq"
  1422. if self.ui.ch_cat_filter.isChecked():
  1423. categoryhash += ":filter"
  1424. if self.ui.ch_cat_modulator.isChecked():
  1425. categoryhash += ":modulator"
  1426. if self.ui.ch_cat_synth.isChecked():
  1427. categoryhash += ":synth"
  1428. if self.ui.ch_cat_utility.isChecked():
  1429. categoryhash += ":utility"
  1430. if self.ui.ch_cat_other.isChecked():
  1431. categoryhash += ":other"
  1432. if categoryhash:
  1433. categoryhash += ":"
  1434. settings.setValue("PluginDatabase/ShowCategory", categoryhash)
  1435. if self.fFavoritePluginsChanged:
  1436. settings.setValue("PluginDatabase/Favorites", self.fFavoritePlugins)
  1437. # --------------------------------------------------------------------------------------------------------
  1438. def loadSettings(self):
  1439. settings = QSafeSettings("falkTX", "CarlaDatabase2")
  1440. self.fFavoritePlugins = settings.value("PluginDatabase/Favorites", [], list)
  1441. self.fFavoritePluginsChanged = False
  1442. self.restoreGeometry(settings.value("PluginDatabase/Geometry", QByteArray(), QByteArray))
  1443. self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, bool))
  1444. self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, bool))
  1445. self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, bool))
  1446. self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, bool))
  1447. self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, bool))
  1448. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, bool))
  1449. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, bool))
  1450. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, bool))
  1451. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST2", True, bool))
  1452. self.ui.ch_vst3.setChecked(settings.value("PluginDatabase/ShowVST3", (MACOS or WINDOWS), bool))
  1453. self.ui.ch_au.setChecked(settings.value("PluginDatabase/ShowAU", MACOS, bool))
  1454. self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, bool))
  1455. self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, bool))
  1456. self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, bool))
  1457. self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, bool))
  1458. self.ui.ch_favorites.setChecked(settings.value("PluginDatabase/ShowFavorites", False, bool))
  1459. self.ui.ch_rtsafe.setChecked(settings.value("PluginDatabase/ShowRtSafe", False, bool))
  1460. self.ui.ch_cv.setChecked(settings.value("PluginDatabase/ShowHasCV", False, bool))
  1461. self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, bool))
  1462. self.ui.ch_inline_display.setChecked(settings.value("PluginDatabase/ShowHasInlineDisplay", False, bool))
  1463. self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, bool))
  1464. self.ui.lineEdit.setText(settings.value("PluginDatabase/SearchText", "", str))
  1465. categoryhash = settings.value("PluginDatabase/ShowCategory", "all", str)
  1466. if categoryhash == "all" or len(categoryhash) < 2:
  1467. self.ui.ch_cat_all.setChecked(True)
  1468. self.ui.ch_cat_delay.setChecked(False)
  1469. self.ui.ch_cat_distortion.setChecked(False)
  1470. self.ui.ch_cat_dynamics.setChecked(False)
  1471. self.ui.ch_cat_eq.setChecked(False)
  1472. self.ui.ch_cat_filter.setChecked(False)
  1473. self.ui.ch_cat_modulator.setChecked(False)
  1474. self.ui.ch_cat_synth.setChecked(False)
  1475. self.ui.ch_cat_utility.setChecked(False)
  1476. self.ui.ch_cat_other.setChecked(False)
  1477. else:
  1478. self.ui.ch_cat_all.setChecked(False)
  1479. self.ui.ch_cat_delay.setChecked(":delay:" in categoryhash)
  1480. self.ui.ch_cat_distortion.setChecked(":distortion:" in categoryhash)
  1481. self.ui.ch_cat_dynamics.setChecked(":dynamics:" in categoryhash)
  1482. self.ui.ch_cat_eq.setChecked(":eq:" in categoryhash)
  1483. self.ui.ch_cat_filter.setChecked(":filter:" in categoryhash)
  1484. self.ui.ch_cat_modulator.setChecked(":modulator:" in categoryhash)
  1485. self.ui.ch_cat_synth.setChecked(":synth:" in categoryhash)
  1486. self.ui.ch_cat_utility.setChecked(":utility:" in categoryhash)
  1487. self.ui.ch_cat_other.setChecked(":other:" in categoryhash)
  1488. tableGeometry = settings.value("PluginDatabase/TableGeometry_6", QByteArray(), QByteArray)
  1489. horizontalHeader = self.ui.tableWidget.horizontalHeader()
  1490. if not tableGeometry.isNull():
  1491. horizontalHeader.restoreState(tableGeometry)
  1492. else:
  1493. horizontalHeader.setSectionResizeMode(self.TABLEWIDGET_ITEM_FAVORITE, QHeaderView.Fixed)
  1494. self.ui.tableWidget.setColumnWidth(self.TABLEWIDGET_ITEM_FAVORITE, 24)
  1495. self.ui.tableWidget.setColumnWidth(self.TABLEWIDGET_ITEM_NAME, 250)
  1496. self.ui.tableWidget.setColumnWidth(self.TABLEWIDGET_ITEM_LABEL, 200)
  1497. self.ui.tableWidget.setColumnWidth(self.TABLEWIDGET_ITEM_MAKER, 150)
  1498. self.ui.tableWidget.sortByColumn(self.TABLEWIDGET_ITEM_NAME, Qt.AscendingOrder)
  1499. # --------------------------------------------------------------------------------------------------------
  1500. def _createFavoritePluginDict(self, plugin):
  1501. return {
  1502. 'name' : plugin['name'],
  1503. 'build' : plugin['build'],
  1504. 'type' : plugin['type'],
  1505. 'filename': plugin['filename'],
  1506. 'label' : plugin['label'],
  1507. 'uniqueId': plugin['uniqueId'],
  1508. }
  1509. def _checkFilters(self):
  1510. text = self.ui.lineEdit.text().lower()
  1511. hideEffects = not self.ui.ch_effects.isChecked()
  1512. hideInstruments = not self.ui.ch_instruments.isChecked()
  1513. hideMidi = not self.ui.ch_midi.isChecked()
  1514. hideOther = not self.ui.ch_other.isChecked()
  1515. hideInternal = not self.ui.ch_internal.isChecked()
  1516. hideLadspa = not self.ui.ch_ladspa.isChecked()
  1517. hideDssi = not self.ui.ch_dssi.isChecked()
  1518. hideLV2 = not self.ui.ch_lv2.isChecked()
  1519. hideVST2 = not self.ui.ch_vst.isChecked()
  1520. hideVST3 = not self.ui.ch_vst3.isChecked()
  1521. hideAU = not self.ui.ch_au.isChecked()
  1522. hideKits = not self.ui.ch_kits.isChecked()
  1523. hideNative = not self.ui.ch_native.isChecked()
  1524. hideBridged = not self.ui.ch_bridged.isChecked()
  1525. hideBridgedWine = not self.ui.ch_bridged_wine.isChecked()
  1526. hideNonFavs = self.ui.ch_favorites.isChecked()
  1527. hideNonRtSafe = self.ui.ch_rtsafe.isChecked()
  1528. hideNonCV = self.ui.ch_cv.isChecked()
  1529. hideNonGui = self.ui.ch_gui.isChecked()
  1530. hideNonIDisp = self.ui.ch_inline_display.isChecked()
  1531. hideNonStereo = self.ui.ch_stereo.isChecked()
  1532. if HAIKU or LINUX or MACOS:
  1533. nativeBins = [BINARY_POSIX32, BINARY_POSIX64]
  1534. wineBins = [BINARY_WIN32, BINARY_WIN64]
  1535. elif WINDOWS:
  1536. nativeBins = [BINARY_WIN32, BINARY_WIN64]
  1537. wineBins = []
  1538. else:
  1539. nativeBins = []
  1540. wineBins = []
  1541. self.ui.tableWidget.setRowCount(self.fLastTableIndex)
  1542. for i in range(self.fLastTableIndex):
  1543. plugin = self.ui.tableWidget.item(i, self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+1)
  1544. ptext = self.ui.tableWidget.item(i, self.TABLEWIDGET_ITEM_NAME).data(Qt.UserRole+2)
  1545. aIns = plugin['audio.ins']
  1546. aOuts = plugin['audio.outs']
  1547. cvIns = plugin['cv.ins']
  1548. cvOuts = plugin['cv.outs']
  1549. mIns = plugin['midi.ins']
  1550. mOuts = plugin['midi.outs']
  1551. phints = plugin['hints']
  1552. ptype = plugin['type']
  1553. categ = plugin['category']
  1554. isSynth = bool(phints & PLUGIN_IS_SYNTH)
  1555. isEffect = bool(aIns > 0 < aOuts and not isSynth)
  1556. isMidi = bool(aIns == 0 and aOuts == 0 and mIns > 0 < mOuts)
  1557. isKit = bool(ptype in (PLUGIN_SF2, PLUGIN_SFZ))
  1558. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  1559. isNative = bool(plugin['build'] == BINARY_NATIVE)
  1560. isRtSafe = bool(phints & PLUGIN_IS_RTSAFE)
  1561. isStereo = bool(aIns == 2 and aOuts == 2) or (isSynth and aOuts == 2)
  1562. hasCV = bool(cvIns + cvOuts > 0)
  1563. hasGui = bool(phints & PLUGIN_HAS_CUSTOM_UI)
  1564. hasIDisp = bool(phints & PLUGIN_HAS_INLINE_DISPLAY)
  1565. isBridged = bool(not isNative and plugin['build'] in nativeBins)
  1566. isBridgedWine = bool(not isNative and plugin['build'] in wineBins)
  1567. if hideEffects and isEffect:
  1568. self.ui.tableWidget.hideRow(i)
  1569. elif hideInstruments and isSynth:
  1570. self.ui.tableWidget.hideRow(i)
  1571. elif hideMidi and isMidi:
  1572. self.ui.tableWidget.hideRow(i)
  1573. elif hideOther and isOther:
  1574. self.ui.tableWidget.hideRow(i)
  1575. elif hideKits and isKit:
  1576. self.ui.tableWidget.hideRow(i)
  1577. elif hideInternal and ptype == PLUGIN_INTERNAL:
  1578. self.ui.tableWidget.hideRow(i)
  1579. elif hideLadspa and ptype == PLUGIN_LADSPA:
  1580. self.ui.tableWidget.hideRow(i)
  1581. elif hideDssi and ptype == PLUGIN_DSSI:
  1582. self.ui.tableWidget.hideRow(i)
  1583. elif hideLV2 and ptype == PLUGIN_LV2:
  1584. self.ui.tableWidget.hideRow(i)
  1585. elif hideVST2 and ptype == PLUGIN_VST2:
  1586. self.ui.tableWidget.hideRow(i)
  1587. elif hideVST3 and ptype == PLUGIN_VST3:
  1588. self.ui.tableWidget.hideRow(i)
  1589. elif hideAU and ptype == PLUGIN_AU:
  1590. self.ui.tableWidget.hideRow(i)
  1591. elif hideNative and isNative:
  1592. self.ui.tableWidget.hideRow(i)
  1593. elif hideBridged and isBridged:
  1594. self.ui.tableWidget.hideRow(i)
  1595. elif hideBridgedWine and isBridgedWine:
  1596. self.ui.tableWidget.hideRow(i)
  1597. elif hideNonRtSafe and not isRtSafe:
  1598. self.ui.tableWidget.hideRow(i)
  1599. elif hideNonCV and not hasCV:
  1600. self.ui.tableWidget.hideRow(i)
  1601. elif hideNonGui and not hasGui:
  1602. self.ui.tableWidget.hideRow(i)
  1603. elif hideNonIDisp and not hasIDisp:
  1604. self.ui.tableWidget.hideRow(i)
  1605. elif hideNonStereo and not isStereo:
  1606. self.ui.tableWidget.hideRow(i)
  1607. elif text and not all(t in ptext for t in text.strip().split(' ')):
  1608. self.ui.tableWidget.hideRow(i)
  1609. elif hideNonFavs and self._createFavoritePluginDict(plugin) not in self.fFavoritePlugins:
  1610. self.ui.tableWidget.hideRow(i)
  1611. elif (self.ui.ch_cat_all.isChecked() or
  1612. (self.ui.ch_cat_delay.isChecked() and categ == "delay") or
  1613. (self.ui.ch_cat_distortion.isChecked() and categ == "distortion") or
  1614. (self.ui.ch_cat_dynamics.isChecked() and categ == "dynamics") or
  1615. (self.ui.ch_cat_eq.isChecked() and categ == "eq") or
  1616. (self.ui.ch_cat_filter.isChecked() and categ == "filter") or
  1617. (self.ui.ch_cat_modulator.isChecked() and categ == "modulator") or
  1618. (self.ui.ch_cat_synth.isChecked() and categ == "synth") or
  1619. (self.ui.ch_cat_utility.isChecked() and categ == "utility") or
  1620. (self.ui.ch_cat_other.isChecked() and categ == "other")):
  1621. self.ui.tableWidget.showRow(i)
  1622. else:
  1623. self.ui.tableWidget.hideRow(i)
  1624. # --------------------------------------------------------------------------------------------------------
  1625. def _addPluginToTable(self, plugin, ptype):
  1626. if plugin['API'] != PLUGIN_QUERY_API_VERSION:
  1627. return
  1628. if ptype in (self.tr("Internal"), "LV2", "SF2", "SFZ"):
  1629. plugin['build'] = BINARY_NATIVE
  1630. index = self.fLastTableIndex
  1631. isFav = bool(self._createFavoritePluginDict(plugin) in self.fFavoritePlugins)
  1632. favItem = QTableWidgetItem()
  1633. favItem.setCheckState(Qt.Checked if isFav else Qt.Unchecked)
  1634. favItem.setText(" " if isFav else " ")
  1635. pluginText = (plugin['name']+plugin['label']+plugin['maker']+plugin['filename']).lower()
  1636. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_FAVORITE, favItem)
  1637. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_NAME, QTableWidgetItem(plugin['name']))
  1638. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_LABEL, QTableWidgetItem(plugin['label']))
  1639. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_MAKER, QTableWidgetItem(plugin['maker']))
  1640. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_BINARY, QTableWidgetItem(os.path.basename(plugin['filename'])))
  1641. self.ui.tableWidget.item(index, self.TABLEWIDGET_ITEM_NAME).setData(Qt.UserRole+1, plugin)
  1642. self.ui.tableWidget.item(index, self.TABLEWIDGET_ITEM_NAME).setData(Qt.UserRole+2, pluginText)
  1643. self.fLastTableIndex += 1
  1644. # --------------------------------------------------------------------------------------------------------
  1645. def _reAddInternalHelper(self, settingsDB, ptype, path):
  1646. if ptype == PLUGIN_INTERNAL:
  1647. ptypeStr = "Internal"
  1648. ptypeStrTr = self.tr("Internal")
  1649. elif ptype == PLUGIN_LV2:
  1650. ptypeStr = "LV2"
  1651. ptypeStrTr = ptypeStr
  1652. elif ptype == PLUGIN_AU:
  1653. ptypeStr = "AU"
  1654. ptypeStrTr = ptypeStr
  1655. #elif ptype == PLUGIN_SFZ:
  1656. #ptypeStr = "SFZ"
  1657. #ptypeStrTr = ptypeStr
  1658. else:
  1659. return 0
  1660. plugins = settingsDB.value("Plugins/" + ptypeStr, [], list)
  1661. pluginCount = settingsDB.value("PluginCount/" + ptypeStr, 0, int)
  1662. if ptype == PLUGIN_AU:
  1663. gCarla.utils.juce_init()
  1664. pluginCountNew = gCarla.utils.get_cached_plugin_count(ptype, path)
  1665. if pluginCountNew != pluginCount or len(plugins) != pluginCount or (len(plugins) > 0 and plugins[0]['API'] != PLUGIN_QUERY_API_VERSION):
  1666. plugins = []
  1667. pluginCount = pluginCountNew
  1668. QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50)
  1669. if ptype == PLUGIN_AU:
  1670. gCarla.utils.juce_idle()
  1671. for i in range(pluginCountNew):
  1672. descInfo = gCarla.utils.get_cached_plugin_info(ptype, i)
  1673. if not descInfo['valid']:
  1674. continue
  1675. info = checkPluginCached(descInfo, ptype)
  1676. plugins.append(info)
  1677. if i % 50 == 0:
  1678. QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50)
  1679. if ptype == PLUGIN_AU:
  1680. gCarla.utils.juce_idle()
  1681. settingsDB.setValue("Plugins/" + ptypeStr, plugins)
  1682. settingsDB.setValue("PluginCount/" + ptypeStr, pluginCount)
  1683. if ptype == PLUGIN_AU:
  1684. gCarla.utils.juce_cleanup()
  1685. # prepare rows in advance
  1686. self.ui.tableWidget.setRowCount(self.fLastTableIndex + len(plugins))
  1687. for plugin in plugins:
  1688. self._addPluginToTable(plugin, ptypeStrTr)
  1689. return pluginCount
  1690. def _reAddPlugins(self):
  1691. settingsDB = QSafeSettings("falkTX", "CarlaPlugins5")
  1692. self.fLastTableIndex = 0
  1693. self.ui.tableWidget.setSortingEnabled(False)
  1694. self.ui.tableWidget.clearContents()
  1695. settings = QSafeSettings("falkTX", "Carla2")
  1696. LV2_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list))
  1697. del settings
  1698. # ----------------------------------------------------------------------------------------------------
  1699. # plugins handled through backend
  1700. internalCount = self._reAddInternalHelper(settingsDB, PLUGIN_INTERNAL, "")
  1701. lv2Count = self._reAddInternalHelper(settingsDB, PLUGIN_LV2, LV2_PATH)
  1702. auCount = self._reAddInternalHelper(settingsDB, PLUGIN_AU, "") if MACOS else 0
  1703. # ----------------------------------------------------------------------------------------------------
  1704. # LADSPA
  1705. ladspaPlugins = []
  1706. ladspaPlugins += settingsDB.value("Plugins/LADSPA_native", [], list)
  1707. ladspaPlugins += settingsDB.value("Plugins/LADSPA_posix32", [], list)
  1708. ladspaPlugins += settingsDB.value("Plugins/LADSPA_posix64", [], list)
  1709. ladspaPlugins += settingsDB.value("Plugins/LADSPA_win32", [], list)
  1710. ladspaPlugins += settingsDB.value("Plugins/LADSPA_win64", [], list)
  1711. # ----------------------------------------------------------------------------------------------------
  1712. # DSSI
  1713. dssiPlugins = []
  1714. dssiPlugins += settingsDB.value("Plugins/DSSI_native", [], list)
  1715. dssiPlugins += settingsDB.value("Plugins/DSSI_posix32", [], list)
  1716. dssiPlugins += settingsDB.value("Plugins/DSSI_posix64", [], list)
  1717. dssiPlugins += settingsDB.value("Plugins/DSSI_win32", [], list)
  1718. dssiPlugins += settingsDB.value("Plugins/DSSI_win64", [], list)
  1719. # ----------------------------------------------------------------------------------------------------
  1720. # VST2
  1721. vst2Plugins = []
  1722. vst2Plugins += settingsDB.value("Plugins/VST2_native", [], list)
  1723. vst2Plugins += settingsDB.value("Plugins/VST2_posix32", [], list)
  1724. vst2Plugins += settingsDB.value("Plugins/VST2_posix64", [], list)
  1725. vst2Plugins += settingsDB.value("Plugins/VST2_win32", [], list)
  1726. vst2Plugins += settingsDB.value("Plugins/VST2_win64", [], list)
  1727. # ----------------------------------------------------------------------------------------------------
  1728. # VST3
  1729. vst3Plugins = []
  1730. vst3Plugins += settingsDB.value("Plugins/VST3_native", [], list)
  1731. vst3Plugins += settingsDB.value("Plugins/VST3_posix32", [], list)
  1732. vst3Plugins += settingsDB.value("Plugins/VST3_posix64", [], list)
  1733. vst3Plugins += settingsDB.value("Plugins/VST3_win32", [], list)
  1734. vst3Plugins += settingsDB.value("Plugins/VST3_win64", [], list)
  1735. # ----------------------------------------------------------------------------------------------------
  1736. # AU (extra non-cached)
  1737. auPlugins32 = settingsDB.value("Plugins/AU_posix32", [], list) if MACOS else []
  1738. # ----------------------------------------------------------------------------------------------------
  1739. # Kits
  1740. sf2s = settingsDB.value("Plugins/SF2", [], list)
  1741. sfzs = settingsDB.value("Plugins/SFZ", [], list)
  1742. # ----------------------------------------------------------------------------------------------------
  1743. # count plugins first, so we can create rows in advance
  1744. ladspaCount = 0
  1745. dssiCount = 0
  1746. vstCount = 0
  1747. vst3Count = 0
  1748. au32Count = 0
  1749. sf2Count = 0
  1750. sfzCount = len(sfzs)
  1751. for plugins in ladspaPlugins:
  1752. ladspaCount += len(plugins)
  1753. for plugins in dssiPlugins:
  1754. dssiCount += len(plugins)
  1755. for plugins in vst2Plugins:
  1756. vstCount += len(plugins)
  1757. for plugins in vst3Plugins:
  1758. vst3Count += len(plugins)
  1759. for plugins in auPlugins32:
  1760. au32Count += len(plugins)
  1761. for plugins in sf2s:
  1762. sf2Count += len(plugins)
  1763. self.ui.tableWidget.setRowCount(self.fLastTableIndex +
  1764. ladspaCount + dssiCount + vstCount + vst3Count + au32Count +
  1765. sf2Count + sfzCount)
  1766. if MACOS:
  1767. 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" % (
  1768. internalCount, ladspaCount, dssiCount, lv2Count, vstCount, vst3Count, auCount+au32Count, sf2Count+sfzCount)))
  1769. else:
  1770. 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" % (
  1771. internalCount, ladspaCount, dssiCount, lv2Count, vstCount, vst3Count, sf2Count+sfzCount)))
  1772. # ----------------------------------------------------------------------------------------------------
  1773. # now add all plugins to the table
  1774. for plugins in ladspaPlugins:
  1775. for plugin in plugins:
  1776. self._addPluginToTable(plugin, "LADSPA")
  1777. for plugins in dssiPlugins:
  1778. for plugin in plugins:
  1779. self._addPluginToTable(plugin, "DSSI")
  1780. for plugins in vst2Plugins:
  1781. for plugin in plugins:
  1782. self._addPluginToTable(plugin, "VST2")
  1783. for plugins in vst3Plugins:
  1784. for plugin in plugins:
  1785. self._addPluginToTable(plugin, "VST3")
  1786. for plugins in auPlugins32:
  1787. for plugin in plugins:
  1788. self._addPluginToTable(plugin, "AU")
  1789. for sf2 in sf2s:
  1790. for sf2_i in sf2:
  1791. self._addPluginToTable(sf2_i, "SF2")
  1792. for sfz in sfzs:
  1793. self._addPluginToTable(sfz, "SFZ")
  1794. # ----------------------------------------------------------------------------------------------------
  1795. self.ui.tableWidget.setSortingEnabled(True)
  1796. self._checkFilters()
  1797. self.slot_checkPlugin(self.ui.tableWidget.currentRow())
  1798. # --------------------------------------------------------------------------------------------------------
  1799. def showEvent(self, event):
  1800. self.slot_focusSearchFieldAndSelectAll()
  1801. QDialog.showEvent(self, event)
  1802. # ---------------------------------------------------------------------------------------------------------------------
  1803. # Jack Application Dialog
  1804. class JackApplicationW(QDialog):
  1805. SESSION_MGR_NONE = 0
  1806. SESSION_MGR_AUTO = 1
  1807. SESSION_MGR_JACK = 2
  1808. SESSION_MGR_LADISH = 3
  1809. SESSION_MGR_NSM = 4
  1810. UI_SESSION_NONE = 0
  1811. UI_SESSION_LADISH = 1
  1812. UI_SESSION_NSM = 2
  1813. FLAG_CONTROL_WINDOW = 0x01
  1814. FLAG_CAPTURE_FIRST_WINDOW = 0x02
  1815. FLAG_BUFFERS_ADDITION_MODE = 0x10
  1816. FLAG_MIDI_OUTPUT_CHANNEL_MIXDOWN = 0x20
  1817. FLAG_EXTERNAL_START = 0x40
  1818. def __init__(self, parent, projectFilename):
  1819. QDialog.__init__(self, parent)
  1820. self.ui = ui_carla_add_jack.Ui_Dialog()
  1821. self.ui.setupUi(self)
  1822. print("Add JACK Application: current project filename is '%s'" % (projectFilename,))
  1823. self.fProjectFilename = projectFilename
  1824. self.ui.group_error.setVisible(False)
  1825. self.adjustSize()
  1826. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  1827. # --------------------------------------------------------------------------------------------------------------
  1828. # Load settings
  1829. self.loadSettings()
  1830. # --------------------------------------------------------------------------------------------------------------
  1831. # Set-up connections
  1832. self.finished.connect(self.slot_saveSettings)
  1833. self.ui.cb_session_mgr.currentIndexChanged.connect(self.slot_sessionManagerChanged)
  1834. self.ui.le_command.textChanged.connect(self.slot_commandChanged)
  1835. # -----------------------------------------------------------------------------------------------------------------
  1836. def getCommandAndFlags(self):
  1837. name = self.ui.le_name.text()
  1838. command = self.ui.le_command.text()
  1839. smgr = self.SESSION_MGR_NONE
  1840. flags = 0x0
  1841. if not name:
  1842. name = os.path.basename(command.split(" ",1)[0]).title()
  1843. uiSessionMgrIndex = self.ui.cb_session_mgr.currentIndex()
  1844. if uiSessionMgrIndex == self.UI_SESSION_LADISH:
  1845. smgr = self.SESSION_MGR_LADISH
  1846. elif uiSessionMgrIndex == self.UI_SESSION_NSM:
  1847. smgr = self.SESSION_MGR_NSM
  1848. if self.ui.cb_manage_window.isChecked():
  1849. flags |= self.FLAG_CONTROL_WINDOW
  1850. if self.ui.cb_capture_first_window.isChecked():
  1851. flags |= self.FLAG_CAPTURE_FIRST_WINDOW
  1852. if self.ui.cb_buffers_addition_mode.isChecked():
  1853. flags |= self.FLAG_BUFFERS_ADDITION_MODE
  1854. if self.ui.cb_out_midi_mixdown.isChecked():
  1855. flags |= self.FLAG_MIDI_OUTPUT_CHANNEL_MIXDOWN
  1856. if self.ui.cb_external_start.isChecked():
  1857. flags |= self.FLAG_EXTERNAL_START
  1858. baseIntVal = ord('0')
  1859. labelSetup = "%s%s%s%s%s%s" % (chr(baseIntVal+self.ui.sb_audio_ins.value()),
  1860. chr(baseIntVal+self.ui.sb_audio_outs.value()),
  1861. chr(baseIntVal+self.ui.sb_midi_ins.value()),
  1862. chr(baseIntVal+self.ui.sb_midi_outs.value()),
  1863. chr(baseIntVal+smgr),
  1864. chr(baseIntVal+flags))
  1865. return (command, name, labelSetup)
  1866. def checkIfButtonBoxShouldBeEnabled(self, index, text):
  1867. enabled = len(text) > 0
  1868. showErr = ""
  1869. # NSM applications must not be abstract or absolute paths, and must not contain arguments
  1870. if enabled and index == self.UI_SESSION_NSM:
  1871. if text[0] in (".", "/"):
  1872. showErr = self.tr("NSM applications cannot use abstract or absolute paths")
  1873. elif " " in text or ";" in text or "&" in text:
  1874. showErr = self.tr("NSM applications cannot use CLI arguments")
  1875. elif len(self.fProjectFilename) == 0:
  1876. showErr = self.tr("You need to save the current Carla project before NSM can be used")
  1877. if showErr:
  1878. enabled = False
  1879. self.ui.l_error.setText(showErr)
  1880. self.ui.group_error.setVisible(True)
  1881. else:
  1882. self.ui.group_error.setVisible(False)
  1883. self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
  1884. def loadSettings(self):
  1885. settings = QSafeSettings("falkTX", "CarlaAddJackApp")
  1886. smName = settings.value("SessionManager", "", str)
  1887. if smName == "LADISH (SIGUSR1)":
  1888. self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_LADISH)
  1889. elif smName == "NSM":
  1890. self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_NSM)
  1891. else:
  1892. self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_NONE)
  1893. self.ui.le_command.setText(settings.value("Command", "", str))
  1894. self.ui.le_name.setText(settings.value("Name", "", str))
  1895. self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, int))
  1896. self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, int))
  1897. self.ui.sb_audio_outs.setValue(settings.value("NumAudioOuts", 2, int))
  1898. self.ui.sb_midi_ins.setValue(settings.value("NumMidiIns", 0, int))
  1899. self.ui.sb_midi_outs.setValue(settings.value("NumMidiOuts", 0, int))
  1900. self.ui.cb_manage_window.setChecked(settings.value("ManageWindow", True, bool))
  1901. self.ui.cb_capture_first_window.setChecked(settings.value("CaptureFirstWindow", False, bool))
  1902. self.ui.cb_out_midi_mixdown.setChecked(settings.value("MidiOutMixdown", False, bool))
  1903. self.checkIfButtonBoxShouldBeEnabled(self.ui.cb_session_mgr.currentIndex(),
  1904. self.ui.le_command.text())
  1905. # -----------------------------------------------------------------------------------------------------------------
  1906. @pyqtSlot(str)
  1907. def slot_commandChanged(self, text):
  1908. self.checkIfButtonBoxShouldBeEnabled(self.ui.cb_session_mgr.currentIndex(), text)
  1909. @pyqtSlot(int)
  1910. def slot_sessionManagerChanged(self, index):
  1911. self.checkIfButtonBoxShouldBeEnabled(index, self.ui.le_command.text())
  1912. @pyqtSlot()
  1913. def slot_saveSettings(self):
  1914. settings = QSafeSettings("falkTX", "CarlaAddJackApp")
  1915. settings.setValue("Command", self.ui.le_command.text())
  1916. settings.setValue("Name", self.ui.le_name.text())
  1917. settings.setValue("SessionManager", self.ui.cb_session_mgr.currentText())
  1918. settings.setValue("NumAudioIns", self.ui.sb_audio_ins.value())
  1919. settings.setValue("NumAudioOuts", self.ui.sb_audio_outs.value())
  1920. settings.setValue("NumMidiIns", self.ui.sb_midi_ins.value())
  1921. settings.setValue("NumMidiOuts", self.ui.sb_midi_outs.value())
  1922. settings.setValue("ManageWindow", self.ui.cb_manage_window.isChecked())
  1923. settings.setValue("CaptureFirstWindow", self.ui.cb_capture_first_window.isChecked())
  1924. settings.setValue("MidiOutMixdown", self.ui.cb_out_midi_mixdown.isChecked())
  1925. # ---------------------------------------------------------------------------------------------------------------------
  1926. # Main
  1927. if __name__ == '__main__':
  1928. from carla_app import CarlaApplication
  1929. from carla_host import initHost as _initHost, loadHostSettings as _loadHostSettings
  1930. # pylint: disable=ungrouped-imports
  1931. from carla_shared import handleInitialCommandLineArguments
  1932. # pylint: enable=ungrouped-imports
  1933. initName, libPrefix = handleInitialCommandLineArguments(__file__ if "__file__" in dir() else None)
  1934. app = CarlaApplication("Carla2-Database", libPrefix)
  1935. host = _initHost("Carla2-Database", libPrefix, False, False, False)
  1936. _loadHostSettings(host)
  1937. gui = PluginDatabaseW(None, host, True)
  1938. #gui = PluginRefreshW(None, host, True)
  1939. gui.show()
  1940. app.exit_exec()
  1941. # ------------------------------------------------------------------------------------------------------------