From 707926d27af6bb3e7209c0eac0f4cdcfe4973955 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 4 Jun 2023 04:07:04 +0200 Subject: [PATCH] Allow to skip MIDI ports in patchbay plugin, in use for OBS Signed-off-by: falkTX --- source/backend/engine/CarlaEngineGraph.cpp | 10 +++++-- source/backend/engine/CarlaEngineGraph.hpp | 3 +- source/backend/engine/CarlaEngineInternal.hpp | 4 ++- source/backend/engine/CarlaEngineNative.cpp | 30 +++++++++++-------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/source/backend/engine/CarlaEngineGraph.cpp b/source/backend/engine/CarlaEngineGraph.cpp index d92154d4a..dd83f08fc 100644 --- a/source/backend/engine/CarlaEngineGraph.cpp +++ b/source/backend/engine/CarlaEngineGraph.cpp @@ -1749,7 +1749,8 @@ private: PatchbayGraph::PatchbayGraph(CarlaEngine* const engine, const uint32_t audioIns, const uint32_t audioOuts, - const uint32_t cvIns, const uint32_t cvOuts) + const uint32_t cvIns, const uint32_t cvOuts, + const bool withMidiIn, const bool withMidiOut) : CarlaRunner("PatchbayReorderRunner"), connections(), graph(), @@ -1858,6 +1859,7 @@ PatchbayGraph::PatchbayGraph(CarlaEngine* const engine, node->properties.isOSC = false; } + if (withMidiIn) { NamedAudioGraphIOProcessor* const proc( new NamedAudioGraphIOProcessor(NamedAudioGraphIOProcessor::midiInputNode)); @@ -1870,6 +1872,7 @@ PatchbayGraph::PatchbayGraph(CarlaEngine* const engine, node->properties.isOSC = false; } + if (withMidiOut) { NamedAudioGraphIOProcessor* const proc( new NamedAudioGraphIOProcessor(NamedAudioGraphIOProcessor::midiOutputNode)); @@ -2663,7 +2666,8 @@ EngineInternalGraph::~EngineInternalGraph() noexcept } void EngineInternalGraph::create(const uint32_t audioIns, const uint32_t audioOuts, - const uint32_t cvIns, const uint32_t cvOuts) + const uint32_t cvIns, const uint32_t cvOuts, + const bool withMidiIn, const bool withMidiOut) { fIsRack = (kEngine->getOptions().processMode == ENGINE_PROCESS_MODE_CONTINUOUS_RACK); @@ -2675,7 +2679,7 @@ void EngineInternalGraph::create(const uint32_t audioIns, const uint32_t audioOu else { CARLA_SAFE_ASSERT_RETURN(fPatchbay == nullptr,); - fPatchbay = new PatchbayGraph(kEngine, audioIns, audioOuts, cvIns, cvOuts); + fPatchbay = new PatchbayGraph(kEngine, audioIns, audioOuts, cvIns, cvOuts, withMidiIn, withMidiOut); } fNumAudioOuts = audioOuts; diff --git a/source/backend/engine/CarlaEngineGraph.hpp b/source/backend/engine/CarlaEngineGraph.hpp index f287c85d1..6ad01e62b 100644 --- a/source/backend/engine/CarlaEngineGraph.hpp +++ b/source/backend/engine/CarlaEngineGraph.hpp @@ -184,7 +184,8 @@ public: PatchbayGraph(CarlaEngine* engine, uint32_t audioIns, uint32_t audioOuts, - uint32_t cvIns, uint32_t cvOuts); + uint32_t cvIns, uint32_t cvOuts, + bool withMidiIn, bool withMidiOut); ~PatchbayGraph(); void setBufferSize(uint32_t bufferSize); diff --git a/source/backend/engine/CarlaEngineInternal.hpp b/source/backend/engine/CarlaEngineInternal.hpp index 69568db06..1db6854c5 100644 --- a/source/backend/engine/CarlaEngineInternal.hpp +++ b/source/backend/engine/CarlaEngineInternal.hpp @@ -80,7 +80,9 @@ public: EngineInternalGraph(CarlaEngine* engine) noexcept; ~EngineInternalGraph() noexcept; - void create(uint32_t audioIns, uint32_t audioOuts, uint32_t cvIns, uint32_t cvOuts); + void create(uint32_t audioIns, uint32_t audioOuts, + uint32_t cvIns, uint32_t cvOuts, + bool withMidiIn = true, bool withMidiOut = true); void destroy() noexcept; void setBufferSize(uint32_t bufferSize); diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index 491a319a4..fe1a278ea 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -101,7 +101,8 @@ private: class CarlaEngineNative : public CarlaEngine { public: - CarlaEngineNative(const NativeHostDescriptor* const host, const bool isPatchbay, const bool withMidiOut, + CarlaEngineNative(const NativeHostDescriptor* const host, const bool isPatchbay, + const bool withMidiIn, const bool withMidiOut, const uint32_t inChan = 2, uint32_t outChan = 2, const uint32_t cvIns = 0, const uint32_t cvOuts = 0) : CarlaEngine(), @@ -114,6 +115,7 @@ public: fJuceMsgMutex(), #endif kIsPatchbay(isPatchbay), + kHasMidiIn(withMidiIn), kHasMidiOut(withMidiOut), fIsActive(false), fIsRunning(false), @@ -158,7 +160,7 @@ public: pData->options.preferPluginBridges = false; pData->options.preferUiBridges = false; init("Carla-Patchbay"); - pData->graph.create(inChan, outChan, cvIns, cvOuts); + pData->graph.create(inChan, outChan, cvIns, cvOuts, withMidiIn, withMidiOut); } else { @@ -1154,6 +1156,7 @@ protected: // --------------------------------------------------------------- // events input (before processing) + if (kHasMidiIn) { uint32_t engineEventIndex = 0; @@ -1545,57 +1548,57 @@ public: static NativePluginHandle _instantiateRack(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, false, true); + return new CarlaEngineNative(host, false, true, true); } static NativePluginHandle _instantiateRackNoMidiOut(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, false, false); + return new CarlaEngineNative(host, false, true, false); } static NativePluginHandle _instantiatePatchbay(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, true, true); + return new CarlaEngineNative(host, true, true, true); } static NativePluginHandle _instantiatePatchbay3s(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, true, true, 3, 2); + return new CarlaEngineNative(host, true, true, true, 3, 2); } static NativePluginHandle _instantiatePatchbay16(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, true, true, 16, 16); + return new CarlaEngineNative(host, true, true, true, 16, 16); } static NativePluginHandle _instantiatePatchbay32(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, true, true, 32, 32); + return new CarlaEngineNative(host, true, true, true, 32, 32); } static NativePluginHandle _instantiatePatchbay64(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, true, true, 64, 64); + return new CarlaEngineNative(host, true, true, true, 64, 64); } static NativePluginHandle _instantiatePatchbayCV(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, true, true, 2, 2, 5, 5); + return new CarlaEngineNative(host, true, true, true, 2, 2, 5, 5); } static NativePluginHandle _instantiatePatchbayCV8(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, true, true, 2, 2, 8, 8); + return new CarlaEngineNative(host, true, true, true, 2, 2, 8, 8); } static NativePluginHandle _instantiatePatchbayCV32(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, true, true, 64, 64, 32, 32); + return new CarlaEngineNative(host, true, true, true, 64, 64, 32, 32); } static NativePluginHandle _instantiatePatchbayOBS(const NativeHostDescriptor* host) { - return new CarlaEngineNative(host, true, true, 8, 8); + return new CarlaEngineNative(host, true, false, false, 8, 8); } static void _cleanup(NativePluginHandle handle) @@ -1752,6 +1755,7 @@ private: #endif const bool kIsPatchbay; // rack if false + const bool kHasMidiIn; const bool kHasMidiOut; bool fIsActive, fIsRunning, fUsesEmbed; #ifndef CARLA_ENGINE_WITHOUT_UI