From dda135a9ebacab34445503d89b6c4cc5180f2935 Mon Sep 17 00:00:00 2001 From: hogliux Date: Wed, 1 Feb 2017 15:54:49 +0000 Subject: [PATCH] Updated the JUCE demo plugin to support standalone targets on all platforms --- .../audio plugin demo/JuceDemoPlugin.jucer | 49 ++++++++++++++++++- .../Source/PluginProcessor.cpp | 46 +++++++++++------ .../Source/PluginProcessor.h | 1 + .../Standalone/juce_StandaloneFilterWindow.h | 8 +++ 4 files changed, 87 insertions(+), 17 deletions(-) diff --git a/examples/audio plugin demo/JuceDemoPlugin.jucer b/examples/audio plugin demo/JuceDemoPlugin.jucer index d285784e91..1bdb9a46d5 100644 --- a/examples/audio plugin demo/JuceDemoPlugin.jucer +++ b/examples/audio plugin demo/JuceDemoPlugin.jucer @@ -11,9 +11,9 @@ bundleIdentifier="com.juce.JuceDemoPlugin" jucerVersion="4.3.1" companyName="ROLI Ltd." aaxIdentifier="com.yourcompany.JuceDemoPlugin" buildAAX="0" pluginAAXCategory="AAX_ePlugInCategory_Dynamics" - includeBinaryInAppConfig="1" buildVST3="1" pluginManufacturerEmail="support@yourcompany.com" + includeBinaryInAppConfig="1" buildVST3="0" pluginManufacturerEmail="support@yourcompany.com" companyWebsite="www.juce.com" companyEmail="info@juce.com" pluginIsMidiEffectPlugin="0" - buildAUv3="0"> + buildAUv3="1" buildStandalone="1"> @@ -83,6 +83,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2) return false; + if (mainOutput.size() > 2) return false; return true; } +AudioProcessor::BusesProperties JuceDemoPluginAudioProcessor::getBusesProperties() +{ + // This plug-in should not have any inputs when run as a standalone plug-in + + if (PluginHostType::getPluginLoadedAs() == wrapperType_Standalone) + return BusesProperties().withOutput ("Output", AudioChannelSet::stereo(), true); + else + return BusesProperties().withInput ("Input", AudioChannelSet::stereo(), true) + .withOutput ("Output", AudioChannelSet::stereo(), true); +} + +//============================================================================== void JuceDemoPluginAudioProcessor::prepareToPlay (double newSampleRate, int /*samplesPerBlock*/) { // Use this method as the place to do any pre-playback @@ -244,8 +255,8 @@ void JuceDemoPluginAudioProcessor::process (AudioBuffer& buffer, { const int numSamples = buffer.getNumSamples(); - // apply our gain-change to the incoming data.. - applyGain (buffer, delayBuffer); + if (wrapperType == wrapperType_Standalone) + buffer.clear(); // Now pass any incoming midi messages to our keyboard state object, and let it // add messages to the buffer if the user is clicking on the on-screen keys @@ -257,11 +268,16 @@ void JuceDemoPluginAudioProcessor::process (AudioBuffer& buffer, // Apply our delay effect to the new output.. applyDelay (buffer, delayBuffer); - // In case we have more outputs than inputs, we'll clear any output - // channels that didn't contain input data, (because these aren't - // guaranteed to be empty - they may contain garbage). - for (int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i) - buffer.clear (i, 0, numSamples); + if (wrapperType != wrapperType_Standalone) + { + // In case we have more outputs than inputs, we'll clear any output + // channels that didn't contain input data, (because these aren't + // guaranteed to be empty - they may contain garbage). + for (int i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i) + buffer.clear (i, 0, numSamples); + } + + applyGain (buffer, delayBuffer); // apply our gain-change to the outgoing data.. // Now ask the host for the current time so we can store it to be displayed later... updateCurrentTimeInfoFromHost(); @@ -273,7 +289,7 @@ void JuceDemoPluginAudioProcessor::applyGain (AudioBuffer& buffer, Au ignoreUnused (delayBuffer); const float gainLevel = *gainParam; - for (int channel = 0; channel < getTotalNumInputChannels(); ++channel) + for (int channel = 0; channel < getTotalNumOutputChannels(); ++channel) buffer.applyGain (channel, 0, buffer.getNumSamples(), gainLevel); } @@ -285,7 +301,7 @@ void JuceDemoPluginAudioProcessor::applyDelay (AudioBuffer& buffer, A int delayPos = 0; - for (int channel = 0; channel < getTotalNumInputChannels(); ++channel) + for (int channel = 0; channel < getTotalNumOutputChannels(); ++channel) { FloatType* const channelData = buffer.getWritePointer (channel); FloatType* const delayData = delayBuffer.getWritePointer (jmin (channel, delayBuffer.getNumChannels() - 1)); diff --git a/examples/audio plugin demo/Source/PluginProcessor.h b/examples/audio plugin demo/Source/PluginProcessor.h index 8d2656b097..eea25f9bf2 100644 --- a/examples/audio plugin demo/Source/PluginProcessor.h +++ b/examples/audio plugin demo/Source/PluginProcessor.h @@ -106,6 +106,7 @@ private: void initialiseSynth(); void updateCurrentTimeInfoFromHost(); + static BusesProperties getBusesProperties(); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JuceDemoPluginAudioProcessor) }; diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index e69dbb66ff..d1a3c4594f 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -368,6 +368,11 @@ public: createEditorComp(); + #if JUCE_IOS || JUCE_ANDROID + setFullScreen (true); + Desktop::getInstance().setKioskModeComponent (this, false); + #else + if (PropertySet* props = pluginHolder->settings) { const int x = props->getIntValue ("windowX", -100); @@ -382,15 +387,18 @@ public: { centreWithSize (getWidth(), getHeight()); } + #endif } ~StandaloneFilterWindow() { + #if (! JUCE_IOS) && (! JUCE_ANDROID) if (PropertySet* props = pluginHolder->settings) { props->setValue ("windowX", getX()); props->setValue ("windowY", getY()); } + #endif pluginHolder->stopPlaying(); deleteEditorComp();