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.

2085 lines
82KB

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