From 4874d682b0f588ba029e323c69e901c1f1a2bfc0 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 26 Aug 2018 14:24:49 +0200 Subject: [PATCH] Rework parts of plugin list (cleanup and simplify), refresh needed --- source/backend/utils/CachedPlugins.cpp | 17 +- source/backend/utils/PipeClient.cpp | 1 - source/bridges-ui/CarlaBridgeFormat.cpp | 4 - source/carla_database.py | 407 +++++++++++++----------- source/carla_host.py | 6 +- source/discovery/Makefile | 10 +- source/modules/water/water.files.cpp | 6 +- 7 files changed, 237 insertions(+), 214 deletions(-) diff --git a/source/backend/utils/CachedPlugins.cpp b/source/backend/utils/CachedPlugins.cpp index 4dde36518..e326a8c61 100644 --- a/source/backend/utils/CachedPlugins.cpp +++ b/source/backend/utils/CachedPlugins.cpp @@ -21,6 +21,10 @@ #include "CarlaString.hpp" #include "CarlaLv2Utils.hpp" +#ifdef DEBUG +# include "CarlaBackendUtils.hpp" +#endif + #include "water/containers/Array.h" #include "water/files/File.h" @@ -467,10 +471,13 @@ const CarlaCachedPluginInfo* get_cached_plugin_sfz(const File file) { static CarlaCachedPluginInfo info; - static CarlaString name; + static CarlaString name, filename; + name = file.getFileNameWithoutExtension().toRawUTF8(); name.replace('_',' '); + filename = file.getFullPathName().toRawUTF8(); + info.category = CB::PLUGIN_CATEGORY_SYNTH; info.hints = CB::PLUGIN_IS_SYNTH; // CB::PLUGIN_IS_RTSAFE @@ -484,9 +491,9 @@ const CarlaCachedPluginInfo* get_cached_plugin_sfz(const File file) info.parameterOuts = 1; info.name = name.buffer(); - info.label = name.buffer(); - info.maker = ""; - info.copyright = ""; + info.label = filename.buffer(); + info.maker = gNullCharPtr; + info.copyright = gNullCharPtr; return &info; } @@ -495,7 +502,7 @@ const CarlaCachedPluginInfo* get_cached_plugin_sfz(const File file) uint carla_get_cached_plugin_count(CB::PluginType ptype, const char* pluginPath) { CARLA_SAFE_ASSERT_RETURN(isCachedPluginType(ptype), 0); - carla_debug("carla_get_cached_plugin_count(%i:%s)", ptype, CB::PluginType2Str(ptype)); + carla_debug("carla_get_cached_plugin_count(%i:%s, %s)", ptype, CB::PluginType2Str(ptype), pluginPath); switch (ptype) { diff --git a/source/backend/utils/PipeClient.cpp b/source/backend/utils/PipeClient.cpp index 7aa7bfe7a..3bd5a8a79 100644 --- a/source/backend/utils/PipeClient.cpp +++ b/source/backend/utils/PipeClient.cpp @@ -165,6 +165,5 @@ void carla_pipe_client_destroy(CarlaPipeClientHandle handle) // ------------------------------------------------------------------------------------------------------------------- #include "CarlaPipeUtils.cpp" -#include "water/misc/Time.cpp" // ------------------------------------------------------------------------------------------------------------------- diff --git a/source/bridges-ui/CarlaBridgeFormat.cpp b/source/bridges-ui/CarlaBridgeFormat.cpp index 7e7d0ca3e..971d1dd5e 100644 --- a/source/bridges-ui/CarlaBridgeFormat.cpp +++ b/source/bridges-ui/CarlaBridgeFormat.cpp @@ -351,8 +351,4 @@ CARLA_BRIDGE_UI_END_NAMESPACE #include "CarlaPipeUtils.cpp" -#if !(defined(DEBUG) || defined(BUILDING_CARLA_FOR_WINDOWS)) -# include "water/misc/Time.cpp" -#endif - // --------------------------------------------------------------------- diff --git a/source/carla_database.py b/source/carla_database.py index 2cf96e7b7..560addce5 100755 --- a/source/carla_database.py +++ b/source/carla_database.py @@ -28,11 +28,11 @@ from copy import deepcopy from subprocess import Popen, PIPE if config_UseQt5: - from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QThread, QSettings - from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QTableWidgetItem + from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QEventLoop, QThread, QSettings + from PyQt5.QtWidgets import QApplication, QDialog, QDialogButtonBox, QTableWidgetItem else: - from PyQt4.QtCore import pyqtSignal, pyqtSlot, Qt, QThread, QSettings - from PyQt4.QtGui import QDialog, QDialogButtonBox, QTableWidgetItem + from PyQt4.QtCore import pyqtSignal, pyqtSlot, Qt, QEventLoop, QThread, QSettings + from PyQt4.QtGui import QApplication, QDialog, QDialogButtonBox, QTableWidgetItem # ---------------------------------------------------------------------------------------------------------------------- # Imports (Custom) @@ -117,8 +117,6 @@ def findFilenames(filePath, stype): if stype == "sf2": extensions = (".sf2",".sf3",) - elif stype == "sfz": - extensions = (".sfz",) else: return [] @@ -131,10 +129,11 @@ def findFilenames(filePath, stype): # ---------------------------------------------------------------------------------------------------------------------- # Plugin Query -PLUGIN_QUERY_API_VERSION = 7 +PLUGIN_QUERY_API_VERSION = 8 PyPluginInfo = { 'API': PLUGIN_QUERY_API_VERSION, + 'valid': False, 'build': BINARY_NONE, 'type': PLUGIN_NONE, 'hints': 0x0, @@ -316,8 +315,6 @@ def killDiscovery(): gDiscoveryProcess.kill() def checkPluginCached(desc, ptype): - plugins = [] - pinfo = deepcopy(PyPluginInfo) pinfo['build'] = BINARY_NATIVE pinfo['type'] = ptype @@ -335,9 +332,7 @@ def checkPluginCached(desc, ptype): pinfo['parameters.ins'] = desc['parameterIns'] pinfo['parameters.outs'] = desc['parameterOuts'] - plugins.append(pinfo) - - return plugins + return pinfo def checkPluginLADSPA(filename, tool, wineSettings=None): return runCarlaDiscovery(PLUGIN_LADSPA, "LADSPA", filename, tool, wineSettings) @@ -407,13 +402,6 @@ class SearchPluginsThread(QThread): self.fLastCheckValue = 0 self.fSomethingChanged = False - self.fLadspaPlugins = [] - self.fDssiPlugins = [] - self.fLv2Plugins = [] - self.fVst2Plugins = [] - self.fAuPlugins = [] - self.fKitPlugins = [] - # ------------------------------------------------------------- def hasSomethingChanged(self): @@ -466,20 +454,24 @@ class SearchPluginsThread(QThread): if self.fCheckWin64: self.fCurCount += pluginCount - # Special case for LV2, only "search" for native plugins + # Special case for cached plugins, only "search" for native plugins (does not need tool) if self.fCheckLV2: if self.fCheckNative: self.fCurCount += 1 else: self.fCheckLV2 = False + if self.fCheckSFZ: + if self.fCheckNative: + self.fCurCount += 1 + else: + self.fCheckSFZ = False + # Special case for Sound Kits, only search native if self.fCheckNative and self.fToolNative: if self.fCheckSF2: self.fCurCount += 1 - if self.fCheckSFZ: self.fCurCount += 1 else: self.fCheckSF2 = False - self.fCheckSFZ = False if self.fCurCount == 0: return @@ -515,28 +507,28 @@ class SearchPluginsThread(QThread): rdfPadValue = self.fCurPercentValue * checkValue if self.fCheckNative: - self._checkLADSPA(OS, self.fToolNative) - settingsDB.setValue("Plugins/LADSPA_native", self.fLadspaPlugins) + plugins = self._checkLADSPA(OS, self.fToolNative) + settingsDB.setValue("Plugins/LADSPA_native", plugins) if not self.fContinueChecking: return if self.fCheckPosix32: - self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32")) - settingsDB.setValue("Plugins/LADSPA_posix32", self.fLadspaPlugins) + plugins = self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32")) + settingsDB.setValue("Plugins/LADSPA_posix32", plugins) if not self.fContinueChecking: return if self.fCheckPosix64: - self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64")) - settingsDB.setValue("Plugins/LADSPA_posix64", self.fLadspaPlugins) + plugins = self._checkLADSPA(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64")) + settingsDB.setValue("Plugins/LADSPA_posix64", plugins) if not self.fContinueChecking: return if self.fCheckWin32: - self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS) - settingsDB.setValue("Plugins/LADSPA_win32", self.fLadspaPlugins) + plugins = self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS) + settingsDB.setValue("Plugins/LADSPA_win32", plugins) if not self.fContinueChecking: return if self.fCheckWin64: - self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS) - settingsDB.setValue("Plugins/LADSPA_win64", self.fLadspaPlugins) + plugins = self._checkLADSPA("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS) + settingsDB.setValue("Plugins/LADSPA_win64", plugins) settingsDB.sync() if not self.fContinueChecking: return @@ -560,62 +552,63 @@ class SearchPluginsThread(QThread): if self.fCheckDSSI: if self.fCheckNative: - self._checkDSSI(OS, self.fToolNative) - settingsDB.setValue("Plugins/DSSI_native", self.fDssiPlugins) + plugins = self._checkDSSI(OS, self.fToolNative) + settingsDB.setValue("Plugins/DSSI_native", plugins) if not self.fContinueChecking: return if self.fCheckPosix32: - self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32")) - settingsDB.setValue("Plugins/DSSI_posix32", self.fDssiPlugins) + plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32")) + settingsDB.setValue("Plugins/DSSI_posix32", plugins) if not self.fContinueChecking: return if self.fCheckPosix64: - self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64")) - settingsDB.setValue("Plugins/DSSI_posix64", self.fDssiPlugins) + plugins = self._checkDSSI(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64")) + settingsDB.setValue("Plugins/DSSI_posix64", plugins) if not self.fContinueChecking: return if self.fCheckWin32: - self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS) - settingsDB.setValue("Plugins/DSSI_win32", self.fDssiPlugins) + plugins = self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS) + settingsDB.setValue("Plugins/DSSI_win32", plugins) if not self.fContinueChecking: return if self.fCheckWin64: - self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS) - settingsDB.setValue("Plugins/DSSI_win64", self.fDssiPlugins) + plugins = self._checkDSSI("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS) + settingsDB.setValue("Plugins/DSSI_win64", plugins) settingsDB.sync() if not self.fContinueChecking: return if self.fCheckLV2: - self._checkLv2Cached() - settingsDB.setValue("Plugins/LV2", self.fLv2Plugins) - + plugins = self._checkLv2Cached() + settingsDB.setValue("Plugins/LV2", plugins) + settingsDB.sync() if not self.fContinueChecking: return if self.fCheckVST2: if self.fCheckNative: - self._checkVST2(OS, self.fToolNative) - settingsDB.setValue("Plugins/VST2_native", self.fVstPlugins) + plugins = self._checkVST2(OS, self.fToolNative) + settingsDB.setValue("Plugins/VST2_native", plugins) if not self.fContinueChecking: return if self.fCheckPosix32: - self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32")) - settingsDB.setValue("Plugins/VST2_posix32", self.fVstPlugins) + plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix32")) + settingsDB.setValue("Plugins/VST2_posix32", plugins) if not self.fContinueChecking: return if self.fCheckPosix64: - self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64")) - settingsDB.setValue("Plugins/VST2_posix64", self.fVstPlugins) + plugins = self._checkVST2(OS, os.path.join(self.fPathBinaries, "carla-discovery-posix64")) + settingsDB.setValue("Plugins/VST2_posix64", plugins) if not self.fContinueChecking: return if self.fCheckWin32: - self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS) - settingsDB.setValue("Plugins/VST2_win32", self.fVstPlugins) + plugins = self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win32.exe"), not WINDOWS) + settingsDB.setValue("Plugins/VST2_win32", plugins) if not self.fContinueChecking: return if self.fCheckWin64: - self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS) - settingsDB.setValue("Plugins/VST2_win64", self.fVstPlugins) + plugins = self._checkVST2("WINDOWS", os.path.join(self.fPathBinaries, "carla-discovery-win64.exe"), not WINDOWS) + settingsDB.setValue("Plugins/VST2_win64", plugins) + if not self.fContinueChecking: return settingsDB.sync() if not self.fContinueChecking: return @@ -625,23 +618,19 @@ class SearchPluginsThread(QThread): SF2_PATH = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH)) del settings - self._checkKIT(SF2_PATH, "sf2") - settingsDB.setValue("Plugins/SF2", self.fKitPlugins) + kits = self._checkKIT(SF2_PATH, "sf2") + settingsDB.setValue("Plugins/SF2", kits) + settingsDB.sync() if not self.fContinueChecking: return if self.fCheckSFZ: - settings = QSettings("falkTX", "Carla2") - SFZ_PATH = toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH)) - del settings - - self._checkKIT(SFZ_PATH, "sfz") - settingsDB.setValue("Plugins/SFZ", self.fKitPlugins) - - settingsDB.sync() + kits = self._checkSfzCached() + settingsDB.setValue("Plugins/SFZ", kits) + settingsDB.sync() def _checkLADSPA(self, OS, tool, isWine=False): ladspaBinaries = [] - self.fLadspaPlugins = [] + ladspaPlugins = [] self._pluginLook(self.fLastCheckValue, "LADSPA plugins...") @@ -657,7 +646,8 @@ class SearchPluginsThread(QThread): ladspaBinaries.sort() - if not self.fContinueChecking: return + if not self.fContinueChecking: + return ladspaPlugins for i in range(len(ladspaBinaries)): ladspa = ladspaBinaries[i] @@ -666,15 +656,17 @@ class SearchPluginsThread(QThread): plugins = checkPluginLADSPA(ladspa, tool, self.fWineSettings if isWine else None) if plugins: - self.fLadspaPlugins.append(plugins) + ladspaPlugins.append(plugins) - if not self.fContinueChecking: break + if not self.fContinueChecking: + break self.fLastCheckValue += self.fCurPercentValue + return ladspaPlugins def _checkDSSI(self, OS, tool, isWine=False): dssiBinaries = [] - self.fDssiPlugins = [] + dssiPlugins = [] self._pluginLook(self.fLastCheckValue, "DSSI plugins...") @@ -690,7 +682,8 @@ class SearchPluginsThread(QThread): dssiBinaries.sort() - if not self.fContinueChecking: return + if not self.fContinueChecking: + return dssiPlugins for i in range(len(dssiBinaries)): dssi = dssiBinaries[i] @@ -699,15 +692,17 @@ class SearchPluginsThread(QThread): plugins = checkPluginDSSI(dssi, tool, self.fWineSettings if isWine else None) if plugins: - self.fDssiPlugins.append(plugins) + dssiPlugins.append(plugins) - if not self.fContinueChecking: break + if not self.fContinueChecking: + break self.fLastCheckValue += self.fCurPercentValue + return dssiPlugins def _checkVST2(self, OS, tool, isWine=False): vst2Binaries = [] - self.fVstPlugins = [] + vstPlugins = [] if MACOS and not isWine: self._pluginLook(self.fLastCheckValue, "VST2 bundles...") @@ -729,7 +724,8 @@ class SearchPluginsThread(QThread): vst2Binaries.sort() - if not self.fContinueChecking: return + if not self.fContinueChecking: + return vstPlugins for i in range(len(vst2Binaries)): vst2 = vst2Binaries[i] @@ -738,15 +734,17 @@ class SearchPluginsThread(QThread): plugins = checkPluginVST2(vst2, tool, self.fWineSettings if isWine else None) if plugins: - self.fVstPlugins.append(plugins) + vstPlugins.append(plugins) - if not self.fContinueChecking: break + if not self.fContinueChecking: + break self.fLastCheckValue += self.fCurPercentValue + return vstPlugins def _checkKIT(self, kitPATH, kitExtension): kitFiles = [] - self.fKitPlugins = [] + kitPlugins = [] for iPATH in kitPATH: files = findFilenames(iPATH, kitExtension) @@ -756,7 +754,8 @@ class SearchPluginsThread(QThread): kitFiles.sort() - if not self.fContinueChecking: return + if not self.fContinueChecking: + return kitPlugins for i in range(len(kitFiles)): kit = kitFiles[i] @@ -765,31 +764,30 @@ class SearchPluginsThread(QThread): if kitExtension == "sf2": plugins = checkFileSF2(kit, self.fToolNative) - elif kitExtension == "sfz": - plugins = checkFileSFZ(kit, self.fToolNative) else: plugins = None if plugins: - self.fKitPlugins.append(plugins) + kitPlugins.append(plugins) - if not self.fContinueChecking: break + if not self.fContinueChecking: + break self.fLastCheckValue += self.fCurPercentValue + return kitPlugins def _checkLv2Cached(self): settings = QSettings("falkTX", "Carla2") PLUG_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH))) del settings - self.fLv2Plugins = [] - PLUG_LIST = self.fLv2Plugins - + lv2Plugins = [] self._pluginLook(self.fLastCheckValue, "LV2 plugins...") count = gCarla.utils.get_cached_plugin_count(PLUGIN_LV2, PLUG_PATH) - if not self.fContinueChecking: return + if not self.fContinueChecking: + return lv2Plugins for i in range(count): descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_LV2, i) @@ -797,14 +795,46 @@ class SearchPluginsThread(QThread): percent = ( float(i) / count ) * self.fCurPercentValue self._pluginLook(self.fLastCheckValue + percent, descInfo['label']) - plugins = checkPluginCached(descInfo, PLUGIN_LV2) + if not descInfo['valid']: + continue + + lv2Plugins.append(checkPluginCached(descInfo, PLUGIN_LV2)) - if plugins: - PLUG_LIST.append(plugins) + if not self.fContinueChecking: + break + + self.fLastCheckValue += self.fCurPercentValue + return lv2Plugins + + def _checkSfzCached(self): + settings = QSettings("falkTX", "Carla2") + PLUG_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH))) + del settings + + sfzKits = [] + self._pluginLook(self.fLastCheckValue, "SFZ kits...") + + count = gCarla.utils.get_cached_plugin_count(PLUGIN_SFZ, PLUG_PATH) + + if not self.fContinueChecking: + return sfzKits + + for i in range(count): + descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_SFZ, i) + + percent = ( float(i) / count ) * self.fCurPercentValue + self._pluginLook(self.fLastCheckValue + percent, descInfo['label']) + + if not descInfo['valid']: + continue - if not self.fContinueChecking: break + sfzKits.append(checkPluginCached(descInfo, PLUGIN_SFZ)) + + if not self.fContinueChecking: + break self.fLastCheckValue += self.fCurPercentValue + return sfzKits def _pluginLook(self, percent, plugin): self.pluginLook.emit(percent, plugin) @@ -1388,9 +1418,7 @@ class PluginDatabaseW(QDialog): rowCount = self.ui.tableWidget.rowCount() - for i in range(rowCount): - self.ui.tableWidget.showRow(i) - + for i in range(self.fLastTableIndex): plugin = self.ui.tableWidget.item(i, 0).data(Qt.UserRole) aIns = plugin['audio.ins'] aOuts = plugin['audio.outs'] @@ -1449,6 +1477,8 @@ class PluginDatabaseW(QDialog): text in self.ui.tableWidget.item(i, 3).text().lower() or text in self.ui.tableWidget.item(i, 13).text().lower())): self.ui.tableWidget.hideRow(i) + else: + self.ui.tableWidget.showRow(i) # -------------------------------------------------------------------------------------------------------- @@ -1492,7 +1522,6 @@ class PluginDatabaseW(QDialog): bridgeText = self.tr("Yes (%s)" % typeText) - self.ui.tableWidget.insertRow(index) self.ui.tableWidget.setItem(index, 0, QTableWidgetItem(str(plugin['name']))) self.ui.tableWidget.setItem(index, 1, QTableWidgetItem(str(plugin['label']))) self.ui.tableWidget.setItem(index, 2, QTableWidgetItem(str(plugin['maker']))) @@ -1512,89 +1541,80 @@ class PluginDatabaseW(QDialog): # -------------------------------------------------------------------------------------------------------- - def _reAddPlugins(self): - settingsDB = QSettings("falkTX", "CarlaPlugins3") - - for x in range(self.ui.tableWidget.rowCount()): - self.ui.tableWidget.removeRow(0) - - self.fLastTableIndex = 0 - self.ui.tableWidget.setSortingEnabled(False) - - internalCount = 0 - ladspaCount = 0 - dssiCount = 0 - lv2Count = 0 - vstCount = 0 - kitCount = 0 + def _reAddInternalHelper(self, settingsDB, ptype, path): + if ptype == PLUGIN_INTERNAL: + ptypeStr = "Internal" + ptypeStrTr = self.tr("Internal") + elif ptype == PLUGIN_LV2: + ptypeStr = "LV2" + ptypeStrTr = ptypeStr + elif ptype == PLUGIN_SFZ: + ptypeStr = "SFZ" + ptypeStrTr = ptypeStr + else: + return 0 - settings = QSettings("falkTX", "Carla2") - LV2_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH))) - del settings + #qApp = QApplication.instance() - # ---------------------------------------------------------------------------------------------------- - # Cached plugins (Internal) + plugins = toList(settingsDB.value("Plugins/" + ptypeStr, [])) + pluginCount = settingsDB.value("PluginCount/" + ptypeStr, 0, type=int) - internalPlugins = toList(settingsDB.value("Plugins/Internal", [])) + pluginCountNew = gCarla.utils.get_cached_plugin_count(ptype, path) - for plugins in internalPlugins: - internalCount += len(plugins) + if pluginCountNew != pluginCount or (len(plugins) > 0 and plugins[0]['API'] != PLUGIN_QUERY_API_VERSION): + plugins = [] + pluginCount = pluginCountNew - internalCountNew = gCarla.utils.get_cached_plugin_count(PLUGIN_INTERNAL, "") + QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50) - if internalCountNew != internalCount or (len(internalPlugins) > 0 and - len(internalPlugins[0]) > 0 and - internalPlugins[0][0]['API'] != PLUGIN_QUERY_API_VERSION): - internalCount = internalCountNew - internalPlugins = [] + for i in range(pluginCountNew): + descInfo = gCarla.utils.get_cached_plugin_info(ptype, i) - for i in range(internalCountNew): - descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_INTERNAL, i) - plugins = checkPluginCached(descInfo, PLUGIN_INTERNAL) + if not descInfo['valid']: + continue - if plugins: - internalPlugins.append(plugins) + info = checkPluginCached(descInfo, ptype) - settingsDB.setValue("Plugins/Internal", internalPlugins) + if ptype == PLUGIN_SFZ: + info['filename'] = info['label'] + info['label'] = info['name'] - for plugins in internalPlugins: - for plugin in plugins: - self._addPluginToTable(plugin, self.tr("Internal")) + plugins.append(info) - del internalCountNew - del internalPlugins + if i % 50 == 0: + QApplication.processEvents(QEventLoop.ExcludeUserInputEvents, 50) - # ---------------------------------------------------------------------------------------------------- - # Cached plugins (LV2) + settingsDB.setValue("Plugins/" + ptypeStr, plugins) + settingsDB.setValue("PluginCount/" + ptypeStr, pluginCount) - lv2Plugins = toList(settingsDB.value("Plugins/LV2", [])) + # prepare rows in advance + self.ui.tableWidget.setRowCount(self.fLastTableIndex + len(plugins)) - for plugins in lv2Plugins: - lv2Count += len(plugins) + for plugin in plugins: + self._addPluginToTable(plugin, ptypeStrTr) - lv2CountNew = gCarla.utils.get_cached_plugin_count(PLUGIN_LV2, LV2_PATH) + return pluginCount - if lv2CountNew != lv2Count or (len(lv2Plugins) > 0 and - len(lv2Plugins[0]) > 0 and - lv2Plugins[0][0]['API'] != PLUGIN_QUERY_API_VERSION): - lv2Count = lv2CountNew - lv2Plugins = [] + def _reAddPlugins(self): + settingsDB = QSettings("falkTX", "CarlaPlugins4") - for i in range(lv2CountNew): - descInfo = gCarla.utils.get_cached_plugin_info(PLUGIN_LV2, i) - plugins = checkPluginCached(descInfo, PLUGIN_LV2) + for x in range(self.ui.tableWidget.rowCount()): + self.ui.tableWidget.removeRow(0) - if plugins: - lv2Plugins.append(plugins) + self.fLastTableIndex = 0 + self.ui.tableWidget.setSortingEnabled(False) - settingsDB.setValue("Plugins/LV2", lv2Plugins) + settings = QSettings("falkTX", "Carla2") + LV2_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH))) + SFZ_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH))) + del settings - for plugins in lv2Plugins: - for plugin in plugins: - self._addPluginToTable(plugin, "LV2") + # ---------------------------------------------------------------------------------------------------- + # plugins handled through backend - del lv2CountNew - del lv2Plugins + internalCount = self._reAddInternalHelper(settingsDB, PLUGIN_INTERNAL, "") + lv2Count = self._reAddInternalHelper(settingsDB, PLUGIN_LV2, LV2_PATH) + sfzCount = self._reAddInternalHelper(settingsDB, PLUGIN_SFZ, SFZ_PATH) # ---------------------------------------------------------------------------------------------------- # LADSPA @@ -1606,13 +1626,6 @@ class PluginDatabaseW(QDialog): ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win32", [])) ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win64", [])) - for plugins in ladspaPlugins: - for plugin in plugins: - self._addPluginToTable(plugin, "LADSPA") - ladspaCount += 1 - - del ladspaPlugins - # ---------------------------------------------------------------------------------------------------- # DSSI @@ -1623,13 +1636,6 @@ class PluginDatabaseW(QDialog): dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win32", [])) dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win64", [])) - for plugins in dssiPlugins: - for plugin in plugins: - self._addPluginToTable(plugin, "DSSI") - dssiCount += 1 - - del dssiPlugins - # ---------------------------------------------------------------------------------------------------- # VST2 @@ -1640,43 +1646,58 @@ class PluginDatabaseW(QDialog): vst2Plugins += toList(settingsDB.value("Plugins/VST2_win32", [])) vst2Plugins += toList(settingsDB.value("Plugins/VST2_win64", [])) - for plugins in vst2Plugins: - for plugin in plugins: - self._addPluginToTable(plugin, "VST2") - vstCount += 1 - - del vst2Plugins - # ---------------------------------------------------------------------------------------------------- # Kits sf2s = toList(settingsDB.value("Plugins/SF2", [])) - for sf2 in sf2s: - for sf2_i in sf2: - self._addPluginToTable(sf2_i, "SF2") - kitCount += 1 + # ---------------------------------------------------------------------------------------------------- + # count plugins first, so we can create rows in advance + + ladspaCount = 0 + dssiCount = 0 + vstCount = 0 + sf2Count = 0 - del sf2s + for plugins in ladspaPlugins: + ladspaCount += len(plugins) - # ---------------------------------------------------------------------------------------------------- + for plugins in dssiPlugins: + dssiCount += len(plugins) + + for plugins in vst2Plugins: + vstCount += len(plugins) - sfzs = toList(settingsDB.value("Plugins/SFZ", [])) + for plugins in sf2s: + sf2Count += len(plugins) - for sfz in sfzs: - for sfz_i in sfz: - self._addPluginToTable(sfz_i, "SFZ") - kitCount += 1 + self.ui.tableWidget.setRowCount(self.fLastTableIndex+ladspaCount+dssiCount+vstCount+sf2Count) - del sfzs + self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2 and %i VST plugins, plus %i Sound Kits" % ( + internalCount, ladspaCount, dssiCount, lv2Count, vstCount, sf2Count+sfzCount))) # ---------------------------------------------------------------------------------------------------- + # now add all plugins to the table - self.ui.tableWidget.setSortingEnabled(True) + for plugins in ladspaPlugins: + for plugin in plugins: + self._addPluginToTable(plugin, "LADSPA") - self.ui.label.setText(self.tr("Have %i Internal, %i LADSPA, %i DSSI, %i LV2 and %i VST plugins, plus %i Sound Kits" % ( - internalCount, ladspaCount, dssiCount, lv2Count, vstCount, kitCount))) + for plugins in dssiPlugins: + for plugin in plugins: + self._addPluginToTable(plugin, "DSSI") + + for plugins in vst2Plugins: + for plugin in plugins: + self._addPluginToTable(plugin, "VST2") + for sf2 in sf2s: + for sf2_i in sf2: + self._addPluginToTable(sf2_i, "SF2") + + # ---------------------------------------------------------------------------------------------------- + + self.ui.tableWidget.setSortingEnabled(True) self._checkFilters() # -------------------------------------------------------------------------------------------------------- diff --git a/source/carla_host.py b/source/carla_host.py index 60f45baa5..5aa0fd19a 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -27,11 +27,11 @@ from carla_config import * import json if config_UseQt5: - from PyQt5.QtCore import qCritical, QFileInfo, QModelIndex, QPointF, QTimer + from PyQt5.QtCore import qCritical, QEventLoop, QFileInfo, QModelIndex, QPointF, QTimer from PyQt5.QtGui import QImage, QPalette from PyQt5.QtWidgets import QAction, QApplication, QInputDialog, QFileSystemModel, QListWidgetItem, QMainWindow else: - from PyQt4.QtCore import qCritical, QFileInfo, QModelIndex, QPointF, QTimer + from PyQt4.QtCore import qCritical, QEventLoop, QFileInfo, QModelIndex, QPointF, QTimer from PyQt4.QtGui import QImage, QPalette from PyQt4.QtGui import QAction, QApplication, QInputDialog, QFileSystemModel, QListWidgetItem, QMainWindow @@ -2525,7 +2525,7 @@ def engineCallback(host, action, pluginId, value1, value2, value3, valueStr): elif action == ENGINE_CALLBACK_NSM: host.NSMCallback.emit(value1, value2, valueStr) elif action == ENGINE_CALLBACK_IDLE: - QApplication.instance().processEvents() + QApplication.processEvents(QEventLoop.ExcludeUserInputEvents) elif action == ENGINE_CALLBACK_INFO: host.InfoCallback.emit(valueStr) elif action == ENGINE_CALLBACK_ERROR: diff --git a/source/discovery/Makefile b/source/discovery/Makefile index ac180680c..d218a03c5 100644 --- a/source/discovery/Makefile +++ b/source/discovery/Makefile @@ -61,11 +61,11 @@ LIBS_win32 = $(MODULEDIR)/lilv.win32.a LIBS_win64 = $(MODULEDIR)/lilv.win64.a LINK_FLAGS += $(LILV_LIBS) -LIBS_native += $(MODULEDIR)/water.a -LIBS_posix32 += $(MODULEDIR)/water.posix32.a -LIBS_posix64 += $(MODULEDIR)/water.posix64.a -LIBS_win32 += $(MODULEDIR)/water.win32.a -LIBS_win64 += $(MODULEDIR)/water.win64.a +LIBS_native += $(MODULEDIR)/water.files.a +LIBS_posix32 += $(MODULEDIR)/water.files.posix32.a +LIBS_posix64 += $(MODULEDIR)/water.files.posix64.a +LIBS_win32 += $(MODULEDIR)/water.files.win32.a +LIBS_win64 += $(MODULEDIR)/water.files.win64.a LINK_FLAGS += $(WATER_LIBS) LINK_FLAGS += $(LIBDL_LIBS) diff --git a/source/modules/water/water.files.cpp b/source/modules/water/water.files.cpp index a79518b03..a8a17e53d 100644 --- a/source/modules/water/water.files.cpp +++ b/source/modules/water/water.files.cpp @@ -1,7 +1,7 @@ /* * Cross-platform C++ library for Carla, based on Juce v4 * Copyright (C) 2015 ROLI Ltd. - * Copyright (C) 2017 Filipe Coelho + * Copyright (C) 2017-2018 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -36,20 +36,20 @@ HINSTANCE water_getCurrentModuleInstanceHandle() noexcept } +#include "files/DirectoryIterator.cpp" #include "files/File.cpp" #include "misc/Result.cpp" +#include "misc/Time.cpp" #include "text/CharacterFunctions.cpp" #include "text/StringArray.cpp" #include "text/String.cpp" #if defined(DEBUG) || defined(BUILDING_CARLA_FOR_WINDOWS) -# include "files/DirectoryIterator.cpp" # include "files/FileInputStream.cpp" # include "files/FileOutputStream.cpp" # include "files/TemporaryFile.cpp" # include "maths/Random.cpp" # include "memory/MemoryBlock.cpp" -# include "misc/Time.cpp" # include "streams/InputStream.cpp" # include "streams/MemoryOutputStream.cpp" # include "streams/OutputStream.cpp"