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.

1997 lines
79KB

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