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.

carla_database.py 73KB

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