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.

2270 lines
91KB

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