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.

1685 lines
63KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin database code
  4. # Copyright (C) 2011-2013 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 PyQt4.QtCore import pyqtSignal, pyqtSlot, Qt, QThread, QSettings
  22. from PyQt4.QtGui import QDialog, QTableWidgetItem
  23. # ------------------------------------------------------------------------------------------------------------
  24. # Imports (Custom)
  25. import ui_carla_database
  26. import ui_carla_refresh
  27. from carla_shared import *
  28. # ------------------------------------------------------------------------------------------------------------
  29. # Try Import LADSPA-RDF
  30. try:
  31. import ladspa_rdf
  32. import json
  33. haveLRDF = True
  34. except:
  35. qWarning("LRDF Support not available (LADSPA-RDF will be disabled)")
  36. haveLRDF = False
  37. # ------------------------------------------------------------------------------------------------------------
  38. # Set LADSPA-RDF Path
  39. if haveLRDF and readEnvVars:
  40. LADSPA_RDF_PATH_env = os.getenv("LADSPA_RDF_PATH")
  41. if LADSPA_RDF_PATH_env:
  42. ladspa_rdf.set_rdf_path(LADSPA_RDF_PATH_env.split(splitter))
  43. del LADSPA_RDF_PATH_env
  44. # ------------------------------------------------------------------------------------------------------------
  45. # Plugin Query (helper functions)
  46. def findBinaries(binPath, OS):
  47. binaries = []
  48. if OS == "WINDOWS":
  49. extensions = (".dll",)
  50. elif OS == "MACOS":
  51. extensions = (".dylib", ".so")
  52. else:
  53. extensions = (".so",)
  54. for root, dirs, files in os.walk(binPath):
  55. for name in [name for name in files if name.lower().endswith(extensions)]:
  56. binaries.append(os.path.join(root, name))
  57. return binaries
  58. def findLV2Bundles(bundlePath):
  59. bundles = []
  60. for root, dirs, files in os.walk(bundlePath):
  61. if os.path.exists(os.path.join(root, "manifest.ttl")):
  62. bundles.append(root)
  63. return bundles
  64. def findMacVSTBundles(bundlePath):
  65. bundles = []
  66. for root, dirs, files in os.walk(bundlePath):
  67. for name in [name for name in dirs if name.lower().endswith(".vst")]:
  68. bundles.append(os.path.join(root, name))
  69. return bundles
  70. def findFilenames(filePath, stype):
  71. filenames = []
  72. if stype == "csd":
  73. extensions = (".csd",)
  74. elif stype == "gig":
  75. extensions = (".gig",)
  76. elif stype == "sf2":
  77. extensions = (".sf2",)
  78. elif stype == "sfz":
  79. extensions = (".sfz",)
  80. else:
  81. return []
  82. for root, dirs, files in os.walk(filePath):
  83. for name in [name for name in files if name.lower().endswith(extensions)]:
  84. filenames.append(os.path.join(root, name))
  85. return filenames
  86. # ------------------------------------------------------------------------------------------------------------
  87. # Plugin Query
  88. PLUGIN_QUERY_API_VERSION = 3
  89. PyPluginInfo = {
  90. 'API': PLUGIN_QUERY_API_VERSION,
  91. 'build': BINARY_NONE,
  92. 'type': PLUGIN_NONE,
  93. 'hints': 0x0,
  94. 'filename': "",
  95. 'name': "",
  96. 'label': "",
  97. 'maker': "",
  98. 'copyright': "",
  99. 'uniqueId': 0,
  100. 'audio.ins': 0,
  101. 'audio.outs': 0,
  102. 'audio.total': 0,
  103. 'midi.ins': 0,
  104. 'midi.outs': 0,
  105. 'midi.total': 0,
  106. 'parameters.ins': 0,
  107. 'parameters.outs': 0,
  108. 'parameters.total': 0,
  109. 'programs.total': 0
  110. }
  111. global gDiscoveryProcess
  112. gDiscoveryProcess = None
  113. def runCarlaDiscovery(itype, stype, filename, tool, isWine=False):
  114. if not os.path.exists(tool):
  115. qWarning("runCarlaDiscovery() - tool '%s' does not exist" % tool)
  116. return
  117. command = []
  118. if LINUX or MACOS:
  119. command.append("env")
  120. command.append("LANG=C")
  121. if isWine:
  122. command.append("WINEDEBUG=-all")
  123. command.append(tool)
  124. command.append(stype)
  125. command.append(filename)
  126. global gDiscoveryProcess
  127. gDiscoveryProcess = Popen(command, stdout=PIPE)
  128. pinfo = None
  129. plugins = []
  130. fakeLabel = os.path.basename(filename).rsplit(".", 1)[0]
  131. while True:
  132. try:
  133. line = gDiscoveryProcess.stdout.readline().decode("utf-8", errors="ignore")
  134. except:
  135. print("ERROR: discovery readline failed")
  136. break
  137. # line is valid, strip it
  138. if line:
  139. line = line.strip()
  140. # line is invalid, try poll() again
  141. elif gDiscoveryProcess.poll() is None:
  142. continue
  143. # line is invalid and poll() failed, stop here
  144. else:
  145. break
  146. if line == "carla-discovery::init::-----------":
  147. pinfo = deepcopy(PyPluginInfo)
  148. pinfo['type'] = itype
  149. pinfo['filename'] = filename
  150. elif line == "carla-discovery::end::------------":
  151. if pinfo is not None:
  152. plugins.append(pinfo)
  153. del pinfo
  154. pinfo = None
  155. elif line == "Segmentation fault":
  156. print("carla-discovery::crash::%s crashed during discovery" % filename)
  157. elif line.startswith("err:module:import_dll Library"):
  158. print(line)
  159. elif line.startswith("carla-discovery::info::"):
  160. print("%s - %s" % (line, filename))
  161. elif line.startswith("carla-discovery::error::"):
  162. print("%s - %s" % (line, filename))
  163. elif line.startswith("carla-discovery::"):
  164. if pinfo == None:
  165. continue
  166. try:
  167. prop, value = line.replace("carla-discovery::", "").split("::", 1)
  168. except:
  169. continue
  170. if prop == "name":
  171. pinfo['name'] = value if value else fakeLabel
  172. elif prop == "label":
  173. pinfo['label'] = value if value else fakeLabel
  174. elif prop == "maker":
  175. pinfo['maker'] = value
  176. elif prop == "copyright":
  177. pinfo['copyright'] = value
  178. elif prop == "uniqueId":
  179. if value.isdigit(): pinfo['uniqueId'] = int(value)
  180. elif prop == "hints":
  181. if value.isdigit(): pinfo['hints'] = int(value)
  182. elif prop == "audio.ins":
  183. if value.isdigit(): pinfo['audio.ins'] = int(value)
  184. elif prop == "audio.outs":
  185. if value.isdigit(): pinfo['audio.outs'] = int(value)
  186. elif prop == "audio.total":
  187. if value.isdigit(): pinfo['audio.total'] = int(value)
  188. elif prop == "midi.ins":
  189. if value.isdigit(): pinfo['midi.ins'] = int(value)
  190. elif prop == "midi.outs":
  191. if value.isdigit(): pinfo['midi.outs'] = int(value)
  192. elif prop == "midi.total":
  193. if value.isdigit(): pinfo['midi.total'] = int(value)
  194. elif prop == "parameters.ins":
  195. if value.isdigit(): pinfo['parameters.ins'] = int(value)
  196. elif prop == "parameters.outs":
  197. if value.isdigit(): pinfo['parameters.outs'] = int(value)
  198. elif prop == "parameters.total":
  199. if value.isdigit(): pinfo['parameters.total'] = int(value)
  200. elif prop == "programs.total":
  201. if value.isdigit(): pinfo['programs.total'] = int(value)
  202. elif prop == "build":
  203. if value.isdigit(): pinfo['build'] = int(value)
  204. elif prop == "uri":
  205. if value:
  206. pinfo['label'] = value
  207. else:
  208. # cannot use empty URIs
  209. del pinfo
  210. pinfo = None
  211. continue
  212. # FIXME?
  213. tmp = gDiscoveryProcess
  214. gDiscoveryProcess = None
  215. del gDiscoveryProcess, tmp
  216. return plugins
  217. def killDiscovery():
  218. global gDiscoveryProcess
  219. if gDiscoveryProcess is not None:
  220. gDiscoveryProcess.kill()
  221. def checkPluginInternal(desc):
  222. plugins = []
  223. pinfo = deepcopy(PyPluginInfo)
  224. pinfo['build'] = BINARY_NATIVE
  225. pinfo['type'] = PLUGIN_INTERNAL
  226. pinfo['hints'] = int(desc['hints'])
  227. pinfo['name'] = charPtrToString(desc['name'])
  228. pinfo['label'] = charPtrToString(desc['label'])
  229. pinfo['maker'] = charPtrToString(desc['maker'])
  230. pinfo['copyright'] = charPtrToString(desc['copyright'])
  231. pinfo['audio.ins'] = int(desc['audioIns'])
  232. pinfo['audio.outs'] = int(desc['audioOuts'])
  233. pinfo['audio.total'] = pinfo['audio.ins'] + pinfo['audio.outs']
  234. pinfo['midi.ins'] = int(desc['midiIns'])
  235. pinfo['midi.outs'] = int(desc['midiOuts'])
  236. pinfo['midi.total'] = pinfo['midi.ins'] + pinfo['midi.outs']
  237. pinfo['parameters.ins'] = int(desc['parameterIns'])
  238. pinfo['parameters.outs'] = int(desc['parameterOuts'])
  239. pinfo['parameters.total'] = pinfo['parameters.ins'] + pinfo['parameters.outs']
  240. plugins.append(pinfo)
  241. return plugins
  242. def checkPluginLADSPA(filename, tool, isWine=False):
  243. return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, isWine)
  244. def checkPluginDSSI(filename, tool, isWine=False):
  245. return runCarlaDiscovery(PLUGIN_DSSI, "DSSI", filename, tool, isWine)
  246. def checkPluginLV2(filename, tool, isWine=False):
  247. return runCarlaDiscovery(PLUGIN_LV2, "LV2", filename, tool, isWine)
  248. def checkPluginVST(filename, tool, isWine=False):
  249. return runCarlaDiscovery(PLUGIN_VST, "VST", filename, tool, isWine)
  250. def checkPluginAU(filename, tool):
  251. return runCarlaDiscovery(PLUGIN_AU, "AU", filename, tool)
  252. def checkFileCSD(filename, tool):
  253. return runCarlaDiscovery(PLUGIN_FILE_CSD, "CSD", filename, tool)
  254. def checkFileGIG(filename, tool):
  255. return runCarlaDiscovery(PLUGIN_FILE_GIG, "GIG", filename, tool)
  256. def checkFileSF2(filename, tool):
  257. return runCarlaDiscovery(PLUGIN_FILE_SF2, "SF2", filename, tool)
  258. def checkFileSFZ(filename, tool):
  259. return runCarlaDiscovery(PLUGIN_FILE_SFZ, "SFZ", filename, tool)
  260. # ------------------------------------------------------------------------------------------------------------
  261. # Separate Thread for Plugin Search
  262. class SearchPluginsThread(QThread):
  263. pluginLook = pyqtSignal(int, str)
  264. def __init__(self, parent):
  265. QThread.__init__(self, parent)
  266. self.fContinueChecking = False
  267. self.fCheckNative = False
  268. self.fCheckPosix32 = False
  269. self.fCheckPosix64 = False
  270. self.fCheckWin32 = False
  271. self.fCheckWin64 = False
  272. self.fCheckLADSPA = False
  273. self.fCheckDSSI = False
  274. self.fCheckLV2 = False
  275. self.fCheckVST = False
  276. self.fCheckAU = False
  277. self.fCheckCSD = False
  278. self.fCheckGIG = False
  279. self.fCheckSF2 = False
  280. self.fCheckSFZ = False
  281. self.fToolNative = Carla.discovery_native
  282. self.fCurCount = 0
  283. self.fCurPercentValue = 0
  284. self.fLastCheckValue = 0
  285. self.fSomethingChanged = False
  286. self.fLadspaPlugins = []
  287. self.fDssiPlugins = []
  288. self.fLv2Plugins = []
  289. self.fVstPlugins = []
  290. self.fAuPlugins = []
  291. self.fCsdFiles = []
  292. self.fKitPlugins = []
  293. print(Carla.discovery_native)
  294. # -------------------------------------------------------------
  295. def hasSomethingChanged(self):
  296. return self.fSomethingChanged
  297. def setSearchBinaryTypes(self, native, posix32, posix64, win32, win64):
  298. self.fCheckNative = native
  299. self.fCheckPosix32 = posix32
  300. self.fCheckPosix64 = posix64
  301. self.fCheckWin32 = win32
  302. self.fCheckWin64 = win64
  303. def setSearchPluginTypes(self, ladspa, dssi, lv2, vst, au, csd, gig, sf2, sfz):
  304. self.fCheckLADSPA = ladspa
  305. self.fCheckDSSI = dssi
  306. self.fCheckLV2 = lv2
  307. self.fCheckVST = vst
  308. self.fCheckAU = au and MACOS
  309. self.fCheckCSD = csd
  310. self.fCheckGIG = gig
  311. self.fCheckSF2 = sf2
  312. self.fCheckSFZ = sfz
  313. def setSearchToolNative(self, tool):
  314. self.fToolNative = tool
  315. def stop(self):
  316. self.fContinueChecking = False
  317. def run(self):
  318. self.fContinueChecking = True
  319. self.fCurCount = 0
  320. pluginCount = 0
  321. settingsDB = QSettings("falkTX", "CarlaPlugins2")
  322. if self.fCheckLADSPA: pluginCount += 1
  323. if self.fCheckDSSI: pluginCount += 1
  324. if self.fCheckLV2: pluginCount += 1
  325. if self.fCheckVST: pluginCount += 1
  326. if self.fCheckAU: pluginCount += 1
  327. if self.fCheckNative:
  328. self.fCurCount += pluginCount
  329. if self.fCheckPosix32:
  330. self.fCurCount += pluginCount
  331. if self.fCheckPosix64:
  332. self.fCurCount += pluginCount
  333. if self.fCheckWin32:
  334. self.fCurCount += pluginCount
  335. if self.fCheckAU: self.fCurCount -= 1
  336. if self.fCheckWin64:
  337. self.fCurCount += pluginCount
  338. if self.fCheckAU: self.fCurCount -= 1
  339. if self.fCheckNative and self.fToolNative:
  340. if self.fCheckCSD: self.fCurCount += 1
  341. if self.fCheckGIG: self.fCurCount += 1
  342. if self.fCheckSF2: self.fCurCount += 1
  343. if self.fCheckSFZ: self.fCurCount += 1
  344. else:
  345. self.fCheckCSD = False
  346. self.fCheckGIG = False
  347. self.fCheckSF2 = False
  348. self.fCheckSFZ = False
  349. if self.fCurCount == 0:
  350. return
  351. self.fCurPercentValue = 100.0 / self.fCurCount
  352. self.fLastCheckValue = 0.0
  353. if HAIKU:
  354. OS = "HAIKU"
  355. elif LINUX:
  356. OS = "LINUX"
  357. elif MACOS:
  358. OS = "MACOS"
  359. elif WINDOWS:
  360. OS = "WINDOWS"
  361. else:
  362. OS = "UNKNOWN"
  363. if not self.fContinueChecking: return
  364. if self.fCheckLADSPA:
  365. checkValue = 0.0
  366. if haveLRDF:
  367. if self.fCheckNative: checkValue += 0.1
  368. if self.fCheckPosix32: checkValue += 0.1
  369. if self.fCheckPosix64: checkValue += 0.1
  370. if self.fCheckWin32: checkValue += 0.1
  371. if self.fCheckWin64: checkValue += 0.1
  372. rdfPadValue = self.fCurPercentValue * checkValue
  373. if self.fCheckNative:
  374. self._checkLADSPA(OS, self.fToolNative)
  375. settingsDB.setValue("Plugins/LADSPA_native", self.fLadspaPlugins)
  376. if not self.fContinueChecking: return
  377. if self.fCheckPosix32:
  378. self._checkLADSPA(OS, Carla.discovery_posix32)
  379. settingsDB.setValue("Plugins/LADSPA_posix32", self.fLadspaPlugins)
  380. if not self.fContinueChecking: return
  381. if self.fCheckPosix64:
  382. self._checkLADSPA(OS, Carla.discovery_posix64)
  383. settingsDB.setValue("Plugins/LADSPA_posix64", self.fLadspaPlugins)
  384. if not self.fContinueChecking: return
  385. if self.fCheckWin32:
  386. self._checkLADSPA("WINDOWS", Carla.discovery_win32, not WINDOWS)
  387. settingsDB.setValue("Plugins/LADSPA_win32", self.fLadspaPlugins)
  388. if not self.fContinueChecking: return
  389. if self.fCheckWin64:
  390. self._checkLADSPA("WINDOWS", Carla.discovery_win64, not WINDOWS)
  391. settingsDB.setValue("Plugins/LADSPA_win64", self.fLadspaPlugins)
  392. settingsDB.sync()
  393. if not self.fContinueChecking: return
  394. if haveLRDF and checkValue > 0:
  395. startValue = self.fLastCheckValue - rdfPadValue
  396. self._pluginLook(startValue, "LADSPA RDFs...")
  397. ladspaRdfInfo = ladspa_rdf.recheck_all_plugins(self, startValue, self.fCurPercentValue, checkValue)
  398. settingsDir = os.path.join(HOME, ".config", "falkTX")
  399. fdLadspa = open(os.path.join(settingsDir, "ladspa_rdf.db"), 'w')
  400. json.dump(ladspaRdfInfo, fdLadspa)
  401. fdLadspa.close()
  402. if not self.fContinueChecking: return
  403. if self.fCheckDSSI:
  404. if self.fCheckNative:
  405. self._checkDSSI(OS, self.fToolNative)
  406. settingsDB.setValue("Plugins/DSSI_native", self.fDssiPlugins)
  407. if not self.fContinueChecking: return
  408. if self.fCheckPosix32:
  409. self._checkDSSI(OS, Carla.discovery_posix32)
  410. settingsDB.setValue("Plugins/DSSI_posix32", self.fDssiPlugins)
  411. if not self.fContinueChecking: return
  412. if self.fCheckPosix64:
  413. self._checkDSSI(OS, Carla.discovery_posix64)
  414. settingsDB.setValue("Plugins/DSSI_posix64", self.fDssiPlugins)
  415. if not self.fContinueChecking: return
  416. if self.fCheckWin32:
  417. self._checkDSSI("WINDOWS", Carla.discovery_win32, not WINDOWS)
  418. settingsDB.setValue("Plugins/DSSI_win32", self.fDssiPlugins)
  419. if not self.fContinueChecking: return
  420. if self.fCheckWin64:
  421. self._checkDSSI("WINDOWS", Carla.discovery_win64, not WINDOWS)
  422. settingsDB.setValue("Plugins/DSSI_win64", self.fDssiPlugins)
  423. settingsDB.sync()
  424. if not self.fContinueChecking: return
  425. if self.fCheckLV2:
  426. if self.fCheckNative:
  427. self._checkLV2(self.fToolNative)
  428. settingsDB.setValue("Plugins/LV2_native", self.fLv2Plugins)
  429. if not self.fContinueChecking: return
  430. if self.fCheckPosix32:
  431. self._checkLV2(Carla.discovery_posix32)
  432. settingsDB.setValue("Plugins/LV2_posix32", self.fLv2Plugins)
  433. if not self.fContinueChecking: return
  434. if self.fCheckPosix64:
  435. self._checkLV2(Carla.discovery_posix64)
  436. settingsDB.setValue("Plugins/LV2_posix64", self.fLv2Plugins)
  437. if not self.fContinueChecking: return
  438. if self.fCheckWin32:
  439. self._checkLV2(Carla.discovery_win32, not WINDOWS)
  440. settingsDB.setValue("Plugins/LV2_win32", self.fLv2Plugins)
  441. if not self.fContinueChecking: return
  442. if self.fCheckWin64:
  443. self._checkLV2(Carla.discovery_win64, not WINDOWS)
  444. settingsDB.setValue("Plugins/LV2_win64", self.fLv2Plugins)
  445. settingsDB.sync()
  446. if not self.fContinueChecking: return
  447. if self.fCheckVST:
  448. if self.fCheckNative:
  449. self._checkVST(OS, self.fToolNative)
  450. settingsDB.setValue("Plugins/VST_native", self.fVstPlugins)
  451. if not self.fContinueChecking: return
  452. if self.fCheckPosix32:
  453. self._checkVST(OS, Carla.discovery_posix32)
  454. settingsDB.setValue("Plugins/VST_posix32", self.fVstPlugins)
  455. if not self.fContinueChecking: return
  456. if self.fCheckPosix64:
  457. self._checkVST(OS, Carla.discovery_posix64)
  458. settingsDB.setValue("Plugins/VST_posix64", self.fVstPlugins)
  459. if not self.fContinueChecking: return
  460. if self.fCheckWin32:
  461. self._checkVST("WINDOWS", Carla.discovery_win32, not WINDOWS)
  462. settingsDB.setValue("Plugins/VST_win32", self.fVstPlugins)
  463. if not self.fContinueChecking: return
  464. if self.fCheckWin64:
  465. self._checkVST("WINDOWS", Carla.discovery_win64, not WINDOWS)
  466. settingsDB.setValue("Plugins/VST_win64", self.fVstPlugins)
  467. settingsDB.sync()
  468. if not self.fContinueChecking: return
  469. if self.fCheckAU:
  470. if self.fCheckNative:
  471. self._checkAU(self.fToolNative)
  472. settingsDB.setValue("Plugins/AU_native", self.fAuPlugins)
  473. if not self.fContinueChecking: return
  474. if self.fCheckPosix32:
  475. self._checkAU(Carla.discovery_posix32)
  476. settingsDB.setValue("Plugins/AU_posix32", self.fAuPlugins)
  477. if not self.fContinueChecking: return
  478. if self.fCheckPosix64:
  479. self._checkAU(Carla.discovery_posix64)
  480. settingsDB.setValue("Plugins/AU_posix64", self.fAuPlugins)
  481. settingsDB.sync()
  482. if not self.fContinueChecking: return
  483. if self.fCheckCSD:
  484. self._checkCSD()
  485. settingsDB.setValue("Plugins/CSD", self.fCsdFiles)
  486. if not self.fContinueChecking: return
  487. if self.fCheckGIG:
  488. settings = QSettings()
  489. GIG_PATH = toList(settings.value("Paths/GIG", Carla.DEFAULT_GIG_PATH))
  490. del settings
  491. self._checkKIT(GIG_PATH, "gig")
  492. settingsDB.setValue("Plugins/GIG", self.fKitPlugins)
  493. if not self.fContinueChecking: return
  494. if self.fCheckSF2:
  495. settings = QSettings()
  496. SF2_PATH = toList(settings.value("Paths/SF2", Carla.DEFAULT_SF2_PATH))
  497. del settings
  498. self._checkKIT(SF2_PATH, "sf2")
  499. settingsDB.setValue("Plugins/SF2", self.fKitPlugins)
  500. if not self.fContinueChecking: return
  501. if self.fCheckSFZ:
  502. settings = QSettings()
  503. SFZ_PATH = toList(settings.value("Paths/SFZ", Carla.DEFAULT_SFZ_PATH))
  504. del settings
  505. self._checkKIT(SFZ_PATH, "sfz")
  506. settingsDB.setValue("Plugins/SFZ", self.fKitPlugins)
  507. settingsDB.sync()
  508. def _checkLADSPA(self, OS, tool, isWine=False):
  509. ladspaBinaries = []
  510. self.fLadspaPlugins = []
  511. self._pluginLook(self.fLastCheckValue, "LADSPA plugins...")
  512. settings = QSettings()
  513. LADSPA_PATH = toList(settings.value("Paths/LADSPA", Carla.DEFAULT_LADSPA_PATH))
  514. for iPATH in LADSPA_PATH:
  515. binaries = findBinaries(iPATH, OS)
  516. for binary in binaries:
  517. if binary not in ladspaBinaries:
  518. ladspaBinaries.append(binary)
  519. ladspaBinaries.sort()
  520. if not self.fContinueChecking: return
  521. for i in range(len(ladspaBinaries)):
  522. ladspa = ladspaBinaries[i]
  523. percent = ( float(i) / len(ladspaBinaries) ) * self.fCurPercentValue
  524. self._pluginLook((self.fLastCheckValue + percent) * 0.9, ladspa)
  525. plugins = checkPluginLADSPA(ladspa, tool, isWine)
  526. if plugins:
  527. self.fLadspaPlugins.append(plugins)
  528. self.fSomethingChanged = True
  529. if not self.fContinueChecking: break
  530. self.fLastCheckValue += self.fCurPercentValue
  531. def _checkDSSI(self, OS, tool, isWine=False):
  532. dssiBinaries = []
  533. self.fDssiPlugins = []
  534. self._pluginLook(self.fLastCheckValue, "DSSI plugins...")
  535. settings = QSettings()
  536. DSSI_PATH = toList(settings.value("Paths/DSSI", Carla.DEFAULT_DSSI_PATH))
  537. for iPATH in DSSI_PATH:
  538. binaries = findBinaries(iPATH, OS)
  539. for binary in binaries:
  540. if binary not in dssiBinaries:
  541. dssiBinaries.append(binary)
  542. dssiBinaries.sort()
  543. if not self.fContinueChecking: return
  544. for i in range(len(dssiBinaries)):
  545. dssi = dssiBinaries[i]
  546. percent = ( float(i) / len(dssiBinaries) ) * self.fCurPercentValue
  547. self._pluginLook(self.fLastCheckValue + percent, dssi)
  548. plugins = checkPluginDSSI(dssi, tool, isWine)
  549. if plugins:
  550. self.fDssiPlugins.append(plugins)
  551. self.fSomethingChanged = True
  552. if not self.fContinueChecking: break
  553. self.fLastCheckValue += self.fCurPercentValue
  554. def _checkLV2(self, tool, isWine=False):
  555. lv2Bundles = []
  556. self.fLv2Plugins = []
  557. self._pluginLook(self.fLastCheckValue, "LV2 bundles...")
  558. settings = QSettings()
  559. LV2_PATH = toList(settings.value("Paths/LV2", Carla.DEFAULT_LV2_PATH))
  560. for iPATH in LV2_PATH:
  561. bundles = findLV2Bundles(iPATH)
  562. for bundle in bundles:
  563. if bundle not in lv2Bundles:
  564. lv2Bundles.append(bundle)
  565. lv2Bundles.sort()
  566. if not self.fContinueChecking: return
  567. for i in range(len(lv2Bundles)):
  568. lv2 = lv2Bundles[i]
  569. percent = ( float(i) / len(lv2Bundles) ) * self.fCurPercentValue
  570. self._pluginLook(self.fLastCheckValue + percent, lv2)
  571. plugins = checkPluginLV2(lv2, tool, isWine)
  572. if plugins:
  573. self.fLv2Plugins.append(plugins)
  574. self.fSomethingChanged = True
  575. if not self.fContinueChecking: break
  576. self.fLastCheckValue += self.fCurPercentValue
  577. def _checkVST(self, OS, tool, isWine=False):
  578. vstBinaries = []
  579. self.fVstPlugins = []
  580. if MACOS and not isWine:
  581. self._pluginLook(self.fLastCheckValue, "VST bundles...")
  582. else:
  583. self._pluginLook(self.fLastCheckValue, "VST plugins...")
  584. settings = QSettings()
  585. VST_PATH = toList(settings.value("Paths/VST", Carla.DEFAULT_VST_PATH))
  586. for iPATH in VST_PATH:
  587. if MACOS and not isWine:
  588. binaries = findMacVSTBundles(iPATH)
  589. else:
  590. binaries = findBinaries(iPATH, OS)
  591. for binary in binaries:
  592. if binary not in vstBinaries:
  593. vstBinaries.append(binary)
  594. vstBinaries.sort()
  595. if not self.fContinueChecking: return
  596. for i in range(len(vstBinaries)):
  597. vst = vstBinaries[i]
  598. percent = ( float(i) / len(vstBinaries) ) * self.fCurPercentValue
  599. self._pluginLook(self.fLastCheckValue + percent, vst)
  600. plugins = checkPluginVST(vst, tool, isWine)
  601. if plugins:
  602. self.fVstPlugins.append(plugins)
  603. self.fSomethingChanged = True
  604. if not self.fContinueChecking: break
  605. self.fLastCheckValue += self.fCurPercentValue
  606. def _checkAU(self, tool):
  607. auBinaries = []
  608. self.fAuPlugins = []
  609. # FIXME - this probably uses bundles
  610. self._pluginLook(self.fLastCheckValue, "AU plugins...")
  611. settings = QSettings()
  612. AU_PATH = toList(settings.value("Paths/AU", Carla.DEFAULT_AU_PATH))
  613. for iPATH in AU_PATH:
  614. binaries = findBinaries(iPATH, "MACOS")
  615. for binary in binaries:
  616. if binary not in auBinaries:
  617. auBinaries.append(binary)
  618. auBinaries.sort()
  619. if not self.fContinueChecking: return
  620. for i in range(len(auBinaries)):
  621. au = auBinaries[i]
  622. percent = ( float(i) / len(auBinaries) ) * self.fCurPercentValue
  623. self._pluginLook(self.fLastCheckValue + percent, au)
  624. plugins = checkPluginAU(au, tool)
  625. if plugins:
  626. self.fAuPlugins.append(plugins)
  627. self.fSomethingChanged = True
  628. if not self.fContinueChecking: break
  629. self.fLastCheckValue += self.fCurPercentValue
  630. def _checkCSD(self):
  631. csdFiles = []
  632. self.fCsdFiles = []
  633. settings = QSettings()
  634. CSOUND_PATH = toList(settings.value("Paths/CSOUND", Carla.DEFAULT_CSOUND_PATH))
  635. for iPATH in CSOUND_PATH:
  636. files = findFilenames(iPATH, "csd")
  637. for file_ in files:
  638. if file_ not in csdFiles:
  639. csdFiles.append(file_)
  640. csdFiles.sort()
  641. if not self.fContinueChecking: return
  642. for i in range(len(csdFiles)):
  643. csd = csdFiles[i]
  644. percent = ( float(i) / len(csdFiles) ) * self.fCurPercentValue
  645. self._pluginLook(self.fLastCheckValue + percent, csd)
  646. plugins = checkFileCSD(csd, self.fToolNative)
  647. if plugins:
  648. self.fCsdFiles.append(plugins)
  649. self.fSomethingChanged = True
  650. if not self.fContinueChecking: break
  651. self.fLastCheckValue += self.fCurPercentValue
  652. def _checkKIT(self, kitPATH, kitExtension):
  653. kitFiles = []
  654. self.fKitPlugins = []
  655. for iPATH in kitPATH:
  656. files = findFilenames(iPATH, kitExtension)
  657. for file_ in files:
  658. if file_ not in kitFiles:
  659. kitFiles.append(file_)
  660. kitFiles.sort()
  661. if not self.fContinueChecking: return
  662. for i in range(len(kitFiles)):
  663. kit = kitFiles[i]
  664. percent = ( float(i) / len(kitFiles) ) * self.fCurPercentValue
  665. self._pluginLook(self.fLastCheckValue + percent, kit)
  666. if kitExtension == "gig":
  667. plugins = checkFileGIG(kit, self.fToolNative)
  668. elif kitExtension == "sf2":
  669. plugins = checkFileSF2(kit, self.fToolNative)
  670. elif kitExtension == "sfz":
  671. plugins = checkFileSFZ(kit, self.fToolNative)
  672. else:
  673. plugins = None
  674. if plugins:
  675. self.fKitPlugins.append(plugins)
  676. self.fSomethingChanged = True
  677. if not self.fContinueChecking: break
  678. self.fLastCheckValue += self.fCurPercentValue
  679. def _pluginLook(self, percent, plugin):
  680. self.pluginLook.emit(percent, plugin)
  681. # ------------------------------------------------------------------------------------------------------------
  682. # Plugin Refresh Dialog
  683. class PluginRefreshW(QDialog):
  684. def __init__(self, parent):
  685. QDialog.__init__(self, parent)
  686. self.ui = ui_carla_refresh.Ui_PluginRefreshW()
  687. self.ui.setupUi(self)
  688. # -------------------------------------------------------------
  689. # Internal stuff
  690. self.fThread = SearchPluginsThread(self)
  691. # -------------------------------------------------------------
  692. # Load settings
  693. self.loadSettings()
  694. # -------------------------------------------------------------
  695. # Set-up GUI
  696. self.fIconYes = getIcon("dialog-ok-apply").pixmap(16, 16)
  697. self.fIconNo = getIcon("dialog-error").pixmap(16, 16)
  698. self.ui.b_skip.setVisible(False)
  699. if HAIKU:
  700. self.ui.ch_posix32.setText("Haiku 32bit")
  701. self.ui.ch_posix64.setText("Haiku 64bit")
  702. elif LINUX:
  703. self.ui.ch_posix32.setText("Linux 32bit")
  704. self.ui.ch_posix64.setText("Linux 64bit")
  705. elif MACOS:
  706. self.ui.ch_posix32.setText("MacOS 32bit")
  707. self.ui.ch_posix64.setText("MacOS 64bit")
  708. if Carla.discovery_posix32 and not WINDOWS:
  709. self.ui.ico_posix32.setPixmap(self.fIconYes)
  710. else:
  711. self.ui.ico_posix32.setPixmap(self.fIconNo)
  712. self.ui.ch_posix32.setChecked(False)
  713. self.ui.ch_posix32.setEnabled(False)
  714. if Carla.discovery_posix64 and not WINDOWS:
  715. self.ui.ico_posix64.setPixmap(self.fIconYes)
  716. else:
  717. self.ui.ico_posix64.setPixmap(self.fIconNo)
  718. self.ui.ch_posix64.setChecked(False)
  719. self.ui.ch_posix64.setEnabled(False)
  720. if Carla.discovery_win32:
  721. self.ui.ico_win32.setPixmap(self.fIconYes)
  722. else:
  723. self.ui.ico_win32.setPixmap(self.fIconNo)
  724. self.ui.ch_win32.setChecked(False)
  725. self.ui.ch_win32.setEnabled(False)
  726. if Carla.discovery_win64:
  727. self.ui.ico_win64.setPixmap(self.fIconYes)
  728. else:
  729. self.ui.ico_win64.setPixmap(self.fIconNo)
  730. self.ui.ch_win64.setChecked(False)
  731. self.ui.ch_win64.setEnabled(False)
  732. if haveLRDF:
  733. self.ui.ico_rdflib.setPixmap(self.fIconYes)
  734. else:
  735. self.ui.ico_rdflib.setPixmap(self.fIconNo)
  736. hasNative = bool(Carla.discovery_native)
  737. hasNonNative = False
  738. if WINDOWS:
  739. if kIs64bit:
  740. hasNative = bool(Carla.discovery_win64)
  741. hasNonNative = bool(Carla.discovery_win32)
  742. self.fThread.setSearchToolNative(Carla.discovery_win64)
  743. self.ui.ch_win64.setChecked(False)
  744. self.ui.ch_win64.setVisible(False)
  745. self.ui.ico_win64.setVisible(False)
  746. self.ui.label_win64.setVisible(False)
  747. else:
  748. hasNative = bool(Carla.discovery_win32)
  749. hasNonNative = bool(Carla.discovery_win64)
  750. self.fThread.setSearchToolNative(Carla.discovery_win32)
  751. self.ui.ch_win32.setChecked(False)
  752. self.ui.ch_win32.setVisible(False)
  753. self.ui.ico_win32.setVisible(False)
  754. self.ui.label_win32.setVisible(False)
  755. elif LINUX or MACOS:
  756. if kIs64bit:
  757. hasNonNative = bool(Carla.discovery_posix32 or Carla.discovery_win32 or Carla.discovery_win64)
  758. self.ui.ch_posix64.setChecked(False)
  759. self.ui.ch_posix64.setVisible(False)
  760. self.ui.ico_posix64.setVisible(False)
  761. self.ui.label_posix64.setVisible(False)
  762. else:
  763. hasNonNative = bool(Carla.discovery_posix64 or Carla.discovery_win32 or Carla.discovery_win64)
  764. self.ui.ch_posix32.setChecked(False)
  765. self.ui.ch_posix32.setVisible(False)
  766. self.ui.ico_posix32.setVisible(False)
  767. self.ui.label_posix32.setVisible(False)
  768. if hasNative:
  769. self.ui.ico_native.setPixmap(self.fIconYes)
  770. else:
  771. self.ui.ico_native.setPixmap(self.fIconNo)
  772. self.ui.ch_native.setChecked(False)
  773. self.ui.ch_native.setEnabled(False)
  774. self.ui.ch_csound.setChecked(False)
  775. self.ui.ch_csound.setEnabled(False)
  776. self.ui.ch_gig.setChecked(False)
  777. self.ui.ch_gig.setEnabled(False)
  778. self.ui.ch_sf2.setChecked(False)
  779. self.ui.ch_sf2.setEnabled(False)
  780. self.ui.ch_sfz.setChecked(False)
  781. self.ui.ch_sfz.setEnabled(False)
  782. if not hasNonNative:
  783. self.ui.ch_ladspa.setChecked(False)
  784. self.ui.ch_ladspa.setEnabled(False)
  785. self.ui.ch_dssi.setChecked(False)
  786. self.ui.ch_dssi.setEnabled(False)
  787. self.ui.ch_lv2.setChecked(False)
  788. self.ui.ch_lv2.setEnabled(False)
  789. self.ui.ch_vst.setChecked(False)
  790. self.ui.ch_vst.setEnabled(False)
  791. self.ui.ch_au.setChecked(False)
  792. self.ui.ch_au.setEnabled(False)
  793. self.ui.b_start.setEnabled(False)
  794. if not MACOS:
  795. self.ui.ch_au.setChecked(False)
  796. self.ui.ch_au.setEnabled(False)
  797. self.ui.ch_au.setVisible(False)
  798. # -------------------------------------------------------------
  799. # Set-up connections
  800. self.ui.b_start.clicked.connect(self.slot_start)
  801. self.ui.b_skip.clicked.connect(self.slot_skip)
  802. self.ui.ch_native.clicked.connect(self.slot_checkTools)
  803. self.ui.ch_posix32.clicked.connect(self.slot_checkTools)
  804. self.ui.ch_posix64.clicked.connect(self.slot_checkTools)
  805. self.ui.ch_win32.clicked.connect(self.slot_checkTools)
  806. self.ui.ch_win64.clicked.connect(self.slot_checkTools)
  807. self.ui.ch_ladspa.clicked.connect(self.slot_checkTools)
  808. self.ui.ch_dssi.clicked.connect(self.slot_checkTools)
  809. self.ui.ch_lv2.clicked.connect(self.slot_checkTools)
  810. self.ui.ch_vst.clicked.connect(self.slot_checkTools)
  811. self.ui.ch_au.clicked.connect(self.slot_checkTools)
  812. self.ui.ch_csound.clicked.connect(self.slot_checkTools)
  813. self.ui.ch_gig.clicked.connect(self.slot_checkTools)
  814. self.ui.ch_sf2.clicked.connect(self.slot_checkTools)
  815. self.ui.ch_sfz.clicked.connect(self.slot_checkTools)
  816. self.fThread.pluginLook.connect(self.slot_handlePluginLook)
  817. self.fThread.finished.connect(self.slot_handlePluginThreadFinished)
  818. @pyqtSlot()
  819. def slot_start(self):
  820. self.ui.progressBar.setMinimum(0)
  821. self.ui.progressBar.setMaximum(100)
  822. self.ui.progressBar.setValue(0)
  823. self.ui.b_start.setEnabled(False)
  824. self.ui.b_skip.setVisible(True)
  825. self.ui.b_close.setVisible(False)
  826. native, posix32, posix64, win32, win64 = (self.ui.ch_native.isChecked(),
  827. self.ui.ch_posix32.isChecked(), self.ui.ch_posix64.isChecked(),
  828. self.ui.ch_win32.isChecked(), self.ui.ch_win64.isChecked())
  829. ladspa, dssi, lv2, vst, au, csound, gig, sf2, sfz = (self.ui.ch_ladspa.isChecked(), self.ui.ch_dssi.isChecked(),
  830. self.ui.ch_lv2.isChecked(), self.ui.ch_vst.isChecked(),
  831. self.ui.ch_au.isChecked(), self.ui.ch_csound.isChecked(),
  832. self.ui.ch_gig.isChecked(), self.ui.ch_sf2.isChecked(), self.ui.ch_sfz.isChecked())
  833. self.fThread.setSearchBinaryTypes(native, posix32, posix64, win32, win64)
  834. self.fThread.setSearchPluginTypes(ladspa, dssi, lv2, vst, au, csound, gig, sf2, sfz)
  835. self.fThread.start()
  836. @pyqtSlot()
  837. def slot_skip(self):
  838. killDiscovery()
  839. @pyqtSlot()
  840. def slot_checkTools(self):
  841. enabled1 = bool(self.ui.ch_native.isChecked() or self.ui.ch_posix32.isChecked() or self.ui.ch_posix64.isChecked() or self.ui.ch_win32.isChecked() or self.ui.ch_win64.isChecked())
  842. enabled2 = bool(self.ui.ch_ladspa.isChecked() or self.ui.ch_dssi.isChecked() or self.ui.ch_lv2.isChecked() or self.ui.ch_vst.isChecked() or self.ui.ch_au.isChecked() or
  843. self.ui.ch_csound.isChecked() or self.ui.ch_gig.isChecked() or self.ui.ch_sf2.isChecked() or self.ui.ch_sfz.isChecked())
  844. self.ui.b_start.setEnabled(enabled1 and enabled2)
  845. @pyqtSlot(int, str)
  846. def slot_handlePluginLook(self, percent, plugin):
  847. self.ui.progressBar.setFormat("%s" % plugin)
  848. self.ui.progressBar.setValue(percent)
  849. @pyqtSlot()
  850. def slot_handlePluginThreadFinished(self):
  851. self.ui.progressBar.setMinimum(0)
  852. self.ui.progressBar.setMaximum(1)
  853. self.ui.progressBar.setValue(1)
  854. self.ui.progressBar.setFormat(self.tr("Done"))
  855. self.ui.b_start.setEnabled(True)
  856. self.ui.b_skip.setVisible(False)
  857. self.ui.b_close.setVisible(True)
  858. def loadSettings(self):
  859. settings = QSettings()
  860. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/SearchLADSPA", True, type=bool))
  861. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/SearchDSSI", True, type=bool))
  862. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/SearchLV2", True, type=bool))
  863. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/SearchVST", True, type=bool))
  864. self.ui.ch_au.setChecked(settings.value("PluginDatabase/SearchAU", True, type=bool))
  865. self.ui.ch_csound.setChecked(settings.value("PluginDatabase/SearchCsound", False, type=bool))
  866. self.ui.ch_gig.setChecked(settings.value("PluginDatabase/SearchGIG", False, type=bool))
  867. self.ui.ch_sf2.setChecked(settings.value("PluginDatabase/SearchSF2", False, type=bool))
  868. self.ui.ch_sfz.setChecked(settings.value("PluginDatabase/SearchSFZ", False, type=bool))
  869. self.ui.ch_native.setChecked(settings.value("PluginDatabase/SearchNative", True, type=bool))
  870. self.ui.ch_posix32.setChecked(settings.value("PluginDatabase/SearchPOSIX32", False, type=bool))
  871. self.ui.ch_posix64.setChecked(settings.value("PluginDatabase/SearchPOSIX64", False, type=bool))
  872. self.ui.ch_win32.setChecked(settings.value("PluginDatabase/SearchWin32", False, type=bool))
  873. self.ui.ch_win64.setChecked(settings.value("PluginDatabase/SearchWin64", False, type=bool))
  874. def saveSettings(self):
  875. settings = QSettings()
  876. settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked())
  877. settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked())
  878. settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked())
  879. settings.setValue("PluginDatabase/SearchVST", self.ui.ch_vst.isChecked())
  880. settings.setValue("PluginDatabase/SearchAU", self.ui.ch_au.isChecked())
  881. settings.setValue("PluginDatabase/SearchCsound", self.ui.ch_csound.isChecked())
  882. settings.setValue("PluginDatabase/SearchGIG", self.ui.ch_gig.isChecked())
  883. settings.setValue("PluginDatabase/SearchSF2", self.ui.ch_sf2.isChecked())
  884. settings.setValue("PluginDatabase/SearchSFZ", self.ui.ch_sfz.isChecked())
  885. settings.setValue("PluginDatabase/SearchNative", self.ui.ch_native.isChecked())
  886. settings.setValue("PluginDatabase/SearchPOSIX32", self.ui.ch_posix32.isChecked())
  887. settings.setValue("PluginDatabase/SearchPOSIX64", self.ui.ch_posix64.isChecked())
  888. settings.setValue("PluginDatabase/SearchWin32", self.ui.ch_win32.isChecked())
  889. settings.setValue("PluginDatabase/SearchWin64", self.ui.ch_win64.isChecked())
  890. def closeEvent(self, event):
  891. self.saveSettings()
  892. if self.fThread.isRunning():
  893. self.fThread.stop()
  894. killDiscovery()
  895. #self.fThread.terminate()
  896. self.fThread.wait()
  897. if self.fThread.hasSomethingChanged():
  898. self.accept()
  899. else:
  900. self.reject()
  901. QDialog.closeEvent(self, event)
  902. def done(self, r):
  903. QDialog.done(self, r)
  904. self.close()
  905. # ------------------------------------------------------------------------------------------------------------
  906. # Plugin Database Dialog
  907. class PluginDatabaseW(QDialog):
  908. def __init__(self, parent):
  909. QDialog.__init__(self, parent)
  910. self.ui = ui_carla_database.Ui_PluginDatabaseW()
  911. self.ui.setupUi(self)
  912. # -------------------------------------------------------------
  913. # Internal stuff
  914. self.fLastTableIndex = 0
  915. self.fRetPlugin = None
  916. self.fRealParent = parent
  917. # -------------------------------------------------------------
  918. # Load settings
  919. self.loadSettings()
  920. # -------------------------------------------------------------
  921. # Set-up GUI
  922. self.ui.b_add.setEnabled(False)
  923. if BINARY_NATIVE in (BINARY_POSIX32, BINARY_WIN32):
  924. self.ui.ch_bridged.setText(self.tr("Bridged (64bit)"))
  925. else:
  926. self.ui.ch_bridged.setText(self.tr("Bridged (32bit)"))
  927. if not (LINUX or MACOS):
  928. self.ui.ch_bridged_wine.setChecked(False)
  929. self.ui.ch_bridged_wine.setEnabled(False)
  930. # -------------------------------------------------------------
  931. # Set-up connections
  932. self.ui.b_add.clicked.connect(self.slot_addPlugin)
  933. self.ui.b_refresh.clicked.connect(self.slot_refreshPlugins)
  934. self.ui.tb_filters.clicked.connect(self.slot_maybeShowFilters)
  935. self.ui.lineEdit.textChanged.connect(self.slot_checkFilters)
  936. self.ui.tableWidget.currentCellChanged.connect(self.slot_checkPlugin)
  937. self.ui.tableWidget.cellDoubleClicked.connect(self.slot_addPlugin)
  938. self.ui.ch_effects.clicked.connect(self.slot_checkFilters)
  939. self.ui.ch_instruments.clicked.connect(self.slot_checkFilters)
  940. self.ui.ch_midi.clicked.connect(self.slot_checkFilters)
  941. self.ui.ch_other.clicked.connect(self.slot_checkFilters)
  942. self.ui.ch_internal.clicked.connect(self.slot_checkFilters)
  943. self.ui.ch_ladspa.clicked.connect(self.slot_checkFilters)
  944. self.ui.ch_dssi.clicked.connect(self.slot_checkFilters)
  945. self.ui.ch_lv2.clicked.connect(self.slot_checkFilters)
  946. self.ui.ch_vst.clicked.connect(self.slot_checkFilters)
  947. self.ui.ch_au.clicked.connect(self.slot_checkFilters)
  948. self.ui.ch_csound.clicked.connect(self.slot_checkFilters)
  949. self.ui.ch_kits.clicked.connect(self.slot_checkFilters)
  950. self.ui.ch_native.clicked.connect(self.slot_checkFilters)
  951. self.ui.ch_bridged.clicked.connect(self.slot_checkFilters)
  952. self.ui.ch_bridged_wine.clicked.connect(self.slot_checkFilters)
  953. self.ui.ch_rtsafe.clicked.connect(self.slot_checkFilters)
  954. self.ui.ch_gui.clicked.connect(self.slot_checkFilters)
  955. self.ui.ch_stereo.clicked.connect(self.slot_checkFilters)
  956. # -------------------------------------------------------------
  957. @pyqtSlot()
  958. def slot_addPlugin(self):
  959. if self.ui.tableWidget.currentRow() >= 0:
  960. self.fRetPlugin = self.ui.tableWidget.item(self.ui.tableWidget.currentRow(), 0).data(Qt.UserRole)
  961. self.accept()
  962. else:
  963. self.reject()
  964. @pyqtSlot(int)
  965. def slot_checkPlugin(self, row):
  966. self.ui.b_add.setEnabled(row >= 0)
  967. @pyqtSlot()
  968. def slot_checkFilters(self):
  969. self._checkFilters()
  970. @pyqtSlot()
  971. def slot_maybeShowFilters(self):
  972. self._showFilters(not self.ui.frame.isVisible())
  973. @pyqtSlot()
  974. def slot_refreshPlugins(self):
  975. if PluginRefreshW(self).exec_():
  976. self._reAddPlugins()
  977. if self.fRealParent:
  978. self.fRealParent.setLoadRDFsNeeded()
  979. def _checkFilters(self):
  980. text = self.ui.lineEdit.text().lower()
  981. hideEffects = not self.ui.ch_effects.isChecked()
  982. hideInstruments = not self.ui.ch_instruments.isChecked()
  983. hideMidi = not self.ui.ch_midi.isChecked()
  984. hideOther = not self.ui.ch_other.isChecked()
  985. hideInternal = not self.ui.ch_internal.isChecked()
  986. hideLadspa = not self.ui.ch_ladspa.isChecked()
  987. hideDssi = not self.ui.ch_dssi.isChecked()
  988. hideLV2 = not self.ui.ch_lv2.isChecked()
  989. hideVST = not self.ui.ch_vst.isChecked()
  990. hideAU = not self.ui.ch_au.isChecked()
  991. hideCsound = not self.ui.ch_csound.isChecked()
  992. hideKits = not self.ui.ch_kits.isChecked()
  993. hideNative = not self.ui.ch_native.isChecked()
  994. hideBridged = not self.ui.ch_bridged.isChecked()
  995. hideBridgedWine = not self.ui.ch_bridged_wine.isChecked()
  996. hideNonRtSafe = self.ui.ch_rtsafe.isChecked()
  997. hideNonGui = self.ui.ch_gui.isChecked()
  998. hideNonStereo = self.ui.ch_stereo.isChecked()
  999. if HAIKU or LINUX or MACOS:
  1000. nativeBins = [BINARY_POSIX32, BINARY_POSIX64]
  1001. wineBins = [BINARY_WIN32, BINARY_WIN64]
  1002. elif WINDOWS:
  1003. nativeBins = [BINARY_WIN32, BINARY_WIN64]
  1004. wineBins = []
  1005. else:
  1006. nativeBins = []
  1007. wineBins = []
  1008. rowCount = self.ui.tableWidget.rowCount()
  1009. for i in range(rowCount):
  1010. self.ui.tableWidget.showRow(i)
  1011. plugin = self.ui.tableWidget.item(i, 0).data(Qt.UserRole)
  1012. aIns = plugin['audio.ins']
  1013. aOuts = plugin['audio.outs']
  1014. mIns = plugin['midi.ins']
  1015. mOuts = plugin['midi.outs']
  1016. ptype = self.ui.tableWidget.item(i, 12).text()
  1017. isSynth = bool(plugin['hints'] & PLUGIN_IS_SYNTH)
  1018. isEffect = bool(aIns > 0 < aOuts and not isSynth)
  1019. isMidi = bool(aIns == 0 and aOuts == 0 and mIns > 0 < mOuts)
  1020. isKit = bool(ptype in ("GIG", "SF2", "SFZ"))
  1021. isOther = bool(not (isEffect or isSynth or isMidi or isKit))
  1022. isNative = bool(plugin['build'] == BINARY_NATIVE)
  1023. isRtSafe = bool(plugin['hints'] & PLUGIN_IS_RTSAFE)
  1024. isStereo = bool(aIns == 2 and aOuts == 2) or (isSynth and aOuts == 2)
  1025. hasGui = bool(plugin['hints'] & PLUGIN_HAS_CUSTOM_UI)
  1026. isBridged = bool(not isNative and plugin['build'] in nativeBins)
  1027. isBridgedWine = bool(not isNative and plugin['build'] in wineBins)
  1028. if hideEffects and isEffect:
  1029. self.ui.tableWidget.hideRow(i)
  1030. elif hideInstruments and isSynth:
  1031. self.ui.tableWidget.hideRow(i)
  1032. elif hideMidi and isMidi:
  1033. self.ui.tableWidget.hideRow(i)
  1034. elif hideOther and isOther:
  1035. self.ui.tableWidget.hideRow(i)
  1036. elif hideKits and isKit:
  1037. self.ui.tableWidget.hideRow(i)
  1038. elif hideInternal and ptype == self.tr("Internal"):
  1039. self.ui.tableWidget.hideRow(i)
  1040. elif hideLadspa and ptype == "LADSPA":
  1041. self.ui.tableWidget.hideRow(i)
  1042. elif hideDssi and ptype == "DSSI":
  1043. self.ui.tableWidget.hideRow(i)
  1044. elif hideLV2 and ptype == "LV2":
  1045. self.ui.tableWidget.hideRow(i)
  1046. elif hideVST and ptype == "VST":
  1047. self.ui.tableWidget.hideRow(i)
  1048. elif hideAU and ptype == "AU":
  1049. self.ui.tableWidget.hideRow(i)
  1050. elif hideCsound and ptype == "CSD":
  1051. self.ui.tableWidget.hideRow(i)
  1052. elif hideNative and isNative:
  1053. self.ui.tableWidget.hideRow(i)
  1054. elif hideBridged and isBridged:
  1055. self.ui.tableWidget.hideRow(i)
  1056. elif hideBridgedWine and isBridgedWine:
  1057. self.ui.tableWidget.hideRow(i)
  1058. elif hideNonRtSafe and not isRtSafe:
  1059. self.ui.tableWidget.hideRow(i)
  1060. elif hideNonGui and not hasGui:
  1061. self.ui.tableWidget.hideRow(i)
  1062. elif hideNonStereo and not isStereo:
  1063. self.ui.tableWidget.hideRow(i)
  1064. elif (text and not (
  1065. text in self.ui.tableWidget.item(i, 0).text().lower() or
  1066. text in self.ui.tableWidget.item(i, 1).text().lower() or
  1067. text in self.ui.tableWidget.item(i, 2).text().lower() or
  1068. text in self.ui.tableWidget.item(i, 3).text().lower() or
  1069. text in self.ui.tableWidget.item(i, 13).text().lower())):
  1070. self.ui.tableWidget.hideRow(i)
  1071. def _showFilters(self, yesNo):
  1072. self.ui.tb_filters.setArrowType(Qt.UpArrow if yesNo else Qt.DownArrow)
  1073. self.ui.frame.setVisible(yesNo)
  1074. def _addPluginToTable(self, plugin, ptype):
  1075. if plugin['API'] != PLUGIN_QUERY_API_VERSION:
  1076. return
  1077. index = self.fLastTableIndex
  1078. if plugin['build'] == BINARY_NATIVE:
  1079. bridgeText = self.tr("No")
  1080. else:
  1081. if LINUX or MACOS:
  1082. if plugin['build'] == BINARY_WIN32:
  1083. typeText = "32bit"
  1084. elif plugin['build'] == BINARY_WIN64:
  1085. typeText = "64bit"
  1086. else:
  1087. typeText = self.tr("Unknown")
  1088. else:
  1089. if plugin['build'] == BINARY_POSIX32:
  1090. typeText = "32bit"
  1091. elif plugin['build'] == BINARY_POSIX64:
  1092. typeText = "64bit"
  1093. elif plugin['build'] == BINARY_WIN32:
  1094. typeText = "Windows 32bit"
  1095. elif plugin['build'] == BINARY_WIN64:
  1096. typeText = "Windows 64bit"
  1097. else:
  1098. typeText = self.tr("Unknown")
  1099. bridgeText = self.tr("Yes (%s)" % typeText)
  1100. self.ui.tableWidget.insertRow(index)
  1101. self.ui.tableWidget.setItem(index, 0, QTableWidgetItem(str(plugin['name'])))
  1102. self.ui.tableWidget.setItem(index, 1, QTableWidgetItem(str(plugin['label'])))
  1103. self.ui.tableWidget.setItem(index, 2, QTableWidgetItem(str(plugin['maker'])))
  1104. self.ui.tableWidget.setItem(index, 3, QTableWidgetItem(str(plugin['uniqueId'])))
  1105. self.ui.tableWidget.setItem(index, 4, QTableWidgetItem(str(plugin['audio.ins'])))
  1106. self.ui.tableWidget.setItem(index, 5, QTableWidgetItem(str(plugin['audio.outs'])))
  1107. self.ui.tableWidget.setItem(index, 6, QTableWidgetItem(str(plugin['parameters.ins'])))
  1108. self.ui.tableWidget.setItem(index, 7, QTableWidgetItem(str(plugin['parameters.outs'])))
  1109. self.ui.tableWidget.setItem(index, 8, QTableWidgetItem(str(plugin['programs.total'])))
  1110. self.ui.tableWidget.setItem(index, 9, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_HAS_CUSTOM_UI) else self.tr("No")))
  1111. self.ui.tableWidget.setItem(index, 10, QTableWidgetItem(self.tr("Yes") if (plugin['hints'] & PLUGIN_IS_SYNTH) else self.tr("No")))
  1112. self.ui.tableWidget.setItem(index, 11, QTableWidgetItem(bridgeText))
  1113. self.ui.tableWidget.setItem(index, 12, QTableWidgetItem(ptype))
  1114. self.ui.tableWidget.setItem(index, 13, QTableWidgetItem(str(plugin['filename'])))
  1115. self.ui.tableWidget.item(index, 0).setData(Qt.UserRole, plugin)
  1116. self.fLastTableIndex += 1
  1117. def _reAddPlugins(self):
  1118. settingsDB = QSettings("falkTX", "CarlaPlugins2")
  1119. for x in range(self.ui.tableWidget.rowCount()):
  1120. self.ui.tableWidget.removeRow(0)
  1121. self.fLastTableIndex = 0
  1122. self.ui.tableWidget.setSortingEnabled(False)
  1123. internalCount = 0
  1124. ladspaCount = 0
  1125. dssiCount = 0
  1126. lv2Count = 0
  1127. vstCount = 0
  1128. auCount = 0
  1129. csdCount = 0
  1130. kitCount = 0
  1131. # ---------------------------------------------------------------------------
  1132. # Internal
  1133. internalPlugins = toList(settingsDB.value("Plugins/Internal", []))
  1134. for plugins in internalPlugins:
  1135. internalCount += len(plugins)
  1136. canRefreshInternals = not (Carla.isControl or Carla.isPlugin or Carla.host is None)
  1137. if canRefreshInternals and internalCount != Carla.host.get_internal_plugin_count():
  1138. internalCount = Carla.host.get_internal_plugin_count()
  1139. internalPlugins = []
  1140. for i in range(Carla.host.get_internal_plugin_count()):
  1141. descInfo = Carla.host.get_internal_plugin_info(i)
  1142. plugins = checkPluginInternal(descInfo)
  1143. if plugins:
  1144. internalPlugins.append(plugins)
  1145. settingsDB.setValue("Plugins/Internal", internalPlugins)
  1146. for plugins in internalPlugins:
  1147. for plugin in plugins:
  1148. self._addPluginToTable(plugin, self.tr("Internal"))
  1149. del internalPlugins
  1150. # ---------------------------------------------------------------------------
  1151. # LADSPA
  1152. ladspaPlugins = []
  1153. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_native", []))
  1154. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix32", []))
  1155. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix64", []))
  1156. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win32", []))
  1157. ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win64", []))
  1158. for plugins in ladspaPlugins:
  1159. for plugin in plugins:
  1160. self._addPluginToTable(plugin, "LADSPA")
  1161. ladspaCount += 1
  1162. del ladspaPlugins
  1163. # ---------------------------------------------------------------------------
  1164. # DSSI
  1165. dssiPlugins = []
  1166. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_native", []))
  1167. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix32", []))
  1168. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix64", []))
  1169. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win32", []))
  1170. dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win64", []))
  1171. for plugins in dssiPlugins:
  1172. for plugin in plugins:
  1173. self._addPluginToTable(plugin, "DSSI")
  1174. dssiCount += 1
  1175. del dssiPlugins
  1176. # ---------------------------------------------------------------------------
  1177. # LV2
  1178. lv2Plugins = []
  1179. lv2Plugins += toList(settingsDB.value("Plugins/LV2_native", []))
  1180. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix32", []))
  1181. lv2Plugins += toList(settingsDB.value("Plugins/LV2_posix64", []))
  1182. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win32", []))
  1183. lv2Plugins += toList(settingsDB.value("Plugins/LV2_win64", []))
  1184. for plugins in lv2Plugins:
  1185. for plugin in plugins:
  1186. self._addPluginToTable(plugin, "LV2")
  1187. lv2Count += 1
  1188. del lv2Plugins
  1189. # ---------------------------------------------------------------------------
  1190. # VST
  1191. vstPlugins = []
  1192. vstPlugins += toList(settingsDB.value("Plugins/VST_native", []))
  1193. vstPlugins += toList(settingsDB.value("Plugins/VST_posix32", []))
  1194. vstPlugins += toList(settingsDB.value("Plugins/VST_posix64", []))
  1195. vstPlugins += toList(settingsDB.value("Plugins/VST_win32", []))
  1196. vstPlugins += toList(settingsDB.value("Plugins/VST_win64", []))
  1197. for plugins in vstPlugins:
  1198. for plugin in plugins:
  1199. self._addPluginToTable(plugin, "VST")
  1200. vstCount += 1
  1201. del vstPlugins
  1202. # ---------------------------------------------------------------------------
  1203. # AU
  1204. if MACOS:
  1205. auPlugins = []
  1206. auPlugins += toList(settingsDB.value("Plugins/AU_native", []))
  1207. auPlugins += toList(settingsDB.value("Plugins/AU_posix32", []))
  1208. auPlugins += toList(settingsDB.value("Plugins/AU_posix64", []))
  1209. for plugins in auPlugins:
  1210. for plugin in plugins:
  1211. self._addPluginToTable(plugin, "AU")
  1212. auCount += 1
  1213. del auPlugins
  1214. # ---------------------------------------------------------------------------
  1215. # Csound
  1216. csds = toList(settingsDB.value("Plugins/CSD", []))
  1217. for csd in csds:
  1218. for csd_i in csd:
  1219. self._addPluginToTable(csd_i, "CSD")
  1220. csdCount += 1
  1221. del csds
  1222. # ---------------------------------------------------------------------------
  1223. # Kits
  1224. gigs = toList(settingsDB.value("Plugins/GIG", []))
  1225. for gig in gigs:
  1226. for gig_i in gig:
  1227. self._addPluginToTable(gig_i, "GIG")
  1228. kitCount += 1
  1229. del gigs
  1230. # ---------------------------------------------------------------------------
  1231. sf2s = toList(settingsDB.value("Plugins/SF2", []))
  1232. for sf2 in sf2s:
  1233. for sf2_i in sf2:
  1234. self._addPluginToTable(sf2_i, "SF2")
  1235. kitCount += 1
  1236. del sf2s
  1237. # ---------------------------------------------------------------------------
  1238. sfzs = toList(settingsDB.value("Plugins/SFZ", []))
  1239. for sfz in sfzs:
  1240. for sfz_i in sfz:
  1241. self._addPluginToTable(sfz_i, "SFZ")
  1242. kitCount += 1
  1243. del sfzs
  1244. # ---------------------------------------------------------------------------
  1245. self.ui.tableWidget.setSortingEnabled(True)
  1246. self.ui.tableWidget.sortByColumn(0, Qt.AscendingOrder)
  1247. if MACOS:
  1248. self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2, %i VST and %i AudioUnit plugins, plus %i CSound modules and %i Sound Kits" % (
  1249. internalCount, ladspaCount, dssiCount, lv2Count, vstCount, auCount, csdCount, kitCount)))
  1250. else:
  1251. self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2 and %i VST plugins, plus %i CSound modules and %i Sound Kits" % (
  1252. internalCount, ladspaCount, dssiCount, lv2Count, vstCount, csdCount, kitCount)))
  1253. self._checkFilters()
  1254. def loadSettings(self):
  1255. settings = QSettings()
  1256. self.restoreGeometry(settings.value("PluginDatabase/Geometry", ""))
  1257. self.ui.tableWidget.horizontalHeader().restoreState(settings.value("PluginDatabase/TableGeometry", ""))
  1258. self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, type=bool))
  1259. self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, type=bool))
  1260. self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, type=bool))
  1261. self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, type=bool))
  1262. self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, type=bool))
  1263. self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, type=bool))
  1264. self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, type=bool))
  1265. self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, type=bool))
  1266. self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST", True, type=bool))
  1267. self.ui.ch_au.setChecked(settings.value("PluginDatabase/ShowAU", True, type=bool))
  1268. self.ui.ch_csound.setChecked(settings.value("PluginDatabase/ShowCsound", True, type=bool))
  1269. self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, type=bool))
  1270. self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, type=bool))
  1271. self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, type=bool))
  1272. self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, type=bool))
  1273. self.ui.ch_rtsafe.setChecked(settings.value("PluginDatabase/ShowRtSafe", False, type=bool))
  1274. self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, type=bool))
  1275. self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, type=bool))
  1276. self._showFilters(settings.value("PluginDatabase/ShowFilters", False, type=bool))
  1277. self._reAddPlugins()
  1278. def saveSettings(self):
  1279. settings = QSettings()
  1280. settings.setValue("PluginDatabase/Geometry", self.saveGeometry())
  1281. settings.setValue("PluginDatabase/TableGeometry", self.ui.tableWidget.horizontalHeader().saveState())
  1282. settings.setValue("PluginDatabase/ShowFilters", (self.ui.tb_filters.arrowType() == Qt.UpArrow))
  1283. settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked())
  1284. settings.setValue("PluginDatabase/ShowInstruments", self.ui.ch_instruments.isChecked())
  1285. settings.setValue("PluginDatabase/ShowMIDI", self.ui.ch_midi.isChecked())
  1286. settings.setValue("PluginDatabase/ShowOther", self.ui.ch_other.isChecked())
  1287. settings.setValue("PluginDatabase/ShowInternal", self.ui.ch_internal.isChecked())
  1288. settings.setValue("PluginDatabase/ShowLADSPA", self.ui.ch_ladspa.isChecked())
  1289. settings.setValue("PluginDatabase/ShowDSSI", self.ui.ch_dssi.isChecked())
  1290. settings.setValue("PluginDatabase/ShowLV2", self.ui.ch_lv2.isChecked())
  1291. settings.setValue("PluginDatabase/ShowVST", self.ui.ch_vst.isChecked())
  1292. settings.setValue("PluginDatabase/ShowAU", self.ui.ch_au.isChecked())
  1293. settings.setValue("PluginDatabase/ShowCsound", self.ui.ch_csound.isChecked())
  1294. settings.setValue("PluginDatabase/ShowKits", self.ui.ch_kits.isChecked())
  1295. settings.setValue("PluginDatabase/ShowNative", self.ui.ch_native.isChecked())
  1296. settings.setValue("PluginDatabase/ShowBridged", self.ui.ch_bridged.isChecked())
  1297. settings.setValue("PluginDatabase/ShowBridgedWine", self.ui.ch_bridged_wine.isChecked())
  1298. settings.setValue("PluginDatabase/ShowRtSafe", self.ui.ch_rtsafe.isChecked())
  1299. settings.setValue("PluginDatabase/ShowHasGUI", self.ui.ch_gui.isChecked())
  1300. settings.setValue("PluginDatabase/ShowStereoOnly", self.ui.ch_stereo.isChecked())
  1301. def closeEvent(self, event):
  1302. self.saveSettings()
  1303. QDialog.closeEvent(self, event)
  1304. def done(self, r):
  1305. QDialog.done(self, r)
  1306. self.close()
  1307. # ------------------------------------------------------------------------------------------------------------
  1308. # Main
  1309. if __name__ == '__main__':
  1310. from carla_style import CarlaApplication
  1311. app = CarlaApplication()
  1312. initHost("Settings", None, False)
  1313. gui = PluginDatabaseW(None)
  1314. gui.show()
  1315. sys.exit(app.exec_())