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.

2402 lines
97KB

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