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.

2415 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. # FIXME?
  256. tmp = gDiscoveryProcess
  257. gDiscoveryProcess = None
  258. del gDiscoveryProcess, tmp
  259. return plugins
  260. def killDiscovery():
  261. global gDiscoveryProcess
  262. if gDiscoveryProcess is not None:
  263. gDiscoveryProcess.kill()
  264. def checkPluginCached(desc, ptype):
  265. pinfo = deepcopy(PyPluginInfo)
  266. pinfo['build'] = BINARY_NATIVE
  267. pinfo['type'] = ptype
  268. pinfo['hints'] = desc['hints']
  269. pinfo['name'] = desc['name']
  270. pinfo['label'] = desc['label']
  271. pinfo['maker'] = desc['maker']
  272. pinfo['category'] = getPluginCategoryAsString(desc['category'])
  273. pinfo['audio.ins'] = desc['audioIns']
  274. pinfo['audio.outs'] = desc['audioOuts']
  275. pinfo['cv.ins'] = desc['cvIns']
  276. pinfo['cv.outs'] = desc['cvOuts']
  277. pinfo['midi.ins'] = desc['midiIns']
  278. pinfo['midi.outs'] = desc['midiOuts']
  279. pinfo['parameters.ins'] = desc['parameterIns']
  280. pinfo['parameters.outs'] = desc['parameterOuts']
  281. if ptype == PLUGIN_LV2:
  282. pinfo['filename'], pinfo['label'] = pinfo['label'].split('\\' if WINDOWS else '/',1)
  283. elif ptype == PLUGIN_SFZ:
  284. pinfo['filename'] = pinfo['label']
  285. pinfo['label'] = pinfo['name']
  286. return pinfo
  287. def checkPluginLADSPA(filename, tool, wineSettings=None):
  288. return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, wineSettings)
  289. def checkPluginDSSI(filename, tool, wineSettings=None):
  290. return runCarlaDiscovery(PLUGIN_DSSI, "DSSI", filename, tool, wineSettings)
  291. def checkPluginLV2(filename, tool, wineSettings=None):
  292. return runCarlaDiscovery(PLUGIN_LV2, "LV2", filename, tool, wineSettings)
  293. def checkPluginVST2(filename, tool, wineSettings=None):
  294. return runCarlaDiscovery(PLUGIN_VST2, "VST2", filename, tool, wineSettings)
  295. def checkPluginVST3(filename, tool, wineSettings=None):
  296. return runCarlaDiscovery(PLUGIN_VST3, "VST3", filename, tool, wineSettings)
  297. def checkFileSF2(filename, tool):
  298. return runCarlaDiscovery(PLUGIN_SF2, "SF2", filename, tool)
  299. def checkFileSFZ(filename, tool):
  300. return runCarlaDiscovery(PLUGIN_SFZ, "SFZ", filename, tool)
  301. def checkAllPluginsAU(tool):
  302. return runCarlaDiscovery(PLUGIN_AU, "AU", ":all", tool)
  303. # ---------------------------------------------------------------------------------------------------------------------
  304. # Separate Thread for Plugin Search
  305. class SearchPluginsThread(QThread):
  306. pluginLook = pyqtSignal(int, str)
  307. def __init__(self, parent, pathBinaries):
  308. QThread.__init__(self, parent)
  309. self.fContinueChecking = False
  310. self.fPathBinaries = pathBinaries
  311. self.fCheckNative = False
  312. self.fCheckPosix32 = False
  313. self.fCheckPosix64 = False
  314. self.fCheckWin32 = False
  315. self.fCheckWin64 = False
  316. self.fCheckLADSPA = False
  317. self.fCheckDSSI = False
  318. self.fCheckLV2 = False
  319. self.fCheckVST2 = False
  320. self.fCheckVST3 = False
  321. self.fCheckAU = False
  322. self.fCheckSF2 = False
  323. self.fCheckSFZ = False
  324. if WINDOWS:
  325. toolNative = "carla-discovery-win64.exe" if kIs64bit else "carla-discovery-win32.exe"
  326. self.fWineSettings = None
  327. else:
  328. toolNative = "carla-discovery-native"
  329. settings = QSafeSettings("falkTX", "Carla2")
  330. self.fWineSettings = {
  331. 'executable' : settings.value(CARLA_KEY_WINE_EXECUTABLE, CARLA_DEFAULT_WINE_EXECUTABLE, str),
  332. 'autoPrefix' : settings.value(CARLA_KEY_WINE_AUTO_PREFIX, CARLA_DEFAULT_WINE_AUTO_PREFIX, bool),
  333. 'fallbackPrefix': settings.value(CARLA_KEY_WINE_FALLBACK_PREFIX, CARLA_DEFAULT_WINE_FALLBACK_PREFIX, str)
  334. }
  335. del settings
  336. self.fToolNative = os.path.join(pathBinaries, toolNative)
  337. if not os.path.exists(self.fToolNative):
  338. self.fToolNative = ""
  339. self.fCurCount = 0
  340. self.fCurPercentValue = 0
  341. self.fLastCheckValue = 0
  342. self.fSomethingChanged = False
  343. # -------------------------------------------------------------
  344. def hasSomethingChanged(self):
  345. return self.fSomethingChanged
  346. def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64):
  347. self.fCheckNative = native
  348. self.fCheckPosix32 = posix32
  349. self.fCheckPosix64 = posix64
  350. self.fCheckWin32 = win32
  351. self.fCheckWin64 = win64
  352. def setSearchPluginTypes(self, ladspa, dssi, lv2, vst2, vst3, au, sf2, sfz):
  353. self.fCheckLADSPA = ladspa
  354. self.fCheckDSSI = dssi
  355. self.fCheckLV2 = lv2
  356. self.fCheckVST2 = vst2
  357. self.fCheckVST3 = vst3 and (LINUX or MACOS or WINDOWS)
  358. self.fCheckAU = au and MACOS
  359. self.fCheckSF2 = sf2
  360. self.fCheckSFZ = sfz
  361. def stop(self):
  362. self.fContinueChecking = False
  363. def run(self):
  364. settingsDB = QSafeSettings("falkTX", "CarlaPlugins5")
  365. self.fContinueChecking = True
  366. self.fCurCount = 0
  367. # looking for plugins via external discovery
  368. pluginCount = 0
  369. if self.fCheckLADSPA: pluginCount += 1
  370. if self.fCheckDSSI: pluginCount += 1
  371. if self.fCheckVST2: pluginCount += 1
  372. if self.fCheckVST3: pluginCount += 1
  373. # Increase count by the number of externally discoverable plugin types
  374. if self.fCheckNative:
  375. self.fCurCount += pluginCount
  376. # Linux, MacOS and Windows are the only VST3 supported OSes
  377. if self.fCheckVST3 and not (LINUX or MACOS or WINDOWS):
  378. self.fCurCount -= 1
  379. if self.fCheckPosix32:
  380. self.fCurCount += pluginCount
  381. if self.fCheckVST3 and not (LINUX or MACOS):
  382. self.fCurCount -= 1
  383. if self.fCheckPosix64:
  384. self.fCurCount += pluginCount
  385. if self.fCheckVST3 and not (LINUX or MACOS):
  386. self.fCurCount -= 1
  387. if self.fCheckWin32:
  388. self.fCurCount += pluginCount
  389. if self.fCheckWin64:
  390. self.fCurCount += pluginCount
  391. # Special case for cached plugins, only "search" for native plugins (does not need tool)
  392. if self.fCheckLV2:
  393. if self.fCheckNative:
  394. self.fCurCount += 1
  395. else:
  396. self.fCheckLV2 = False
  397. if self.fCheckAU:
  398. if self.fCheckNative or self.fCheckPosix32:
  399. self.fCurCount += int(self.fCheckNative) + int(self.fCheckPosix32)
  400. else:
  401. self.fCheckAU = False
  402. if self.fCheckSFZ:
  403. if self.fCheckNative:
  404. self.fCurCount += 1
  405. else:
  406. self.fCheckSFZ = False
  407. # Special case for Sound Kits, only search native
  408. if self.fCheckNative and self.fToolNative:
  409. if self.fCheckSF2: self.fCurCount += 1
  410. else:
  411. self.fCheckSF2 = False
  412. if self.fCurCount == 0:
  413. return
  414. self.fCurPercentValue = 100.0 / self.fCurCount
  415. self.fLastCheckValue = 0.0
  416. del pluginCount
  417. if HAIKU:
  418. OS = "HAIKU"
  419. elif LINUX:
  420. OS = "LINUX"
  421. elif MACOS:
  422. OS = "MACOS"
  423. elif WINDOWS:
  424. OS = "WINDOWS"
  425. else:
  426. OS = "UNKNOWN"
  427. if not self.fContinueChecking: return
  428. self.fSomethingChanged = True
  429. if self.fCheckLADSPA:
  430. checkValue = 0.0
  431. if haveLRDF:
  432. if self.fCheckNative: checkValue += 0.1
  433. if self.fCheckPosix32: checkValue += 0.1
  434. if self.fCheckPosix64: checkValue += 0.1
  435. if self.fCheckWin32: checkValue += 0.1
  436. if self.fCheckWin64: checkValue += 0.1
  437. rdfPadValue = self.fCurPercentValue * checkValue
  438. if self.fCheckNative:
  439. plugins = self._checkLADSPA(OS, self.fToolNative)
  440. settingsDB.setValue("Plugins/LADSPA_native", plugins)
  441. if not self.fContinueChecking: return
  442. if self.fCheckPosix32:
  443. plugins = self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  444. settingsDB.setValue("Plugins/LADSPA_posix32", plugins)
  445. if not self.fContinueChecking: return
  446. if self.fCheckPosix64:
  447. plugins = self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  448. settingsDB.setValue("Plugins/LADSPA_posix64", plugins)
  449. if not self.fContinueChecking: return
  450. if self.fCheckWin32:
  451. plugins = self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  452. settingsDB.setValue("Plugins/LADSPA_win32", plugins)
  453. if not self.fContinueChecking: return
  454. if self.fCheckWin64:
  455. plugins = self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  456. settingsDB.setValue("Plugins/LADSPA_win64", plugins)
  457. settingsDB.sync()
  458. if not self.fContinueChecking: return
  459. if haveLRDF and checkValue > 0:
  460. startValue = self.fLastCheckValue - rdfPadValue
  461. self._pluginLook(startValue, "LADSPA RDFs...")
  462. try:
  463. ladspaRdfInfo = ladspa_rdf.recheck_all_plugins(self, startValue, self.fCurPercentValue, checkValue)
  464. except:
  465. ladspaRdfInfo = None
  466. if ladspaRdfInfo is not None:
  467. settingsDir = os.path.join(HOME, ".config", "falkTX")
  468. fdLadspa = open(os.path.join(settingsDir, "ladspa_rdf.db"), 'w')
  469. json.dump(ladspaRdfInfo, fdLadspa)
  470. fdLadspa.close()
  471. if not self.fContinueChecking: return
  472. if self.fCheckDSSI:
  473. if self.fCheckNative:
  474. plugins = self._checkDSSI(OS, self.fToolNative)
  475. settingsDB.setValue("Plugins/DSSI_native", plugins)
  476. if not self.fContinueChecking: return
  477. if self.fCheckPosix32:
  478. plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  479. settingsDB.setValue("Plugins/DSSI_posix32", plugins)
  480. if not self.fContinueChecking: return
  481. if self.fCheckPosix64:
  482. plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  483. settingsDB.setValue("Plugins/DSSI_posix64", plugins)
  484. if not self.fContinueChecking: return
  485. if self.fCheckWin32:
  486. plugins = self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  487. settingsDB.setValue("Plugins/DSSI_win32", plugins)
  488. if not self.fContinueChecking: return
  489. if self.fCheckWin64:
  490. plugins = self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  491. settingsDB.setValue("Plugins/DSSI_win64", plugins)
  492. settingsDB.sync()
  493. if not self.fContinueChecking: return
  494. if self.fCheckLV2:
  495. plugins = self._checkCached(True)
  496. settingsDB.setValue("Plugins/LV2", plugins)
  497. settingsDB.sync()
  498. if not self.fContinueChecking: return
  499. if self.fCheckVST2:
  500. if self.fCheckNative:
  501. plugins = self._checkVST2(OS, self.fToolNative)
  502. settingsDB.setValue("Plugins/VST2_native", plugins)
  503. if not self.fContinueChecking: return
  504. if self.fCheckPosix32:
  505. plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  506. settingsDB.setValue("Plugins/VST2_posix32", plugins)
  507. if not self.fContinueChecking: return
  508. if self.fCheckPosix64:
  509. plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  510. settingsDB.setValue("Plugins/VST2_posix64", plugins)
  511. if not self.fContinueChecking: return
  512. if self.fCheckWin32:
  513. plugins = self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  514. settingsDB.setValue("Plugins/VST2_win32", plugins)
  515. if not self.fContinueChecking: return
  516. if self.fCheckWin64:
  517. plugins = self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  518. settingsDB.setValue("Plugins/VST2_win64", plugins)
  519. if not self.fContinueChecking: return
  520. settingsDB.sync()
  521. if not self.fContinueChecking: return
  522. if self.fCheckVST3:
  523. if self.fCheckNative and (LINUX or MACOS or WINDOWS):
  524. plugins = self._checkVST3(OS, self.fToolNative)
  525. settingsDB.setValue("Plugins/VST3_native", plugins)
  526. if not self.fContinueChecking: return
  527. if self.fCheckPosix32:
  528. plugins = self._checkVST3(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  529. settingsDB.setValue("Plugins/VST3_posix32", plugins)
  530. if not self.fContinueChecking: return
  531. if self.fCheckPosix64:
  532. plugins = self._checkVST3(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  533. settingsDB.setValue("Plugins/VST3_posix64", plugins)
  534. if not self.fContinueChecking: return
  535. if self.fCheckWin32:
  536. plugins = self._checkVST3("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS)
  537. settingsDB.setValue("Plugins/VST3_win32", plugins)
  538. if not self.fContinueChecking: return
  539. if self.fCheckWin64:
  540. plugins = self._checkVST3("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS)
  541. settingsDB.setValue("Plugins/VST3_win64", plugins)
  542. if not self.fContinueChecking: return
  543. settingsDB.sync()
  544. if not self.fContinueChecking: return
  545. if self.fCheckAU:
  546. if self.fCheckNative:
  547. plugins = self._checkCached(False)
  548. settingsDB.setValue("Plugins/AU", plugins)
  549. settingsDB.sync()
  550. if not self.fContinueChecking: return
  551. if self.fCheckPosix32:
  552. plugins = self._checkAU(os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  553. settingsDB.setValue("Plugins/AU_posix32", self.fAuPlugins)
  554. if not self.fContinueChecking: return
  555. settingsDB.sync()
  556. if not self.fContinueChecking: return
  557. if self.fCheckSF2:
  558. settings = QSafeSettings("falkTX", "Carla2")
  559. SF2_PATH = settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH, list)
  560. del settings
  561. kits = self._checkKIT(SF2_PATH, "sf2")
  562. settingsDB.setValue("Plugins/SF2", kits)
  563. settingsDB.sync()
  564. if not self.fContinueChecking: return
  565. if self.fCheckSFZ:
  566. kits = self._checkSfzCached()
  567. settingsDB.setValue("Plugins/SFZ", kits)
  568. settingsDB.sync()
  569. def _checkLADSPA(self, OS, tool, isWine=False):
  570. ladspaBinaries = []
  571. ladspaPlugins = []
  572. self._pluginLook(self.fLastCheckValue, "LADSPA plugins...")
  573. settings = QSafeSettings("falkTX", "Carla2")
  574. LADSPA_PATH = settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH, list)
  575. del settings
  576. for iPATH in LADSPA_PATH:
  577. binaries = findBinaries(iPATH, PLUGIN_LADSPA, OS)
  578. for binary in binaries:
  579. if binary not in ladspaBinaries:
  580. ladspaBinaries.append(binary)
  581. ladspaBinaries.sort()
  582. if not self.fContinueChecking:
  583. return ladspaPlugins
  584. for i in range(len(ladspaBinaries)):
  585. ladspa = ladspaBinaries[i]
  586. percent = ( float(i) / len(ladspaBinaries) ) * self.fCurPercentValue
  587. self._pluginLook((self.fLastCheckValue + percent) * 0.9, ladspa)
  588. plugins = checkPluginLADSPA(ladspa, tool, self.fWineSettings if isWine else None)
  589. if plugins:
  590. ladspaPlugins.append(plugins)
  591. if not self.fContinueChecking:
  592. break
  593. self.fLastCheckValue += self.fCurPercentValue
  594. return ladspaPlugins
  595. def _checkDSSI(self, OS, tool, isWine=False):
  596. dssiBinaries = []
  597. dssiPlugins = []
  598. self._pluginLook(self.fLastCheckValue, "DSSI plugins...")
  599. settings = QSafeSettings("falkTX", "Carla2")
  600. DSSI_PATH = settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH, list)
  601. del settings
  602. for iPATH in DSSI_PATH:
  603. binaries = findBinaries(iPATH, PLUGIN_DSSI, OS)
  604. for binary in binaries:
  605. if binary not in dssiBinaries:
  606. dssiBinaries.append(binary)
  607. dssiBinaries.sort()
  608. if not self.fContinueChecking:
  609. return dssiPlugins
  610. for i in range(len(dssiBinaries)):
  611. dssi = dssiBinaries[i]
  612. percent = ( float(i) / len(dssiBinaries) ) * self.fCurPercentValue
  613. self._pluginLook(self.fLastCheckValue + percent, dssi)
  614. plugins = checkPluginDSSI(dssi, tool, self.fWineSettings if isWine else None)
  615. if plugins:
  616. dssiPlugins.append(plugins)
  617. if not self.fContinueChecking:
  618. break
  619. self.fLastCheckValue += self.fCurPercentValue
  620. return dssiPlugins
  621. def _checkVST2(self, OS, tool, isWine=False):
  622. vst2Binaries = []
  623. vst2Plugins = []
  624. if MACOS and not isWine:
  625. self._pluginLook(self.fLastCheckValue, "VST2 bundles...")
  626. else:
  627. self._pluginLook(self.fLastCheckValue, "VST2 plugins...")
  628. settings = QSafeSettings("falkTX", "Carla2")
  629. VST2_PATH = settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH, list)
  630. del settings
  631. for iPATH in VST2_PATH:
  632. if MACOS and not isWine:
  633. binaries = findMacVSTBundles(iPATH, False)
  634. else:
  635. binaries = findBinaries(iPATH, PLUGIN_VST2, OS)
  636. for binary in binaries:
  637. if binary not in vst2Binaries:
  638. vst2Binaries.append(binary)
  639. vst2Binaries.sort()
  640. if not self.fContinueChecking:
  641. return vst2Plugins
  642. for i in range(len(vst2Binaries)):
  643. vst2 = vst2Binaries[i]
  644. percent = ( float(i) / len(vst2Binaries) ) * self.fCurPercentValue
  645. self._pluginLook(self.fLastCheckValue + percent, vst2)
  646. plugins = checkPluginVST2(vst2, tool, self.fWineSettings if isWine else None)
  647. if plugins:
  648. vst2Plugins.append(plugins)
  649. if not self.fContinueChecking:
  650. break
  651. self.fLastCheckValue += self.fCurPercentValue
  652. return vst2Plugins
  653. def _checkVST3(self, OS, tool, isWine=False):
  654. vst3Binaries = []
  655. vst3Plugins = []
  656. if MACOS and not isWine:
  657. self._pluginLook(self.fLastCheckValue, "VST2 bundles...")
  658. else:
  659. self._pluginLook(self.fLastCheckValue, "VST2 plugins...")
  660. settings = QSafeSettings("falkTX", "Carla2")
  661. VST3_PATH = settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH, list)
  662. del settings
  663. for iPATH in VST3_PATH:
  664. if MACOS and not isWine:
  665. binaries = findMacVSTBundles(iPATH, True)
  666. else:
  667. binaries = findVST3Binaries(iPATH)
  668. for binary in binaries:
  669. if binary not in vst3Binaries:
  670. vst3Binaries.append(binary)
  671. vst3Binaries.sort()
  672. if not self.fContinueChecking:
  673. return vst3Plugins
  674. for i in range(len(vst3Binaries)):
  675. vst3 = vst3Binaries[i]
  676. percent = ( float(i) / len(vst3Binaries) ) * self.fCurPercentValue
  677. self._pluginLook(self.fLastCheckValue + percent, vst3)
  678. plugins = checkPluginVST3(vst3, tool, self.fWineSettings if isWine else None)
  679. if plugins:
  680. vst3Plugins.append(plugins)
  681. if not self.fContinueChecking:
  682. break
  683. self.fLastCheckValue += self.fCurPercentValue
  684. return vst3Plugins
  685. def _checkAU(self, tool):
  686. auPlugins = []
  687. plugins = checkAllPluginsAU(tool)
  688. if plugins:
  689. auPlugins.append(plugins)
  690. self.fLastCheckValue += self.fCurPercentValue
  691. return auPlugins
  692. def _checkKIT(self, kitPATH, kitExtension):
  693. kitFiles = []
  694. kitPlugins = []
  695. for iPATH in kitPATH:
  696. files = findFilenames(iPATH, kitExtension)
  697. for file_ in files:
  698. if file_ not in kitFiles:
  699. kitFiles.append(file_)
  700. kitFiles.sort()
  701. if not self.fContinueChecking:
  702. return kitPlugins
  703. for i in range(len(kitFiles)):
  704. kit = kitFiles[i]
  705. percent = ( float(i) / len(kitFiles) ) * self.fCurPercentValue
  706. self._pluginLook(self.fLastCheckValue + percent, kit)
  707. if kitExtension == "sf2":
  708. plugins = checkFileSF2(kit, self.fToolNative)
  709. else:
  710. plugins = None
  711. if plugins:
  712. kitPlugins.append(plugins)
  713. if not self.fContinueChecking:
  714. break
  715. self.fLastCheckValue += self.fCurPercentValue
  716. return kitPlugins
  717. def _checkCached(self, isLV2):
  718. if isLV2:
  719. settings = QSafeSettings("falkTX", "Carla2")
  720. PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list))
  721. del settings
  722. PLUG_TEXT = "LV2"
  723. PLUG_TYPE = PLUGIN_LV2
  724. else: # AU
  725. PLUG_PATH = ""
  726. PLUG_TEXT = "AU"
  727. PLUG_TYPE = PLUGIN_AU
  728. plugins = []
  729. self._pluginLook(self.fLastCheckValue, "{} plugins...".format(PLUG_TEXT))
  730. if not isLV2:
  731. gCarla.utils.juce_init()
  732. count = gCarla.utils.get_cached_plugin_count(PLUG_TYPE, PLUG_PATH)
  733. if not self.fContinueChecking:
  734. return plugins
  735. for i in range(count):
  736. descInfo = gCarla.utils.get_cached_plugin_info(PLUG_TYPE, i)
  737. percent = ( float(i) / count ) * self.fCurPercentValue
  738. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  739. if not descInfo['valid']:
  740. continue
  741. plugins.append(checkPluginCached(descInfo, PLUG_TYPE))
  742. if not self.fContinueChecking:
  743. break
  744. if not isLV2:
  745. gCarla.utils.juce_cleanup()
  746. self.fLastCheckValue += self.fCurPercentValue
  747. return plugins
  748. def _checkSfzCached(self):
  749. settings = QSafeSettings("falkTX", "Carla2")
  750. PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH, list))
  751. del settings
  752. sfzKits = []
  753. self._pluginLook(self.fLastCheckValue, "SFZ kits...")
  754. count = gCarla.utils.get_cached_plugin_count(PLUGIN_SFZ, PLUG_PATH)
  755. if not self.fContinueChecking:
  756. return sfzKits
  757. for i in range(count):
  758. descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_SFZ, i)
  759. percent = ( float(i) / count ) * self.fCurPercentValue
  760. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  761. if not descInfo['valid']:
  762. continue
  763. sfzKits.append(checkPluginCached(descInfo, PLUGIN_SFZ))
  764. if not self.fContinueChecking:
  765. break
  766. self.fLastCheckValue += self.fCurPercentValue
  767. return sfzKits
  768. def _pluginLook(self, percent, plugin):
  769. self.pluginLook.emit(percent, plugin)
  770. # ---------------------------------------------------------------------------------------------------------------------
  771. # Plugin Refresh Dialog
  772. class PluginRefreshW(QDialog):
  773. def __init__(self, parent, host, useSystemIcons):
  774. QDialog.__init__(self, parent)
  775. self.host = host
  776. self.ui = ui_carla_refresh.Ui_PluginRefreshW()
  777. self.ui.setupUi(self)
  778. # -------------------------------------------------------------------------------------------------------------
  779. # Internal stuff
  780. toolNative = "carla-discovery-native.exe" if WINDOWS else "carla-discovery-native"
  781. hasNative = os.path.exists(os.path.join(self.host.pathBinaries, toolNative))
  782. hasPosix32 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-posix32"))
  783. hasPosix64 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-posix64"))
  784. hasWin32 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-win32.exe"))
  785. hasWin64 = os.path.exists(os.path.join(self.host.pathBinaries, "carla-discovery-win64.exe"))
  786. self.fThread = SearchPluginsThread(self, host.pathBinaries)
  787. # -------------------------------------------------------------------------------------------------------------
  788. # Set-up Icons
  789. if useSystemIcons:
  790. self.ui.b_start.setIcon(getIcon('arrow-right', 16, 'svgz'))
  791. self.ui.b_close.setIcon(getIcon('window-close', 16, 'svgz'))
  792. if QT_VERSION >= 0x50600:
  793. size = int(16 * self.devicePixelRatioF())
  794. else:
  795. size = 16
  796. self.fIconYes = QPixmap(getIcon('dialog-ok-apply', 16, 'svgz').pixmap(size))
  797. self.fIconNo = QPixmap(getIcon('dialog-error', 16, 'svgz').pixmap(size))
  798. else:
  799. self.fIconYes = QPixmap(":/16x16/dialog-ok-apply.svgz")
  800. self.fIconNo = QPixmap(":/16x16/dialog-error.svgz")
  801. # -------------------------------------------------------------------------------------------------------------
  802. # Set-up GUI
  803. self.ui.b_skip.setVisible(False)
  804. if HAIKU:
  805. self.ui.ch_posix32.setText("Haiku 32bit")
  806. self.ui.ch_posix64.setText("Haiku 64bit")
  807. elif LINUX:
  808. self.ui.ch_posix32.setText("Linux 32bit")
  809. self.ui.ch_posix64.setText("Linux 64bit")
  810. elif MACOS:
  811. self.ui.ch_posix32.setText("MacOS 32bit")
  812. self.ui.ch_posix64.setText("MacOS 64bit")
  813. if hasPosix32 and not WINDOWS:
  814. self.ui.ico_posix32.setPixmap(self.fIconYes)
  815. else:
  816. self.ui.ico_posix32.setPixmap(self.fIconNo)
  817. self.ui.ch_posix32.setEnabled(False)
  818. if hasPosix64 and not WINDOWS:
  819. self.ui.ico_posix64.setPixmap(self.fIconYes)
  820. else:
  821. self.ui.ico_posix64.setPixmap(self.fIconNo)
  822. self.ui.ch_posix64.setEnabled(False)
  823. if hasWin32:
  824. self.ui.ico_win32.setPixmap(self.fIconYes)
  825. else:
  826. self.ui.ico_win32.setPixmap(self.fIconNo)
  827. self.ui.ch_win32.setEnabled(False)
  828. if hasWin64:
  829. self.ui.ico_win64.setPixmap(self.fIconYes)
  830. else:
  831. self.ui.ico_win64.setPixmap(self.fIconNo)
  832. self.ui.ch_win64.setEnabled(False)
  833. if haveLRDF:
  834. self.ui.ico_rdflib.setPixmap(self.fIconYes)
  835. else:
  836. self.ui.ico_rdflib.setPixmap(self.fIconNo)
  837. if WINDOWS:
  838. if kIs64bit:
  839. hasNonNative = hasWin32
  840. self.ui.ch_win64.setEnabled(False)
  841. self.ui.ch_win64.setVisible(False)
  842. self.ui.ico_win64.setVisible(False)
  843. self.ui.label_win64.setVisible(False)
  844. else:
  845. hasNonNative = hasWin64
  846. self.ui.ch_win32.setEnabled(False)
  847. self.ui.ch_win32.setVisible(False)
  848. self.ui.ico_win32.setVisible(False)
  849. self.ui.label_win32.setVisible(False)
  850. self.ui.ch_posix32.setEnabled(False)
  851. self.ui.ch_posix32.setVisible(False)
  852. self.ui.ch_posix64.setEnabled(False)
  853. self.ui.ch_posix64.setVisible(False)
  854. self.ui.ico_posix32.hide()
  855. self.ui.ico_posix64.hide()
  856. self.ui.label_posix32.hide()
  857. self.ui.label_posix64.hide()
  858. self.ui.ico_rdflib.hide()
  859. self.ui.label_rdflib.hide()
  860. else:
  861. if kIs64bit:
  862. hasNonNative = bool(hasPosix32 or hasWin32 or hasWin64)
  863. self.ui.ch_posix64.setEnabled(False)
  864. self.ui.ch_posix64.setVisible(False)
  865. self.ui.ico_posix64.setVisible(False)
  866. self.ui.label_posix64.setVisible(False)
  867. else:
  868. hasNonNative = bool(hasPosix64 or hasWin32 or hasWin64)
  869. self.ui.ch_posix32.setEnabled(False)
  870. self.ui.ch_posix32.setVisible(False)
  871. self.ui.ico_posix32.setVisible(False)
  872. self.ui.label_posix32.setVisible(False)
  873. if not MACOS:
  874. self.ui.ch_au.setEnabled(False)
  875. self.ui.ch_au.setVisible(False)
  876. if not (LINUX or hasWin32 or hasWin64):
  877. self.ui.ch_vst3.setEnabled(False)
  878. self.ui.ch_vst3.setVisible(False)
  879. if hasNative:
  880. self.ui.ico_native.setPixmap(self.fIconYes)
  881. else:
  882. self.ui.ico_native.setPixmap(self.fIconNo)
  883. self.ui.ch_native.setEnabled(False)
  884. self.ui.ch_sf2.setEnabled(False)
  885. if not hasNonNative:
  886. self.ui.ch_ladspa.setEnabled(False)
  887. self.ui.ch_dssi.setEnabled(False)
  888. self.ui.ch_vst.setEnabled(False)
  889. self.ui.ch_vst3.setEnabled(False)
  890. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  891. # -------------------------------------------------------------------------------------------------------------
  892. # Load settings
  893. self.loadSettings()
  894. # -------------------------------------------------------------------------------------------------------------
  895. # Hide bridges if disabled
  896. # NOTE: We Assume win32 carla build will not run win64 plugins
  897. if (WINDOWS and not kIs64bit) or not host.showPluginBridges:
  898. self.ui.ch_native.setChecked(True)
  899. self.ui.ch_native.setEnabled(False)
  900. self.ui.ch_native.setVisible(False)
  901. self.ui.ch_posix32.setChecked(False)
  902. self.ui.ch_posix32.setEnabled(False)
  903. self.ui.ch_posix32.setVisible(False)
  904. self.ui.ch_posix64.setChecked(False)
  905. self.ui.ch_posix64.setEnabled(False)
  906. self.ui.ch_posix64.setVisible(False)
  907. self.ui.ch_win32.setChecked(False)
  908. self.ui.ch_win32.setEnabled(False)
  909. self.ui.ch_win32.setVisible(False)
  910. self.ui.ch_win64.setChecked(False)
  911. self.ui.ch_win64.setEnabled(False)
  912. self.ui.ch_win64.setVisible(False)
  913. self.ui.ico_posix32.hide()
  914. self.ui.ico_posix64.hide()
  915. self.ui.ico_win32.hide()
  916. self.ui.ico_win64.hide()
  917. self.ui.label_posix32.hide()
  918. self.ui.label_posix64.hide()
  919. self.ui.label_win32.hide()
  920. self.ui.label_win64.hide()
  921. self.ui.sep_format.hide()
  922. elif not (WINDOWS or host.showWineBridges):
  923. self.ui.ch_win32.setChecked(False)
  924. self.ui.ch_win32.setEnabled(False)
  925. self.ui.ch_win32.setVisible(False)
  926. self.ui.ch_win64.setChecked(False)
  927. self.ui.ch_win64.setEnabled(False)
  928. self.ui.ch_win64.setVisible(False)
  929. self.ui.ico_win32.hide()
  930. self.ui.ico_win64.hide()
  931. self.ui.label_win32.hide()
  932. self.ui.label_win64.hide()
  933. # Disable non-supported features
  934. features = gCarla.utils.get_supported_features()
  935. if "sf2" not in features:
  936. self.ui.ch_sf2.setChecked(False)
  937. self.ui.ch_sf2.setEnabled(False)
  938. if MACOS and "juce" not in features:
  939. self.ui.ch_au.setChecked(False)
  940. self.ui.ch_au.setEnabled(False)
  941. # -------------------------------------------------------------------------------------------------------------
  942. # Resize to minimum size, as it's very likely UI stuff was hidden
  943. self.resize(self.minimumSize())
  944. # -------------------------------------------------------------------------------------------------------------
  945. # Set-up connections
  946. self.finished.connect(self.slot_saveSettings)
  947. self.ui.b_start.clicked.connect(self.slot_start)
  948. self.ui.b_skip.clicked.connect(self.slot_skip)
  949. self.ui.ch_native.clicked.connect(self.slot_checkTools)
  950. self.ui.ch_posix32.clicked.connect(self.slot_checkTools)
  951. self.ui.ch_posix64.clicked.connect(self.slot_checkTools)
  952. self.ui.ch_win32.clicked.connect(self.slot_checkTools)
  953. self.ui.ch_win64.clicked.connect(self.slot_checkTools)
  954. self.ui.ch_ladspa.clicked.connect(self.slot_checkTools)
  955. self.ui.ch_dssi.clicked.connect(self.slot_checkTools)
  956. self.ui.ch_lv2.clicked.connect(self.slot_checkTools)
  957. self.ui.ch_vst.clicked.connect(self.slot_checkTools)
  958. self.ui.ch_vst3.clicked.connect(self.slot_checkTools)
  959. self.ui.ch_au.clicked.connect(self.slot_checkTools)
  960. self.ui.ch_sf2.clicked.connect(self.slot_checkTools)
  961. self.ui.ch_sfz.clicked.connect(self.slot_checkTools)
  962. self.fThread.pluginLook.connect(self.slot_handlePluginLook)
  963. self.fThread.finished.connect(self.slot_handlePluginThreadFinished)
  964. # -------------------------------------------------------------------------------------------------------------
  965. # Post-connect setup
  966. self.slot_checkTools()
  967. # -----------------------------------------------------------------------------------------------------------------
  968. def loadSettings(self):
  969. settings = QSafeSettings("falkTX", "CarlaRefresh2")
  970. check = settings.value("PluginDatabase/SearchLADSPA", True, bool) and self.ui.ch_ladspa.isEnabled()
  971. self.ui.ch_ladspa.setChecked(check)
  972. check = settings.value("PluginDatabase/SearchDSSI", True, bool) and self.ui.ch_dssi.isEnabled()
  973. self.ui.ch_dssi.setChecked(check)
  974. check = settings.value("PluginDatabase/SearchLV2", True, bool) and self.ui.ch_lv2.isEnabled()
  975. self.ui.ch_lv2.setChecked(check)
  976. check = settings.value("PluginDatabase/SearchVST2", True, bool) and self.ui.ch_vst.isEnabled()
  977. self.ui.ch_vst.setChecked(check)
  978. check = settings.value("PluginDatabase/SearchVST3", True, bool) and self.ui.ch_vst3.isEnabled()
  979. self.ui.ch_vst3.setChecked(check)
  980. if MACOS:
  981. check = settings.value("PluginDatabase/SearchAU", True, bool) and self.ui.ch_au.isEnabled()
  982. else:
  983. check = False
  984. self.ui.ch_au.setChecked(check)
  985. check = settings.value("PluginDatabase/SearchSF2", False, bool) and self.ui.ch_sf2.isEnabled()
  986. self.ui.ch_sf2.setChecked(check)
  987. check = settings.value("PluginDatabase/SearchSFZ", False, bool) and self.ui.ch_sfz.isEnabled()
  988. self.ui.ch_sfz.setChecked(check)
  989. check = settings.value("PluginDatabase/SearchNative", True, bool) and self.ui.ch_native.isEnabled()
  990. self.ui.ch_native.setChecked(check)
  991. check = settings.value("PluginDatabase/SearchPOSIX32", False, bool) and self.ui.ch_posix32.isEnabled()
  992. self.ui.ch_posix32.setChecked(check)
  993. check = settings.value("PluginDatabase/SearchPOSIX64", False, bool) and self.ui.ch_posix64.isEnabled()
  994. self.ui.ch_posix64.setChecked(check)
  995. check = settings.value("PluginDatabase/SearchWin32", False, bool) and self.ui.ch_win32.isEnabled()
  996. self.ui.ch_win32.setChecked(check)
  997. check = settings.value("PluginDatabase/SearchWin64", False, bool) and self.ui.ch_win64.isEnabled()
  998. self.ui.ch_win64.setChecked(check)
  999. self.ui.ch_do_checks.setChecked(settings.value("PluginDatabase/DoChecks", False, bool))
  1000. # -----------------------------------------------------------------------------------------------------------------
  1001. @pyqtSlot()
  1002. def slot_saveSettings(self):
  1003. settings = QSafeSettings("falkTX", "CarlaRefresh2")
  1004. settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked())
  1005. settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked())
  1006. settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked())
  1007. settings.setValue("PluginDatabase/SearchVST2", self.ui.ch_vst.isChecked())
  1008. settings.setValue("PluginDatabase/SearchVST3", self.ui.ch_vst3.isChecked())
  1009. settings.setValue("PluginDatabase/SearchAU", self.ui.ch_au.isChecked())
  1010. settings.setValue("PluginDatabase/SearchSF2", self.ui.ch_sf2.isChecked())
  1011. settings.setValue("PluginDatabase/SearchSFZ", self.ui.ch_sfz.isChecked())
  1012. settings.setValue("PluginDatabase/SearchNative", self.ui.ch_native.isChecked())
  1013. settings.setValue("PluginDatabase/SearchPOSIX32", self.ui.ch_posix32.isChecked())
  1014. settings.setValue("PluginDatabase/SearchPOSIX64", self.ui.ch_posix64.isChecked())
  1015. settings.setValue("PluginDatabase/SearchWin32", self.ui.ch_win32.isChecked())
  1016. settings.setValue("PluginDatabase/SearchWin64", self.ui.ch_win64.isChecked())
  1017. settings.setValue("PluginDatabase/DoChecks", self.ui.ch_do_checks.isChecked())
  1018. # -----------------------------------------------------------------------------------------------------------------
  1019. @pyqtSlot()
  1020. def slot_start(self):
  1021. self.ui.progressBar.setMinimum(0)
  1022. self.ui.progressBar.setMaximum(100)
  1023. self.ui.progressBar.setValue(0)
  1024. self.ui.b_start.setEnabled(False)
  1025. self.ui.b_skip.setVisible(True)
  1026. self.ui.b_close.setVisible(False)
  1027. self.ui.group_types.setEnabled(False)
  1028. self.ui.group_options.setEnabled(False)
  1029. if self.ui.ch_do_checks.isChecked():
  1030. gCarla.utils.unsetenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS")
  1031. else:
  1032. gCarla.utils.setenv("CARLA_DISCOVERY_NO_PROCESSING_CHECKS", "true")
  1033. native, posix32, posix64, win32, win64 = (self.ui.ch_native.isChecked(),
  1034. self.ui.ch_posix32.isChecked(), self.ui.ch_posix64.isChecked(),
  1035. self.ui.ch_win32.isChecked(), self.ui.ch_win64.isChecked())
  1036. ladspa, dssi, lv2, vst, vst3, au, sf2, sfz = (self.ui.ch_ladspa.isChecked(), self.ui.ch_dssi.isChecked(),
  1037. self.ui.ch_lv2.isChecked(), self.ui.ch_vst.isChecked(),
  1038. self.ui.ch_vst3.isChecked(), self.ui.ch_au.isChecked(),
  1039. self.ui.ch_sf2.isChecked(), self.ui.ch_sfz.isChecked())
  1040. self.fThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64)
  1041. self.fThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, vst3, au, sf2, sfz)
  1042. self.fThread.start()
  1043. # -----------------------------------------------------------------------------------------------------------------
  1044. @pyqtSlot()
  1045. def slot_skip(self):
  1046. killDiscovery()
  1047. # -----------------------------------------------------------------------------------------------------------------
  1048. @pyqtSlot()
  1049. def slot_checkTools(self):
  1050. enabled1 = bool(self.ui.ch_native.isChecked() or
  1051. self.ui.ch_posix32.isChecked() or self.ui.ch_posix64.isChecked() or
  1052. self.ui.ch_win32.isChecked() or self.ui.ch_win64.isChecked())
  1053. enabled2 = bool(self.ui.ch_ladspa.isChecked() or self.ui.ch_dssi.isChecked() or
  1054. self.ui.ch_lv2.isChecked() or self.ui.ch_vst.isChecked() or
  1055. self.ui.ch_vst3.isChecked() or self.ui.ch_au.isChecked() or
  1056. self.ui.ch_sf2.isChecked() or self.ui.ch_sfz.isChecked())
  1057. self.ui.b_start.setEnabled(enabled1 and enabled2)
  1058. # -----------------------------------------------------------------------------------------------------------------
  1059. @pyqtSlot(int, str)
  1060. def slot_handlePluginLook(self, percent, plugin):
  1061. self.ui.progressBar.setFormat("%s" % plugin)
  1062. self.ui.progressBar.setValue(percent)
  1063. # -----------------------------------------------------------------------------------------------------------------
  1064. @pyqtSlot()
  1065. def slot_handlePluginThreadFinished(self):
  1066. self.ui.progressBar.setMinimum(0)
  1067. self.ui.progressBar.setMaximum(1)
  1068. self.ui.progressBar.setValue(1)
  1069. self.ui.progressBar.setFormat(self.tr("Done"))
  1070. self.ui.b_start.setEnabled(True)
  1071. self.ui.b_skip.setVisible(False)
  1072. self.ui.b_close.setVisible(True)
  1073. self.ui.group_types.setEnabled(True)
  1074. self.ui.group_options.setEnabled(True)
  1075. # -----------------------------------------------------------------------------------------------------------------
  1076. def closeEvent(self, event):
  1077. if self.fThread.isRunning():
  1078. self.fThread.stop()
  1079. killDiscovery()
  1080. #self.fThread.terminate()
  1081. self.fThread.wait()
  1082. if self.fThread.hasSomethingChanged():
  1083. self.accept()
  1084. else:
  1085. self.reject()
  1086. QDialog.closeEvent(self, event)
  1087. # ---------------------------------------------------------------------------------------------------------------------
  1088. # Plugin Database Dialog
  1089. class PluginDatabaseW(QDialog):
  1090. TABLEWIDGET_ITEM_FAVORITE = 0
  1091. TABLEWIDGET_ITEM_NAME = 1
  1092. TABLEWIDGET_ITEM_LABEL = 2
  1093. TABLEWIDGET_ITEM_MAKER = 3
  1094. TABLEWIDGET_ITEM_BINARY = 4
  1095. def __init__(self, parent, host, useSystemIcons):
  1096. QDialog.__init__(self, parent)
  1097. self.host = host
  1098. self.ui = ui_carla_database.Ui_PluginDatabaseW()
  1099. self.ui.setupUi(self)
  1100. # ----------------------------------------------------------------------------------------------------
  1101. # Internal stuff
  1102. self.fLastTableIndex = 0
  1103. self.fRetPlugin = None
  1104. self.fRealParent = parent
  1105. self.fFavoritePlugins = []
  1106. self.fFavoritePluginsChanged = False
  1107. self.fUseSystemIcons = useSystemIcons
  1108. self.fTrYes = self.tr("Yes")
  1109. self.fTrNo = self.tr("No")
  1110. self.fTrNative = self.tr("Native")
  1111. # ----------------------------------------------------------------------------------------------------
  1112. # Set-up GUI
  1113. self.ui.b_add.setEnabled(False)
  1114. self.addAction(self.ui.act_focus_search)
  1115. self.ui.act_focus_search.triggered.connect(self.slot_focusSearchFieldAndSelectAll)
  1116. if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32):
  1117. self.ui.ch_bridged.setText(self.tr("Bridged (64bit)"))
  1118. else:
  1119. self.ui.ch_bridged.setText(self.tr("Bridged (32bit)"))
  1120. if not (LINUX or MACOS):
  1121. self.ui.ch_bridged_wine.setChecked(False)
  1122. self.ui.ch_bridged_wine.setEnabled(False)
  1123. if not MACOS:
  1124. self.ui.ch_au.setChecked(False)
  1125. self.ui.ch_au.setEnabled(False)
  1126. self.ui.ch_au.setVisible(False)
  1127. self.ui.tab_info.tabBar().hide()
  1128. self.ui.tab_reqs.tabBar().hide()
  1129. # FIXME, why /2 needed?
  1130. self.ui.tab_info.setMinimumWidth(self.ui.la_id.width()/2 + 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. favItem = QTableWidgetItem()
  1632. favItem.setCheckState(Qt.Checked if self._createFavoritePluginDict(plugin) in self.fFavoritePlugins else Qt.Unchecked)
  1633. pluginText = (plugin['name']+plugin['label']+plugin['maker']+plugin['filename']).lower()
  1634. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_FAVORITE, favItem)
  1635. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_NAME, QTableWidgetItem(plugin['name']))
  1636. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_LABEL, QTableWidgetItem(plugin['label']))
  1637. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_MAKER, QTableWidgetItem(plugin['maker']))
  1638. self.ui.tableWidget.setItem(index, self.TABLEWIDGET_ITEM_BINARY, QTableWidgetItem(os.path.basename(plugin['filename'])))
  1639. self.ui.tableWidget.item(index, self.TABLEWIDGET_ITEM_NAME).setData(Qt.UserRole+1, plugin)
  1640. self.ui.tableWidget.item(index, self.TABLEWIDGET_ITEM_NAME).setData(Qt.UserRole+2, pluginText)
  1641. self.fLastTableIndex += 1
  1642. # --------------------------------------------------------------------------------------------------------
  1643. def _reAddInternalHelper(self, settingsDB, ptype, path):
  1644. if ptype == PLUGIN_INTERNAL:
  1645. ptypeStr = "Internal"
  1646. ptypeStrTr = self.tr("Internal")
  1647. elif ptype == PLUGIN_LV2:
  1648. ptypeStr = "LV2"
  1649. ptypeStrTr = ptypeStr
  1650. elif ptype == PLUGIN_AU:
  1651. ptypeStr = "AU"
  1652. ptypeStrTr = ptypeStr
  1653. #elif ptype == PLUGIN_SFZ:
  1654. #ptypeStr = "SFZ"
  1655. #ptypeStrTr = ptypeStr
  1656. else:
  1657. return 0
  1658. plugins = settingsDB.value("Plugins/" + ptypeStr, [], list)
  1659. pluginCount = settingsDB.value("PluginCount/" + ptypeStr, 0, int)
  1660. if ptype == PLUGIN_AU:
  1661. gCarla.utils.juce_init()
  1662. pluginCountNew = gCarla.utils.get_cached_plugin_count(ptype, path)
  1663. if pluginCountNew != pluginCount or len(plugins) != pluginCount or (len(plugins) > 0 and plugins[0]['API'] != PLUGIN_QUERY_API_VERSION):
  1664. plugins = []
  1665. pluginCount = pluginCountNew
  1666. QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50)
  1667. if ptype == PLUGIN_AU:
  1668. gCarla.utils.juce_idle()
  1669. for i in range(pluginCountNew):
  1670. descInfo = gCarla.utils.get_cached_plugin_info(ptype, i)
  1671. if not descInfo['valid']:
  1672. continue
  1673. info = checkPluginCached(descInfo, ptype)
  1674. plugins.append(info)
  1675. if i % 50 == 0:
  1676. QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50)
  1677. if ptype == PLUGIN_AU:
  1678. gCarla.utils.juce_idle()
  1679. settingsDB.setValue("Plugins/" + ptypeStr, plugins)
  1680. settingsDB.setValue("PluginCount/" + ptypeStr, pluginCount)
  1681. if ptype == PLUGIN_AU:
  1682. gCarla.utils.juce_cleanup()
  1683. # prepare rows in advance
  1684. self.ui.tableWidget.setRowCount(self.fLastTableIndex + len(plugins))
  1685. for plugin in plugins:
  1686. self._addPluginToTable(plugin, ptypeStrTr)
  1687. return pluginCount
  1688. def _reAddPlugins(self):
  1689. settingsDB = QSafeSettings("falkTX", "CarlaPlugins5")
  1690. self.fLastTableIndex = 0
  1691. self.ui.tableWidget.setSortingEnabled(False)
  1692. self.ui.tableWidget.clearContents()
  1693. settings = QSafeSettings("falkTX", "Carla2")
  1694. LV2_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list))
  1695. del settings
  1696. # ----------------------------------------------------------------------------------------------------
  1697. # plugins handled through backend
  1698. internalCount = self._reAddInternalHelper(settingsDB, PLUGIN_INTERNAL, "")
  1699. lv2Count = self._reAddInternalHelper(settingsDB, PLUGIN_LV2, LV2_PATH)
  1700. auCount = self._reAddInternalHelper(settingsDB, PLUGIN_AU, "") if MACOS else 0
  1701. # ----------------------------------------------------------------------------------------------------
  1702. # LADSPA
  1703. ladspaPlugins = []
  1704. ladspaPlugins += settingsDB.value("Plugins/LADSPA_native", [], list)
  1705. ladspaPlugins += settingsDB.value("Plugins/LADSPA_posix32", [], list)
  1706. ladspaPlugins += settingsDB.value("Plugins/LADSPA_posix64", [], list)
  1707. ladspaPlugins += settingsDB.value("Plugins/LADSPA_win32", [], list)
  1708. ladspaPlugins += settingsDB.value("Plugins/LADSPA_win64", [], list)
  1709. # ----------------------------------------------------------------------------------------------------
  1710. # DSSI
  1711. dssiPlugins = []
  1712. dssiPlugins += settingsDB.value("Plugins/DSSI_native", [], list)
  1713. dssiPlugins += settingsDB.value("Plugins/DSSI_posix32", [], list)
  1714. dssiPlugins += settingsDB.value("Plugins/DSSI_posix64", [], list)
  1715. dssiPlugins += settingsDB.value("Plugins/DSSI_win32", [], list)
  1716. dssiPlugins += settingsDB.value("Plugins/DSSI_win64", [], list)
  1717. # ----------------------------------------------------------------------------------------------------
  1718. # VST2
  1719. vst2Plugins = []
  1720. vst2Plugins += settingsDB.value("Plugins/VST2_native", [], list)
  1721. vst2Plugins += settingsDB.value("Plugins/VST2_posix32", [], list)
  1722. vst2Plugins += settingsDB.value("Plugins/VST2_posix64", [], list)
  1723. vst2Plugins += settingsDB.value("Plugins/VST2_win32", [], list)
  1724. vst2Plugins += settingsDB.value("Plugins/VST2_win64", [], list)
  1725. # ----------------------------------------------------------------------------------------------------
  1726. # VST3
  1727. vst3Plugins = []
  1728. vst3Plugins += settingsDB.value("Plugins/VST3_native", [], list)
  1729. vst3Plugins += settingsDB.value("Plugins/VST3_posix32", [], list)
  1730. vst3Plugins += settingsDB.value("Plugins/VST3_posix64", [], list)
  1731. vst3Plugins += settingsDB.value("Plugins/VST3_win32", [], list)
  1732. vst3Plugins += settingsDB.value("Plugins/VST3_win64", [], list)
  1733. # ----------------------------------------------------------------------------------------------------
  1734. # AU (extra non-cached)
  1735. auPlugins32 = settingsDB.value("Plugins/AU_posix32", [], list) if MACOS else []
  1736. # ----------------------------------------------------------------------------------------------------
  1737. # Kits
  1738. sf2s = settingsDB.value("Plugins/SF2", [], list)
  1739. sfzs = settingsDB.value("Plugins/SFZ", [], list)
  1740. # ----------------------------------------------------------------------------------------------------
  1741. # count plugins first, so we can create rows in advance
  1742. ladspaCount = 0
  1743. dssiCount = 0
  1744. vstCount = 0
  1745. vst3Count = 0
  1746. au32Count = 0
  1747. sf2Count = 0
  1748. sfzCount = len(sfzs)
  1749. for plugins in ladspaPlugins:
  1750. ladspaCount += len(plugins)
  1751. for plugins in dssiPlugins:
  1752. dssiCount += len(plugins)
  1753. for plugins in vst2Plugins:
  1754. vstCount += len(plugins)
  1755. for plugins in vst3Plugins:
  1756. vst3Count += len(plugins)
  1757. for plugins in auPlugins32:
  1758. au32Count += len(plugins)
  1759. for plugins in sf2s:
  1760. sf2Count += len(plugins)
  1761. self.ui.tableWidget.setRowCount(self.fLastTableIndex +
  1762. ladspaCount + dssiCount + vstCount + vst3Count + au32Count +
  1763. sf2Count + sfzCount)
  1764. if MACOS:
  1765. 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" % (
  1766. internalCount, ladspaCount, dssiCount, lv2Count, vstCount, vst3Count, auCount+au32Count, sf2Count+sfzCount)))
  1767. else:
  1768. 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" % (
  1769. internalCount, ladspaCount, dssiCount, lv2Count, vstCount, vst3Count, sf2Count+sfzCount)))
  1770. # ----------------------------------------------------------------------------------------------------
  1771. # now add all plugins to the table
  1772. for plugins in ladspaPlugins:
  1773. for plugin in plugins:
  1774. self._addPluginToTable(plugin, "LADSPA")
  1775. for plugins in dssiPlugins:
  1776. for plugin in plugins:
  1777. self._addPluginToTable(plugin, "DSSI")
  1778. for plugins in vst2Plugins:
  1779. for plugin in plugins:
  1780. self._addPluginToTable(plugin, "VST2")
  1781. for plugins in vst3Plugins:
  1782. for plugin in plugins:
  1783. self._addPluginToTable(plugin, "VST3")
  1784. for plugins in auPlugins32:
  1785. for plugin in plugins:
  1786. self._addPluginToTable(plugin, "AU")
  1787. for sf2 in sf2s:
  1788. for sf2_i in sf2:
  1789. self._addPluginToTable(sf2_i, "SF2")
  1790. for sfz in sfzs:
  1791. self._addPluginToTable(sfz, "SFZ")
  1792. # ----------------------------------------------------------------------------------------------------
  1793. self.ui.tableWidget.setSortingEnabled(True)
  1794. self._checkFilters()
  1795. self.slot_checkPlugin(self.ui.tableWidget.currentRow())
  1796. # --------------------------------------------------------------------------------------------------------
  1797. def showEvent(self, event):
  1798. self.slot_focusSearchFieldAndSelectAll()
  1799. QDialog.showEvent(self, event)
  1800. # ---------------------------------------------------------------------------------------------------------------------
  1801. # Jack Application Dialog
  1802. class JackApplicationW(QDialog):
  1803. SESSION_MGR_NONE = 0
  1804. SESSION_MGR_AUTO = 1
  1805. SESSION_MGR_JACK = 2
  1806. SESSION_MGR_LADISH = 3
  1807. SESSION_MGR_NSM = 4
  1808. UI_SESSION_NONE = 0
  1809. UI_SESSION_LADISH = 1
  1810. UI_SESSION_NSM = 2
  1811. FLAG_CONTROL_WINDOW = 0x01
  1812. FLAG_CAPTURE_FIRST_WINDOW = 0x02
  1813. FLAG_BUFFERS_ADDITION_MODE = 0x10
  1814. FLAG_MIDI_OUTPUT_CHANNEL_MIXDOWN = 0x20
  1815. FLAG_EXTERNAL_START = 0x40
  1816. def __init__(self, parent, projectFilename):
  1817. QDialog.__init__(self, parent)
  1818. self.ui = ui_carla_add_jack.Ui_Dialog()
  1819. self.ui.setupUi(self)
  1820. print("Add JACK Application: current project filename is '%s'" % (projectFilename,))
  1821. self.fProjectFilename = projectFilename
  1822. self.ui.group_error.setVisible(False)
  1823. self.adjustSize()
  1824. self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
  1825. # --------------------------------------------------------------------------------------------------------------
  1826. # Load settings
  1827. self.loadSettings()
  1828. # --------------------------------------------------------------------------------------------------------------
  1829. # Set-up connections
  1830. self.finished.connect(self.slot_saveSettings)
  1831. self.ui.cb_session_mgr.currentIndexChanged.connect(self.slot_sessionManagerChanged)
  1832. self.ui.le_command.textChanged.connect(self.slot_commandChanged)
  1833. # -----------------------------------------------------------------------------------------------------------------
  1834. def getCommandAndFlags(self):
  1835. name = self.ui.le_name.text()
  1836. command = self.ui.le_command.text()
  1837. smgr = self.SESSION_MGR_NONE
  1838. flags = 0x0
  1839. if not name:
  1840. name = os.path.basename(command.split(" ",1)[0]).title()
  1841. uiSessionMgrIndex = self.ui.cb_session_mgr.currentIndex()
  1842. if uiSessionMgrIndex == self.UI_SESSION_LADISH:
  1843. smgr = self.SESSION_MGR_LADISH
  1844. elif uiSessionMgrIndex == self.UI_SESSION_NSM:
  1845. smgr = self.SESSION_MGR_NSM
  1846. if self.ui.cb_manage_window.isChecked():
  1847. flags |= self.FLAG_CONTROL_WINDOW
  1848. if self.ui.cb_capture_first_window.isChecked():
  1849. flags |= self.FLAG_CAPTURE_FIRST_WINDOW
  1850. if self.ui.cb_buffers_addition_mode.isChecked():
  1851. flags |= self.FLAG_BUFFERS_ADDITION_MODE
  1852. if self.ui.cb_out_midi_mixdown.isChecked():
  1853. flags |= self.FLAG_MIDI_OUTPUT_CHANNEL_MIXDOWN
  1854. if self.ui.cb_external_start.isChecked():
  1855. flags |= self.FLAG_EXTERNAL_START
  1856. baseIntVal = ord('0')
  1857. labelSetup = "%s%s%s%s%s%s" % (chr(baseIntVal+self.ui.sb_audio_ins.value()),
  1858. chr(baseIntVal+self.ui.sb_audio_outs.value()),
  1859. chr(baseIntVal+self.ui.sb_midi_ins.value()),
  1860. chr(baseIntVal+self.ui.sb_midi_outs.value()),
  1861. chr(baseIntVal+smgr),
  1862. chr(baseIntVal+flags))
  1863. return (command, name, labelSetup)
  1864. def checkIfButtonBoxShouldBeEnabled(self, index, text):
  1865. enabled = len(text) > 0
  1866. showErr = ""
  1867. # NSM applications must not be abstract or absolute paths, and must not contain arguments
  1868. if enabled and index == self.UI_SESSION_NSM:
  1869. if text[0] in (".", "/"):
  1870. showErr = self.tr("NSM applications cannot use abstract or absolute paths")
  1871. elif " " in text or ";" in text or "&" in text:
  1872. showErr = self.tr("NSM applications cannot use CLI arguments")
  1873. elif len(self.fProjectFilename) == 0:
  1874. showErr = self.tr("You need to save the current Carla project before NSM can be used")
  1875. if showErr:
  1876. enabled = False
  1877. self.ui.l_error.setText(showErr)
  1878. self.ui.group_error.setVisible(True)
  1879. else:
  1880. self.ui.group_error.setVisible(False)
  1881. self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
  1882. def loadSettings(self):
  1883. settings = QSafeSettings("falkTX", "CarlaAddJackApp")
  1884. smName = settings.value("SessionManager", "", str)
  1885. if smName == "LADISH (SIGUSR1)":
  1886. self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_LADISH)
  1887. elif smName == "NSM":
  1888. self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_NSM)
  1889. else:
  1890. self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_NONE)
  1891. self.ui.le_command.setText(settings.value("Command", "", str))
  1892. self.ui.le_name.setText(settings.value("Name", "", str))
  1893. self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, int))
  1894. self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, int))
  1895. self.ui.sb_audio_outs.setValue(settings.value("NumAudioOuts", 2, int))
  1896. self.ui.sb_midi_ins.setValue(settings.value("NumMidiIns", 0, int))
  1897. self.ui.sb_midi_outs.setValue(settings.value("NumMidiOuts", 0, int))
  1898. self.ui.cb_manage_window.setChecked(settings.value("ManageWindow", True, bool))
  1899. self.ui.cb_capture_first_window.setChecked(settings.value("CaptureFirstWindow", False, bool))
  1900. self.ui.cb_out_midi_mixdown.setChecked(settings.value("MidiOutMixdown", False, bool))
  1901. self.checkIfButtonBoxShouldBeEnabled(self.ui.cb_session_mgr.currentIndex(),
  1902. self.ui.le_command.text())
  1903. # -----------------------------------------------------------------------------------------------------------------
  1904. @pyqtSlot(str)
  1905. def slot_commandChanged(self, text):
  1906. self.checkIfButtonBoxShouldBeEnabled(self.ui.cb_session_mgr.currentIndex(), text)
  1907. @pyqtSlot(int)
  1908. def slot_sessionManagerChanged(self, index):
  1909. self.checkIfButtonBoxShouldBeEnabled(index, self.ui.le_command.text())
  1910. @pyqtSlot()
  1911. def slot_saveSettings(self):
  1912. settings = QSafeSettings("falkTX", "CarlaAddJackApp")
  1913. settings.setValue("Command", self.ui.le_command.text())
  1914. settings.setValue("Name", self.ui.le_name.text())
  1915. settings.setValue("SessionManager", self.ui.cb_session_mgr.currentText())
  1916. settings.setValue("NumAudioIns", self.ui.sb_audio_ins.value())
  1917. settings.setValue("NumAudioOuts", self.ui.sb_audio_outs.value())
  1918. settings.setValue("NumMidiIns", self.ui.sb_midi_ins.value())
  1919. settings.setValue("NumMidiOuts", self.ui.sb_midi_outs.value())
  1920. settings.setValue("ManageWindow", self.ui.cb_manage_window.isChecked())
  1921. settings.setValue("CaptureFirstWindow", self.ui.cb_capture_first_window.isChecked())
  1922. settings.setValue("MidiOutMixdown", self.ui.cb_out_midi_mixdown.isChecked())
  1923. # ---------------------------------------------------------------------------------------------------------------------
  1924. # Main
  1925. if __name__ == '__main__':
  1926. from carla_app import CarlaApplication
  1927. from carla_host import initHost as _initHost, loadHostSettings as _loadHostSettings
  1928. # pylint: disable=ungrouped-imports
  1929. from carla_shared import handleInitialCommandLineArguments
  1930. # pylint: enable=ungrouped-imports
  1931. initName, libPrefix = handleInitialCommandLineArguments(__file__ if "__file__" in dir() else None)
  1932. app = CarlaApplication("Carla2-Database", libPrefix)
  1933. host = _initHost("Carla2-Database", libPrefix, False, False, False)
  1934. _loadHostSettings(host)
  1935. gui = PluginDatabaseW(None, host, True)
  1936. #gui = PluginRefreshW(None, host, True)
  1937. gui.show()
  1938. app.exit_exec()
  1939. # ------------------------------------------------------------------------------------------------------------