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.

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