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.

2260 lines
90KB

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