From 04fdc4c20983c54d3bdaf6355814d29ad827c761 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 9 Apr 2021 16:45:28 +0100 Subject: [PATCH] Standalone: Add a dummy output channel to MIDI effect plug-ins --- .../Standalone/juce_StandaloneFilterWindow.h | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index 7ef90c643b..4ee4c3e55b 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -128,13 +128,7 @@ public: processor->disableNonMainBuses(); processor->setRateAndBufferSizeDetails (44100, 512); - int inChannels = (channelConfiguration.size() > 0 ? channelConfiguration[0].numIns - : processor->getMainBusNumInputChannels()); - - int outChannels = (channelConfiguration.size() > 0 ? channelConfiguration[0].numOuts - : processor->getMainBusNumOutputChannels()); - - processorHasPotentialFeedbackLoop = (inChannels > 0 && outChannels > 0); + processorHasPotentialFeedbackLoop = (getNumInputChannels() > 0 && getNumOutputChannels() > 0); } virtual void deletePlugin() @@ -143,6 +137,24 @@ public: processor = nullptr; } + int getNumInputChannels() const + { + if (processor == nullptr) + return 0; + + return (channelConfiguration.size() > 0 ? channelConfiguration[0].numIns + : processor->getMainBusNumInputChannels()); + } + + int getNumOutputChannels() const + { + if (processor == nullptr) + return 0; + + return (channelConfiguration.size() > 0 ? channelConfiguration[0].numOuts + : processor->getMainBusNumOutputChannels()); + } + static String getFilePatterns (const String& fileSuffix) { if (fileSuffix.isEmpty()) @@ -305,18 +317,17 @@ public: #endif } - auto totalInChannels = processor->getMainBusNumInputChannels(); - auto totalOutChannels = processor->getMainBusNumOutputChannels(); + auto inputChannels = getNumInputChannels(); + auto outputChannels = getNumOutputChannels(); - if (channelConfiguration.size() > 0) + if (inputChannels == 0 && outputChannels == 0 && processor->isMidiEffect()) { - auto defaultConfig = channelConfiguration.getReference (0); - totalInChannels = defaultConfig.numIns; - totalOutChannels = defaultConfig.numOuts; + // add a dummy output channel for MIDI effect plug-ins so they can receive audio callbacks + outputChannels = 1; } - deviceManager.initialise (enableAudioInput ? totalInChannels : 0, - totalOutChannels, + deviceManager.initialise (enableAudioInput ? inputChannels : 0, + outputChannels, savedState.get(), true, preferredDefaultDeviceName,