| @@ -70,6 +70,12 @@ static const uint MAX_PATCHBAY_PLUGINS = 255; | |||
| */ | |||
| static const uint MAX_DEFAULT_PARAMETERS = 200; | |||
| /*! | |||
| * The "plugin Id" for the global Carla instance. | |||
| * Curently only used for audio peaks. | |||
| */ | |||
| static const uint MAIN_CARLA_PLUGIN_ID = 0xFFFF; | |||
| /* ------------------------------------------------------------------------------------------------------------ | |||
| * Engine Driver Device Hints */ | |||
| @@ -1197,6 +1197,14 @@ const EngineTimeInfo& CarlaEngine::getTimeInfo() const noexcept | |||
| float CarlaEngine::getInputPeak(const uint pluginId, const bool isLeft) const noexcept | |||
| { | |||
| if (pluginId == MAIN_CARLA_PLUGIN_ID) | |||
| { | |||
| // get peak from first plugin, if available | |||
| if (pData->curPluginCount > 0) | |||
| return pData->plugins[0].insPeak[isLeft ? 0 : 1]; | |||
| return 0.0f; | |||
| } | |||
| CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount, 0.0f); | |||
| return pData->plugins[pluginId].insPeak[isLeft ? 0 : 1]; | |||
| @@ -1204,6 +1212,14 @@ float CarlaEngine::getInputPeak(const uint pluginId, const bool isLeft) const no | |||
| float CarlaEngine::getOutputPeak(const uint pluginId, const bool isLeft) const noexcept | |||
| { | |||
| if (pluginId == MAIN_CARLA_PLUGIN_ID) | |||
| { | |||
| // get peak from last plugin, if available | |||
| if (pData->curPluginCount > 0) | |||
| return pData->plugins[pData->curPluginCount-1].outsPeak[isLeft ? 0 : 1]; | |||
| return 0.0f; | |||
| } | |||
| CARLA_SAFE_ASSERT_RETURN(pluginId < pData->curPluginCount, 0.0f); | |||
| return pData->plugins[pluginId].outsPeak[isLeft ? 0 : 1]; | |||
| @@ -318,7 +318,7 @@ void ExternalGraph::refresh(const char* const deviceName) | |||
| // Main | |||
| { | |||
| kEngine->callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, kExternalGraphGroupCarla, PATCHBAY_ICON_CARLA, -1, 0.0f, kEngine->getName()); | |||
| kEngine->callback(ENGINE_CALLBACK_PATCHBAY_CLIENT_ADDED, kExternalGraphGroupCarla, PATCHBAY_ICON_CARLA, MAIN_CARLA_PLUGIN_ID, 0.0f, kEngine->getName()); | |||
| if (isRack) | |||
| { | |||
| @@ -154,6 +154,10 @@ MAX_PATCHBAY_PLUGINS = 255 | |||
| # @see ENGINE_OPTION_MAX_PARAMETERS | |||
| MAX_DEFAULT_PARAMETERS = 200 | |||
| # The "plugin Id" for the global Carla instance. | |||
| # Curently only used for audio peaks. | |||
| MAIN_CARLA_PLUGIN_ID = 0xFFFF | |||
| # ------------------------------------------------------------------------------------------------------------ | |||
| # Engine Driver Device Hints | |||
| # Various engine driver device hints. | |||
| @@ -1330,11 +1330,16 @@ class HostWindow(QMainWindow): | |||
| if pluginId < 0: | |||
| return | |||
| if pluginId >= self.fPluginCount: | |||
| if pluginId >= self.fPluginCount and pluginId != MAIN_CARLA_PLUGIN_ID: | |||
| print("sorry, can't map this plugin to canvas client", pluginId, self.fPluginCount) | |||
| return | |||
| patchcanvas.setGroupAsPlugin(clientId, pluginId, bool(self.host.get_plugin_info(pluginId)['hints'] & PLUGIN_HAS_CUSTOM_UI)) | |||
| if pluginId == MAIN_CARLA_PLUGIN_ID: | |||
| hasCustomUI = False | |||
| else: | |||
| hasCustomUI = bool(self.host.get_plugin_info(pluginId)['hints'] & PLUGIN_HAS_CUSTOM_UI) | |||
| patchcanvas.setGroupAsPlugin(clientId, pluginId, hasCustomUI) | |||
| @pyqtSlot(int) | |||
| def slot_handlePatchbayClientRemovedCallback(self, clientId): | |||
| @@ -1366,11 +1371,16 @@ class HostWindow(QMainWindow): | |||
| if pluginId < 0: | |||
| return | |||
| if pluginId >= self.fPluginCount: | |||
| if pluginId >= self.fPluginCount and pluginId != MAIN_CARLA_PLUGIN_ID: | |||
| print("sorry, can't map this plugin to canvas client", pluginId, self.fPluginCount) | |||
| return | |||
| patchcanvas.setGroupAsPlugin(clientId, pluginId, bool(self.host.get_plugin_info(pluginId)['hints'] & PLUGIN_HAS_CUSTOM_UI)) | |||
| if pluginId == MAIN_CARLA_PLUGIN_ID: | |||
| hasCustomUI = False | |||
| else: | |||
| hasCustomUI = bool(self.host.get_plugin_info(pluginId)['hints'] & PLUGIN_HAS_CUSTOM_UI) | |||
| patchcanvas.setGroupAsPlugin(clientId, pluginId, hasCustomUI) | |||
| @pyqtSlot(int, int, int, str) | |||
| def slot_handlePatchbayPortAddedCallback(self, clientId, portId, portFlags, portName): | |||
| @@ -49,6 +49,9 @@ from patchcanvas_theme import * | |||
| # ------------------------------------------------------------------------------ | |||
| # patchcanvas-api.h | |||
| # Maximum Id for a plugin, treated as invalid/zero if above this value | |||
| MAX_PLUGIN_ID_ALLOWED = 0x7FF | |||
| # Port Mode | |||
| PORT_MODE_NULL = 0 | |||
| PORT_MODE_INPUT = 1 | |||
| @@ -1055,7 +1058,7 @@ def handlePluginRemoved(plugin_id): | |||
| print("PatchCanvas::handlePluginRemoved(%i)" % plugin_id) | |||
| for group in canvas.group_list: | |||
| if group.plugin_id < plugin_id: | |||
| if group.plugin_id < plugin_id or group.plugin_id > MAX_PLUGIN_ID_ALLOWED: | |||
| continue | |||
| group.plugin_id -= 1 | |||
| @@ -1069,6 +1072,9 @@ def handleAllPluginsRemoved(): | |||
| print("PatchCanvas::handleAllPluginsRemoved()") | |||
| for group in canvas.group_list: | |||
| if group.plugin_id > MAX_PLUGIN_ID_ALLOWED: | |||
| continue | |||
| group.plugin_id = -1 | |||
| group.plugin_ui = False | |||
| group.widgets[0].m_plugin_id = -1 | |||
| @@ -1306,7 +1312,10 @@ class PatchScene(QGraphicsScene): | |||
| #break | |||
| if group_item is not None and group_item.m_plugin_id >= 0: | |||
| plugin_list.append(group_item.m_plugin_id) | |||
| plugin_id = group_item.m_plugin_id | |||
| if plugin_id > MAX_PLUGIN_ID_ALLOWED: | |||
| plugin_id = 0 | |||
| plugin_list.append(plugin_id) | |||
| self.pluginSelected.emit(plugin_list) | |||
| @@ -2599,7 +2608,7 @@ class CanvasBox(QGraphicsItem): | |||
| if not (features.group_info and features.group_rename): | |||
| act_x_sep1.setVisible(False) | |||
| if self.m_plugin_id >= 0: | |||
| if self.m_plugin_id >= 0 and self.m_plugin_id <= MAX_PLUGIN_ID_ALLOWED: | |||
| menu.addSeparator() | |||
| act_p_edit = menu.addAction("Edit") | |||
| act_p_ui = menu.addAction("Show Custom UI") | |||