From ca212fa084f57ef73f760ed998c1df8d3d7ca0e6 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 2 May 2023 00:22:22 +0200 Subject: [PATCH] Adjustments as needed for Carla as OBS plugin Signed-off-by: falkTX --- source/backend/engine/CarlaEngineNative.cpp | 73 ++++++++++++++++++++- source/includes/CarlaNative.h | 21 +++--- source/includes/CarlaNative.hpp | 3 +- source/includes/CarlaNativePlugin.h | 7 +- 4 files changed, 91 insertions(+), 13 deletions(-) diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 0f476eb13..491a319a4 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2022 Filipe Coelho + * Copyright (C) 2011-2023 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 @@ -1593,6 +1593,11 @@ public: return new CarlaEngineNative(host, true, true, 64, 64, 32, 32); } + static NativePluginHandle _instantiatePatchbayOBS(const NativeHostDescriptor* host) + { + return new CarlaEngineNative(host, true, true, 8, 8); + } + static void _cleanup(NativePluginHandle handle) { delete handlePtr; @@ -1697,6 +1702,9 @@ public: case NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED: handlePtr->fUsesEmbed = true; return 0; + case NATIVE_PLUGIN_OPCODE_HOST_OPTION: + handlePtr->setOption(static_cast(index), value, static_cast(ptr)); + return 0; } return 0; @@ -2928,10 +2936,65 @@ static const NativePluginDescriptor carlaPatchbayCV32Desc = { /* ui_height */ kUiHeight }; +static const NativePluginDescriptor carlaPatchbayOBS = { + /* category */ NATIVE_PLUGIN_CATEGORY_OTHER, + /* hints */ static_cast(NATIVE_PLUGIN_IS_SYNTH + |NATIVE_PLUGIN_HAS_UI + |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD + |NATIVE_PLUGIN_USES_STATE + |NATIVE_PLUGIN_USES_TIME + |NATIVE_PLUGIN_USES_UI_SIZE), + /* supports */ static_cast(NATIVE_PLUGIN_SUPPORTS_EVERYTHING), + /* audioIns */ 8, + /* audioOuts */ 8, + /* midiIns */ 0, + /* midiOuts */ 0, + /* paramIns */ kNumInParams, + /* paramOuts */ kNumOutParams, + /* name */ "Carla-Patchbay (OBS)", + /* label */ "carlapatchbayOBS", + /* maker */ "falkTX", + /* copyright */ "GNU GPL v2+", + CarlaEngineNative::_instantiatePatchbayOBS, + CarlaEngineNative::_cleanup, + CarlaEngineNative::_get_parameter_count, + CarlaEngineNative::_get_parameter_info, + CarlaEngineNative::_get_parameter_value, + /* _get_midi_program_count */ nullptr, + /* _get_midi_program_info */ nullptr, + CarlaEngineNative::_set_parameter_value, + /* _set_midi_program */ nullptr, + /* _set_custom_data */ nullptr, +#ifndef CARLA_ENGINE_WITHOUT_UI + CarlaEngineNative::_ui_show, +#else + nullptr, +#endif + CarlaEngineNative::_ui_idle, + CarlaEngineNative::_ui_set_parameter_value, + /* _ui_set_midi_program */ nullptr, + /* _ui_set_custom_data */ nullptr, + CarlaEngineNative::_activate, + CarlaEngineNative::_deactivate, + CarlaEngineNative::_process, + CarlaEngineNative::_get_state, + CarlaEngineNative::_set_state, + CarlaEngineNative::_dispatcher, + /* _render_inline_dsplay */ nullptr, + /* cvIns */ 0, + /* cvOuts */ 0, + /* _get_buffer_port_name */ nullptr, + /* _get_buffer_port_range */ nullptr, + /* ui_width */ kUiWidth, + /* ui_height */ kUiHeight +}; + CARLA_BACKEND_END_NAMESPACE // ----------------------------------------------------------------------- +#ifndef STATIC_PLUGIN_TARGET + CARLA_API_EXPORT void carla_register_native_plugin_carla(); @@ -2948,6 +3011,8 @@ void carla_register_native_plugin_carla() carla_register_native_plugin(&carlaPatchbayCVDesc); } +#endif + // ----------------------------------------------------------------------- const NativePluginDescriptor* carla_get_native_rack_plugin() @@ -2998,6 +3063,12 @@ const NativePluginDescriptor* carla_get_native_patchbay_cv32_plugin() return &carlaPatchbayCV32Desc; } +const NativePluginDescriptor* carla_get_native_patchbay_obs_plugin() +{ + CARLA_BACKEND_USE_NAMESPACE; + return &carlaPatchbayOBS; +} + // ----------------------------------------------------------------------- // Extra stuff for linking purposes diff --git a/source/includes/CarlaNative.h b/source/includes/CarlaNative.h index 9ecb70444..d66f01173 100644 --- a/source/includes/CarlaNative.h +++ b/source/includes/CarlaNative.h @@ -1,6 +1,6 @@ /* * Carla Native Plugin API - * Copyright (C) 2012-2019 Filipe Coelho + * Copyright (C) 2012-2023 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 @@ -100,15 +100,16 @@ typedef enum { } NativeParameterHints; typedef enum { - NATIVE_PLUGIN_OPCODE_NULL = 0, /** nothing */ - NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED = 1, /** uses value */ - NATIVE_PLUGIN_OPCODE_SAMPLE_RATE_CHANGED = 2, /** uses opt */ - NATIVE_PLUGIN_OPCODE_OFFLINE_CHANGED = 3, /** uses value (0=off, 1=on) */ - NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED = 4, /** uses ptr */ - NATIVE_PLUGIN_OPCODE_GET_INTERNAL_HANDLE = 5, /** nothing */ - NATIVE_PLUGIN_OPCODE_IDLE = 6, /** nothing */ - NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT = 7, /** uses ptr */ - NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED = 8 /** nothing */ + NATIVE_PLUGIN_OPCODE_NULL = 0, /** nothing */ + NATIVE_PLUGIN_OPCODE_BUFFER_SIZE_CHANGED = 1, /** uses value */ + NATIVE_PLUGIN_OPCODE_SAMPLE_RATE_CHANGED = 2, /** uses opt */ + NATIVE_PLUGIN_OPCODE_OFFLINE_CHANGED = 3, /** uses value (0=off, 1=on) */ + NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED = 4, /** uses ptr */ + NATIVE_PLUGIN_OPCODE_GET_INTERNAL_HANDLE = 5, /** nothing */ + NATIVE_PLUGIN_OPCODE_IDLE = 6, /** nothing */ + NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT = 7, /** uses ptr */ + NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED = 8, /** nothing */ + NATIVE_PLUGIN_OPCODE_HOST_OPTION = 9 /** uses index, value and ptr */ } NativePluginDispatcherOpcode; typedef enum { diff --git a/source/includes/CarlaNative.hpp b/source/includes/CarlaNative.hpp index f21183a25..6adc2dbce 100644 --- a/source/includes/CarlaNative.hpp +++ b/source/includes/CarlaNative.hpp @@ -1,6 +1,6 @@ /* * Carla Native Plugin API (C++) - * Copyright (C) 2012-2019 Filipe Coelho + * Copyright (C) 2012-2023 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 @@ -567,6 +567,7 @@ public: return handlePtr->uiMIDIEvent(static_cast(index), static_cast(ptr)); case NATIVE_PLUGIN_OPCODE_HOST_USES_EMBED: + case NATIVE_PLUGIN_OPCODE_HOST_OPTION: return 0; } diff --git a/source/includes/CarlaNativePlugin.h b/source/includes/CarlaNativePlugin.h index 2271879c7..807083322 100644 --- a/source/includes/CarlaNativePlugin.h +++ b/source/includes/CarlaNativePlugin.h @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2022 Filipe Coelho + * Copyright (C) 2011-2023 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 @@ -69,6 +69,11 @@ CARLA_API_EXPORT const NativePluginDescriptor* carla_get_native_patchbay_cv8_plu */ CARLA_API_EXPORT const NativePluginDescriptor* carla_get_native_patchbay_cv32_plugin(void); +/*! + * Get the native plugin descriptor for the carla-patchbay OBS plugin. + */ +CARLA_API_EXPORT const NativePluginDescriptor* carla_get_native_patchbay_obs_plugin(void); + /*! * Create a CarlaHostHandle suitable for CarlaHost API calls. * Returned value must be freed by the caller when no longer needed.