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.

773 lines
26KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla plugin host
  4. # Copyright (C) 2011-2022 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. import os
  20. from PyQt5.QtCore import pyqtSignal, QThread
  21. from PyQt5.QtWidgets import QWidget
  22. # ---------------------------------------------------------------------------------------------------------------------
  23. # Imports (Custom)
  24. from carla_backend import (
  25. PLUGIN_AU,
  26. PLUGIN_DSSI,
  27. PLUGIN_JSFX,
  28. PLUGIN_LADSPA,
  29. PLUGIN_LV2,
  30. PLUGIN_SFZ,
  31. PLUGIN_VST2,
  32. )
  33. from carla_shared import (
  34. CARLA_DEFAULT_DSSI_PATH,
  35. CARLA_DEFAULT_JSFX_PATH,
  36. CARLA_DEFAULT_LADSPA_PATH,
  37. CARLA_DEFAULT_LV2_PATH,
  38. CARLA_DEFAULT_SF2_PATH,
  39. CARLA_DEFAULT_SFZ_PATH,
  40. CARLA_DEFAULT_VST2_PATH,
  41. CARLA_DEFAULT_VST3_PATH,
  42. CARLA_DEFAULT_WINE_AUTO_PREFIX,
  43. CARLA_DEFAULT_WINE_EXECUTABLE,
  44. CARLA_DEFAULT_WINE_FALLBACK_PREFIX,
  45. CARLA_KEY_PATHS_DSSI,
  46. CARLA_KEY_PATHS_JSFX,
  47. CARLA_KEY_PATHS_LADSPA,
  48. CARLA_KEY_PATHS_LV2,
  49. CARLA_KEY_PATHS_SF2,
  50. CARLA_KEY_PATHS_SFZ,
  51. CARLA_KEY_PATHS_VST2,
  52. CARLA_KEY_PATHS_VST3,
  53. CARLA_KEY_WINE_AUTO_PREFIX,
  54. CARLA_KEY_WINE_EXECUTABLE,
  55. CARLA_KEY_WINE_FALLBACK_PREFIX,
  56. HAIKU,
  57. LINUX,
  58. MACOS,
  59. WINDOWS,
  60. gCarla,
  61. splitter,
  62. )
  63. from utils import QSafeSettings
  64. from .discovery import (
  65. checkAllPluginsAU,
  66. checkFileSF2,
  67. checkPluginCached,
  68. checkPluginDSSI,
  69. checkPluginLADSPA,
  70. checkPluginVST2,
  71. checkPluginVST3,
  72. findBinaries,
  73. findFilenames,
  74. findMacVSTBundles,
  75. findVST3Binaries
  76. )
  77. # ---------------------------------------------------------------------------------------------------------------------
  78. # Separate Thread for Plugin Search
  79. class SearchPluginsThread(QThread):
  80. pluginLook = pyqtSignal(float, str)
  81. def __init__(self, parent: QWidget, pathBinaries: str):
  82. QThread.__init__(self, parent)
  83. self.fContinueChecking = False
  84. self.fPathBinaries = pathBinaries
  85. self.fCheckNative = False
  86. self.fCheckPosix32 = False
  87. self.fCheckPosix64 = False
  88. self.fCheckWin32 = False
  89. self.fCheckWin64 = False
  90. self.fCheckLADSPA = False
  91. self.fCheckDSSI = False
  92. self.fCheckLV2 = False
  93. self.fCheckVST2 = False
  94. self.fCheckVST3 = False
  95. self.fCheckAU = False
  96. self.fCheckSF2 = False
  97. self.fCheckSFZ = False
  98. self.fCheckJSFX = False
  99. if WINDOWS:
  100. toolNative = "carla-discovery-native.exe"
  101. self.fWineSettings = None
  102. else:
  103. toolNative = "carla-discovery-native"
  104. settings = QSafeSettings("falkTX", "Carla2")
  105. self.fWineSettings = {
  106. 'executable' : settings.value(CARLA_KEY_WINE_EXECUTABLE,
  107. CARLA_DEFAULT_WINE_EXECUTABLE, str),
  108. 'autoPrefix' : settings.value(CARLA_KEY_WINE_AUTO_PREFIX,
  109. CARLA_DEFAULT_WINE_AUTO_PREFIX, bool),
  110. 'fallbackPrefix': settings.value(CARLA_KEY_WINE_FALLBACK_PREFIX,
  111. CARLA_DEFAULT_WINE_FALLBACK_PREFIX, str),
  112. }
  113. del settings
  114. self.fToolNative = os.path.join(pathBinaries, toolNative)
  115. if not os.path.exists(self.fToolNative):
  116. self.fToolNative = ""
  117. self.fCurCount = 0
  118. self.fCurPercentValue = 0
  119. self.fLastCheckValue = 0
  120. self.fSomethingChanged = False
  121. # -----------------------------------------------------------------------------------------------------------------
  122. # public methods
  123. def hasSomethingChanged(self):
  124. return self.fSomethingChanged
  125. def setSearchBinaryTypes(self, native: bool, posix32: bool, posix64: bool, win32: bool, win64: bool):
  126. self.fCheckNative = native
  127. self.fCheckPosix32 = posix32
  128. self.fCheckPosix64 = posix64
  129. self.fCheckWin32 = win32
  130. self.fCheckWin64 = win64
  131. def setSearchPluginTypes(self, ladspa: bool, dssi: bool, lv2: bool, vst2: bool, vst3: bool, au: bool,
  132. sf2: bool, sfz: bool, jsfx: bool):
  133. self.fCheckLADSPA = ladspa
  134. self.fCheckDSSI = dssi
  135. self.fCheckLV2 = lv2
  136. self.fCheckVST2 = vst2
  137. self.fCheckVST3 = vst3 and (LINUX or MACOS or WINDOWS)
  138. self.fCheckAU = au and MACOS
  139. self.fCheckSF2 = sf2
  140. self.fCheckSFZ = sfz
  141. self.fCheckJSFX = jsfx
  142. def stop(self):
  143. self.fContinueChecking = False
  144. # -----------------------------------------------------------------------------------------------------------------
  145. # protected reimplemented methods
  146. def run(self):
  147. settingsDB = QSafeSettings("falkTX", "CarlaPlugins5")
  148. self.fContinueChecking = True
  149. self.fCurCount = 0
  150. if self.fCheckNative and not self.fToolNative:
  151. self.fCheckNative = False
  152. # looking for plugins via external discovery
  153. pluginCount = 0
  154. if self.fCheckLADSPA:
  155. pluginCount += 1
  156. if self.fCheckDSSI:
  157. pluginCount += 1
  158. if self.fCheckVST2:
  159. pluginCount += 1
  160. if self.fCheckVST3:
  161. pluginCount += 1
  162. # Increase count by the number of externally discoverable plugin types
  163. if self.fCheckNative:
  164. self.fCurCount += pluginCount
  165. # Linux, MacOS and Windows are the only VST3 supported OSes
  166. if self.fCheckVST3 and not (LINUX or MACOS or WINDOWS):
  167. self.fCurCount -= 1
  168. if self.fCheckPosix32:
  169. self.fCurCount += pluginCount
  170. if self.fCheckVST3 and not (LINUX or MACOS):
  171. self.fCurCount -= 1
  172. if self.fCheckPosix64:
  173. self.fCurCount += pluginCount
  174. if self.fCheckVST3 and not (LINUX or MACOS):
  175. self.fCurCount -= 1
  176. if self.fCheckWin32:
  177. self.fCurCount += pluginCount
  178. if self.fCheckWin64:
  179. self.fCurCount += pluginCount
  180. if self.fCheckLV2:
  181. if self.fCheckNative:
  182. self.fCurCount += 1
  183. else:
  184. self.fCheckLV2 = False
  185. if self.fCheckAU:
  186. if self.fCheckNative or self.fCheckPosix32:
  187. self.fCurCount += int(self.fCheckNative) + int(self.fCheckPosix32)
  188. else:
  189. self.fCheckAU = False
  190. if self.fCheckSF2:
  191. if self.fCheckNative:
  192. self.fCurCount += 1
  193. else:
  194. self.fCheckSF2 = False
  195. if self.fCheckSFZ:
  196. if self.fCheckNative:
  197. self.fCurCount += 1
  198. else:
  199. self.fCheckSFZ = False
  200. if self.fCheckJSFX:
  201. if self.fCheckNative:
  202. self.fCurCount += 1
  203. else:
  204. self.fCheckJSFX = False
  205. if self.fCurCount == 0:
  206. return
  207. self.fCurPercentValue = 100.0 / self.fCurCount
  208. self.fLastCheckValue = 0.0
  209. del pluginCount
  210. if HAIKU:
  211. OS = "HAIKU"
  212. elif LINUX:
  213. OS = "LINUX"
  214. elif MACOS:
  215. OS = "MACOS"
  216. elif WINDOWS:
  217. OS = "WINDOWS"
  218. else:
  219. OS = "UNKNOWN"
  220. if not self.fContinueChecking:
  221. return
  222. self.fSomethingChanged = True
  223. if self.fCheckLADSPA:
  224. if self.fCheckNative:
  225. plugins = self._checkLADSPA(OS, self.fToolNative)
  226. settingsDB.setValue("Plugins/LADSPA_native", plugins)
  227. if not self.fContinueChecking:
  228. return
  229. if self.fCheckPosix32:
  230. tool = os.path.join(self.fPathBinaries, "carla-discovery-posix32")
  231. plugins = self._checkLADSPA(OS, tool)
  232. settingsDB.setValue("Plugins/LADSPA_posix32", plugins)
  233. if not self.fContinueChecking:
  234. return
  235. if self.fCheckPosix64:
  236. tool = os.path.join(self.fPathBinaries, "carla-discovery-posix64")
  237. plugins = self._checkLADSPA(OS, tool)
  238. settingsDB.setValue("Plugins/LADSPA_posix64", plugins)
  239. if not self.fContinueChecking:
  240. return
  241. if self.fCheckWin32:
  242. tool = os.path.join(self.fPathBinaries, "carla-discovery-win32.exe")
  243. plugins = self._checkLADSPA("WINDOWS", tool, not WINDOWS)
  244. settingsDB.setValue("Plugins/LADSPA_win32", plugins)
  245. if not self.fContinueChecking:
  246. return
  247. if self.fCheckWin64:
  248. tool = os.path.join(self.fPathBinaries, "carla-discovery-win64.exe")
  249. plugins = self._checkLADSPA("WINDOWS", tool, not WINDOWS)
  250. settingsDB.setValue("Plugins/LADSPA_win64", plugins)
  251. settingsDB.sync()
  252. if not self.fContinueChecking:
  253. return
  254. if self.fCheckDSSI:
  255. if self.fCheckNative:
  256. plugins = self._checkDSSI(OS, self.fToolNative)
  257. settingsDB.setValue("Plugins/DSSI_native", plugins)
  258. if not self.fContinueChecking:
  259. return
  260. if self.fCheckPosix32:
  261. plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  262. settingsDB.setValue("Plugins/DSSI_posix32", plugins)
  263. if not self.fContinueChecking:
  264. return
  265. if self.fCheckPosix64:
  266. plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  267. settingsDB.setValue("Plugins/DSSI_posix64", plugins)
  268. if not self.fContinueChecking:
  269. return
  270. if self.fCheckWin32:
  271. tool = os.path.join(self.fPathBinaries, "carla-discovery-win32.exe")
  272. plugins = self._checkDSSI("WINDOWS", tool, not WINDOWS)
  273. settingsDB.setValue("Plugins/DSSI_win32", plugins)
  274. if not self.fContinueChecking:
  275. return
  276. if self.fCheckWin64:
  277. tool = os.path.join(self.fPathBinaries, "carla-discovery-win64.exe")
  278. plugins = self._checkDSSI("WINDOWS", tool, not WINDOWS)
  279. settingsDB.setValue("Plugins/DSSI_win64", plugins)
  280. settingsDB.sync()
  281. if not self.fContinueChecking:
  282. return
  283. if self.fCheckLV2:
  284. plugins = self._checkCached(True)
  285. settingsDB.setValue("Plugins/LV2", plugins)
  286. settingsDB.sync()
  287. if not self.fContinueChecking:
  288. return
  289. if self.fCheckVST2:
  290. if self.fCheckNative:
  291. plugins = self._checkVST2(OS, self.fToolNative)
  292. settingsDB.setValue("Plugins/VST2_native", plugins)
  293. if not self.fContinueChecking:
  294. return
  295. if self.fCheckPosix32:
  296. plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  297. settingsDB.setValue("Plugins/VST2_posix32", plugins)
  298. if not self.fContinueChecking:
  299. return
  300. if self.fCheckPosix64:
  301. plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  302. settingsDB.setValue("Plugins/VST2_posix64", plugins)
  303. if not self.fContinueChecking:
  304. return
  305. if self.fCheckWin32:
  306. tool = os.path.join(self.fPathBinaries, "carla-discovery-win32.exe")
  307. plugins = self._checkVST2("WINDOWS", tool, not WINDOWS)
  308. settingsDB.setValue("Plugins/VST2_win32", plugins)
  309. if not self.fContinueChecking:
  310. return
  311. if self.fCheckWin64:
  312. tool = os.path.join(self.fPathBinaries, "carla-discovery-win64.exe")
  313. plugins = self._checkVST2("WINDOWS", tool, not WINDOWS)
  314. settingsDB.setValue("Plugins/VST2_win64", plugins)
  315. if not self.fContinueChecking:
  316. return
  317. settingsDB.sync()
  318. if not self.fContinueChecking:
  319. return
  320. if self.fCheckVST3:
  321. if self.fCheckNative and (LINUX or MACOS or WINDOWS):
  322. plugins = self._checkVST3(self.fToolNative)
  323. settingsDB.setValue("Plugins/VST3_native", plugins)
  324. if not self.fContinueChecking:
  325. return
  326. if self.fCheckPosix32:
  327. plugins = self._checkVST3(os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  328. settingsDB.setValue("Plugins/VST3_posix32", plugins)
  329. if not self.fContinueChecking:
  330. return
  331. if self.fCheckPosix64:
  332. plugins = self._checkVST3(os.path.join(self.fPathBinaries, "carla-discovery-posix64"))
  333. settingsDB.setValue("Plugins/VST3_posix64", plugins)
  334. if not self.fContinueChecking:
  335. return
  336. if self.fCheckWin32:
  337. tool = os.path.join(self.fPathBinaries, "carla-discovery-win32.exe")
  338. plugins = self._checkVST3(tool, not WINDOWS)
  339. settingsDB.setValue("Plugins/VST3_win32", plugins)
  340. if not self.fContinueChecking:
  341. return
  342. if self.fCheckWin64:
  343. tool = os.path.join(self.fPathBinaries, "carla-discovery-win64.exe")
  344. plugins = self._checkVST3(tool, not WINDOWS)
  345. settingsDB.setValue("Plugins/VST3_win64", plugins)
  346. if not self.fContinueChecking:
  347. return
  348. settingsDB.sync()
  349. if not self.fContinueChecking:
  350. return
  351. if self.fCheckAU:
  352. if self.fCheckNative:
  353. plugins = self._checkCached(False)
  354. settingsDB.setValue("Plugins/AU", plugins)
  355. settingsDB.sync()
  356. if not self.fContinueChecking:
  357. return
  358. if self.fCheckPosix32:
  359. plugins = self._checkAU(os.path.join(self.fPathBinaries, "carla-discovery-posix32"))
  360. settingsDB.setValue("Plugins/AU_posix32", self.fAuPlugins)
  361. if not self.fContinueChecking:
  362. return
  363. settingsDB.sync()
  364. if not self.fContinueChecking:
  365. return
  366. if self.fCheckSF2:
  367. settings = QSafeSettings("falkTX", "Carla2")
  368. SF2_PATH = settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH, list)
  369. del settings
  370. kits = self._checkKIT(SF2_PATH, "sf2")
  371. settingsDB.setValue("Plugins/SF2", kits)
  372. settingsDB.sync()
  373. if not self.fContinueChecking:
  374. return
  375. if self.fCheckSFZ:
  376. kits = self._checkSfzCached()
  377. settingsDB.setValue("Plugins/SFZ", kits)
  378. settingsDB.sync()
  379. if self.fCheckJSFX:
  380. kits = self._checkJsfxCached()
  381. settingsDB.setValue("Plugins/JSFX", kits)
  382. settingsDB.sync()
  383. # -----------------------------------------------------------------------------------------------------------------
  384. # private methods
  385. def _checkLADSPA(self, OS, tool, isWine=False):
  386. ladspaBinaries = []
  387. ladspaPlugins = []
  388. self._pluginLook(self.fLastCheckValue, "LADSPA plugins...")
  389. settings = QSafeSettings("falkTX", "Carla2")
  390. LADSPA_PATH = settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH, list)
  391. del settings
  392. for iPATH in LADSPA_PATH:
  393. binaries = findBinaries(iPATH, PLUGIN_LADSPA, OS)
  394. for binary in binaries:
  395. if binary not in ladspaBinaries:
  396. ladspaBinaries.append(binary)
  397. ladspaBinaries.sort()
  398. if not self.fContinueChecking:
  399. return ladspaPlugins
  400. for i in range(len(ladspaBinaries)):
  401. ladspa = ladspaBinaries[i]
  402. percent = ( float(i) / len(ladspaBinaries) ) * self.fCurPercentValue
  403. self._pluginLook((self.fLastCheckValue + percent) * 0.9, ladspa)
  404. plugins = checkPluginLADSPA(ladspa, tool, self.fWineSettings if isWine else None)
  405. if plugins:
  406. ladspaPlugins.append(plugins)
  407. if not self.fContinueChecking:
  408. break
  409. self.fLastCheckValue += self.fCurPercentValue
  410. return ladspaPlugins
  411. def _checkDSSI(self, OS, tool, isWine=False):
  412. dssiBinaries = []
  413. dssiPlugins = []
  414. self._pluginLook(self.fLastCheckValue, "DSSI plugins...")
  415. settings = QSafeSettings("falkTX", "Carla2")
  416. DSSI_PATH = settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH, list)
  417. del settings
  418. for iPATH in DSSI_PATH:
  419. binaries = findBinaries(iPATH, PLUGIN_DSSI, OS)
  420. for binary in binaries:
  421. if binary not in dssiBinaries:
  422. dssiBinaries.append(binary)
  423. dssiBinaries.sort()
  424. if not self.fContinueChecking:
  425. return dssiPlugins
  426. for i in range(len(dssiBinaries)):
  427. dssi = dssiBinaries[i]
  428. percent = ( float(i) / len(dssiBinaries) ) * self.fCurPercentValue
  429. self._pluginLook(self.fLastCheckValue + percent, dssi)
  430. plugins = checkPluginDSSI(dssi, tool, self.fWineSettings if isWine else None)
  431. if plugins:
  432. dssiPlugins.append(plugins)
  433. if not self.fContinueChecking:
  434. break
  435. self.fLastCheckValue += self.fCurPercentValue
  436. return dssiPlugins
  437. def _checkVST2(self, OS, tool, isWine=False):
  438. vst2Binaries = []
  439. vst2Plugins = []
  440. if MACOS and not isWine:
  441. self._pluginLook(self.fLastCheckValue, "VST2 bundles...")
  442. else:
  443. self._pluginLook(self.fLastCheckValue, "VST2 plugins...")
  444. settings = QSafeSettings("falkTX", "Carla2")
  445. VST2_PATH = settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH, list)
  446. del settings
  447. for iPATH in VST2_PATH:
  448. if MACOS and not isWine:
  449. binaries = findMacVSTBundles(iPATH, False)
  450. else:
  451. binaries = findBinaries(iPATH, PLUGIN_VST2, OS)
  452. for binary in binaries:
  453. if binary not in vst2Binaries:
  454. vst2Binaries.append(binary)
  455. vst2Binaries.sort()
  456. if not self.fContinueChecking:
  457. return vst2Plugins
  458. for i in range(len(vst2Binaries)):
  459. vst2 = vst2Binaries[i]
  460. percent = ( float(i) / len(vst2Binaries) ) * self.fCurPercentValue
  461. self._pluginLook(self.fLastCheckValue + percent, vst2)
  462. plugins = checkPluginVST2(vst2, tool, self.fWineSettings if isWine else None)
  463. if plugins:
  464. vst2Plugins.append(plugins)
  465. if not self.fContinueChecking:
  466. break
  467. self.fLastCheckValue += self.fCurPercentValue
  468. return vst2Plugins
  469. def _checkVST3(self, tool, isWine=False):
  470. vst3Binaries = []
  471. vst3Plugins = []
  472. if MACOS and not isWine:
  473. self._pluginLook(self.fLastCheckValue, "VST3 bundles...")
  474. else:
  475. self._pluginLook(self.fLastCheckValue, "VST3 plugins...")
  476. settings = QSafeSettings("falkTX", "Carla2")
  477. VST3_PATH = settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH, list)
  478. del settings
  479. for iPATH in VST3_PATH:
  480. if MACOS and not isWine:
  481. binaries = findMacVSTBundles(iPATH, True)
  482. else:
  483. binaries = findVST3Binaries(iPATH)
  484. for binary in binaries:
  485. if binary not in vst3Binaries:
  486. vst3Binaries.append(binary)
  487. vst3Binaries.sort()
  488. if not self.fContinueChecking:
  489. return vst3Plugins
  490. for i in range(len(vst3Binaries)):
  491. vst3 = vst3Binaries[i]
  492. percent = ( float(i) / len(vst3Binaries) ) * self.fCurPercentValue
  493. self._pluginLook(self.fLastCheckValue + percent, vst3)
  494. plugins = checkPluginVST3(vst3, tool, self.fWineSettings if isWine else None)
  495. if plugins:
  496. vst3Plugins.append(plugins)
  497. if not self.fContinueChecking:
  498. break
  499. self.fLastCheckValue += self.fCurPercentValue
  500. return vst3Plugins
  501. def _checkAU(self, tool):
  502. auPlugins = []
  503. plugins = checkAllPluginsAU(tool)
  504. if plugins:
  505. auPlugins.append(plugins)
  506. self.fLastCheckValue += self.fCurPercentValue
  507. return auPlugins
  508. def _checkKIT(self, kitPATH, kitExtension):
  509. kitFiles = []
  510. kitPlugins = []
  511. for iPATH in kitPATH:
  512. files = findFilenames(iPATH, kitExtension)
  513. for file_ in files:
  514. if file_ not in kitFiles:
  515. kitFiles.append(file_)
  516. kitFiles.sort()
  517. if not self.fContinueChecking:
  518. return kitPlugins
  519. for i in range(len(kitFiles)):
  520. kit = kitFiles[i]
  521. percent = ( float(i) / len(kitFiles) ) * self.fCurPercentValue
  522. self._pluginLook(self.fLastCheckValue + percent, kit)
  523. if kitExtension == "sf2":
  524. plugins = checkFileSF2(kit, self.fToolNative)
  525. else:
  526. plugins = None
  527. if plugins:
  528. kitPlugins.append(plugins)
  529. if not self.fContinueChecking:
  530. break
  531. self.fLastCheckValue += self.fCurPercentValue
  532. return kitPlugins
  533. def _checkCached(self, isLV2):
  534. if isLV2:
  535. settings = QSafeSettings("falkTX", "Carla2")
  536. PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list))
  537. del settings
  538. PLUG_TEXT = "LV2"
  539. PLUG_TYPE = PLUGIN_LV2
  540. else: # AU
  541. PLUG_PATH = ""
  542. PLUG_TEXT = "AU"
  543. PLUG_TYPE = PLUGIN_AU
  544. plugins = []
  545. self._pluginLook(self.fLastCheckValue, f"{PLUG_TEXT} plugins...")
  546. if not isLV2:
  547. gCarla.utils.juce_init()
  548. count = gCarla.utils.get_cached_plugin_count(PLUG_TYPE, PLUG_PATH)
  549. if not self.fContinueChecking:
  550. return plugins
  551. for i in range(count):
  552. descInfo = gCarla.utils.get_cached_plugin_info(PLUG_TYPE, i)
  553. percent = ( float(i) / count ) * self.fCurPercentValue
  554. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  555. if not descInfo['valid']:
  556. continue
  557. plugins.append(checkPluginCached(descInfo, PLUG_TYPE))
  558. if not self.fContinueChecking:
  559. break
  560. if not isLV2:
  561. gCarla.utils.juce_cleanup()
  562. self.fLastCheckValue += self.fCurPercentValue
  563. return plugins
  564. def _checkSfzCached(self):
  565. settings = QSafeSettings("falkTX", "Carla2")
  566. PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH, list))
  567. del settings
  568. sfzKits = []
  569. self._pluginLook(self.fLastCheckValue, "SFZ kits...")
  570. count = gCarla.utils.get_cached_plugin_count(PLUGIN_SFZ, PLUG_PATH)
  571. if not self.fContinueChecking:
  572. return sfzKits
  573. for i in range(count):
  574. descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_SFZ, i)
  575. percent = ( float(i) / count ) * self.fCurPercentValue
  576. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  577. if not descInfo['valid']:
  578. continue
  579. sfzKits.append(checkPluginCached(descInfo, PLUGIN_SFZ))
  580. if not self.fContinueChecking:
  581. break
  582. self.fLastCheckValue += self.fCurPercentValue
  583. return sfzKits
  584. def _checkJsfxCached(self):
  585. settings = QSafeSettings("falkTX", "Carla2")
  586. PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_JSFX, CARLA_DEFAULT_JSFX_PATH, list))
  587. del settings
  588. jsfxPlugins = []
  589. self._pluginLook(self.fLastCheckValue, "JSFX plugins...")
  590. count = gCarla.utils.get_cached_plugin_count(PLUGIN_JSFX, PLUG_PATH)
  591. if not self.fContinueChecking:
  592. return jsfxPlugins
  593. for i in range(count):
  594. descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_JSFX, i)
  595. percent = ( float(i) / count ) * self.fCurPercentValue
  596. self._pluginLook(self.fLastCheckValue + percent, descInfo['label'])
  597. if not descInfo['valid']:
  598. continue
  599. jsfxPlugins.append(checkPluginCached(descInfo, PLUGIN_JSFX))
  600. if not self.fContinueChecking:
  601. break
  602. self.fLastCheckValue += self.fCurPercentValue
  603. return jsfxPlugins
  604. def _pluginLook(self, percent, plugin):
  605. self.pluginLook.emit(percent, plugin)
  606. # ---------------------------------------------------------------------------------------------------------------------