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 97KB

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