From 10c0894141af70f13fcf9ddcfc79395b7a08aaab Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 10 Oct 2012 10:50:34 +0100 Subject: [PATCH] Added AudioProcessor::wrapperType flags --- .../AAX/juce_AAX_Wrapper.cpp | 3 + .../AU/juce_AU_Wrapper.mm | 2 + .../RTAS/juce_RTAS_Wrapper.cpp | 4 +- .../Standalone/juce_StandaloneFilterWindow.h | 2 + .../VST/juce_VST_Wrapper.cpp | 63 ++++++++----------- .../format_types/juce_VSTPluginFormat.cpp | 2 + .../processors/juce_AudioProcessor.cpp | 5 +- .../processors/juce_AudioProcessor.h | 16 +++++ 8 files changed, 57 insertions(+), 40 deletions(-) diff --git a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp index b24005b54d..e8b9e102b5 100644 --- a/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/AAX/juce_AAX_Wrapper.cpp @@ -378,6 +378,9 @@ struct AAXClasses JuceAAX_Parameters() { pluginInstance = createPluginFilter(); + + if (pluginInstance != nullptr) + pluginInstance->wrapperType = AudioProcessor::wrapperType_AAX; } static AAX_CEffectParameters* AAX_CALLBACK Create() { return new JuceAAX_Parameters(); } diff --git a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm index 69cf1ce5c6..2849b67262 100644 --- a/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm +++ b/modules/juce_audio_plugin_client/AU/juce_AU_Wrapper.mm @@ -143,6 +143,8 @@ public: juceFilter = createPluginFilter(); jassert (juceFilter != nullptr); + juceFilter->wrapperType = AudioProcessor::wrapperType_AudioUnit; + juceFilter->setPlayHead (this); juceFilter->addListener (this); diff --git a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp index 9b21723721..82be5fc15b 100644 --- a/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/RTAS/juce_RTAS_Wrapper.cpp @@ -156,7 +156,9 @@ public: { asyncUpdater = new InternalAsyncUpdater (*this); juceFilter = createPluginFilter(); - jassert (juceFilter != 0); + jassert (juceFilter != nullptr); + + juceFilter->wrapperType = AudioProcessor::wrapperType_RTAS; AddChunk (juceChunkType, "Juce Audio Plugin Data"); diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index 4d287e2dfa..3006f82398 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -77,6 +77,8 @@ public: JUCEApplication::quit(); } + filter->wrapperType = AudioProcessor::wrapperType_Standalone; + filter->setPlayConfigDetails (JucePlugin_MaxNumInputChannels, JucePlugin_MaxNumOutputChannels, 44100, 512); diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index 1a8456b92c..7afd979305 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -173,11 +173,10 @@ namespace { const MOUSEHOOKSTRUCTEX& hs = *(MOUSEHOOKSTRUCTEX*) lParam; - Component* const comp = Desktop::getInstance().findComponentAt (Point (hs.pt.x, - hs.pt.y)); - if (comp != nullptr && comp->getWindowHandle() != 0) - return PostMessage ((HWND) comp->getWindowHandle(), WM_MOUSEWHEEL, - hs.mouseData & 0xffff0000, (hs.pt.x & 0xffff) | (hs.pt.y << 16)); + if (Component* const comp = Desktop::getInstance().findComponentAt (Point (hs.pt.x, hs.pt.y))) + if (comp->getWindowHandle() != 0) + return PostMessage ((HWND) comp->getWindowHandle(), WM_MOUSEWHEEL, + hs.mouseData & 0xffff0000, (hs.pt.x & 0xffff) | (hs.pt.y << 16)); } return CallNextHookEx (mouseWheelHook, nCode, wParam, lParam); @@ -562,12 +561,8 @@ public: // copy back any temp channels that may have been used.. for (i = 0; i < numOut; ++i) - { - const float* const chan = tempChannels.getUnchecked(i); - - if (chan != nullptr) + if (const float* const chan = tempChannels.getUnchecked(i)) memcpy (outputs[i], chan, sizeof (float) * numSamples); - } } } @@ -673,7 +668,7 @@ public: bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info) { const VstTimeInfo* const ti = getTimeInfo (kVstPpqPosValid | kVstTempoValid | kVstBarsValid | kVstCyclePosValid - | kVstTimeSigValid | kVstSmpteValid | kVstClockValid); + | kVstTimeSigValid | kVstSmpteValid | kVstClockValid); if (ti == nullptr || ti->sampleRate <= 0) return false; @@ -840,9 +835,8 @@ public: return filter != nullptr && filter->isParameterAutomatable ((int) index); } - class ChannelConfigComparator + struct ChannelConfigComparator { - public: static int compareElements (const short* const first, const short* const second) noexcept { if (first[0] < second[0]) return -1; @@ -953,18 +947,18 @@ public: VstInt32 setChunk (void* data, VstInt32 byteSize, bool onlyRestoreCurrentProgramData) { - if (filter == nullptr) - return 0; - - chunkMemory.setSize (0); - chunkMemoryTime = 0; - - if (byteSize > 0 && data != nullptr) + if (filter != nullptr) { - if (onlyRestoreCurrentProgramData) - filter->setCurrentProgramStateInformation (data, byteSize); - else - filter->setStateInformation (data, byteSize); + chunkMemory.setSize (0); + chunkMemoryTime = 0; + + if (byteSize > 0 && data != nullptr) + { + if (onlyRestoreCurrentProgramData) + filter->setCurrentProgramStateInformation (data, byteSize); + else + filter->setStateInformation (data, byteSize); + } } return 0; @@ -1036,9 +1030,7 @@ public: if (editorComp == nullptr) { - AudioProcessorEditor* const ed = filter->createEditorIfNeeded(); - - if (ed != nullptr) + if (AudioProcessorEditor* const ed = filter->createEditorIfNeeded()) { cEffect.flags |= effFlagsHasEditor; ed->setOpaque (true); @@ -1065,8 +1057,7 @@ public: if (editorComp != nullptr) { - Component* const modalComponent = Component::getCurrentlyModalComponent(); - if (modalComponent != nullptr) + if (Component* const modalComponent = Component::getCurrentlyModalComponent()) { modalComponent->exitModalState (0); @@ -1236,8 +1227,8 @@ public: #endif } - if (editorComp->getPeer() != nullptr) - editorComp->getPeer()->handleMovedOrResized(); + if (ComponentPeer* peer = editorComp->getPeer()) + peer->handleMovedOrResized(); } } @@ -1309,9 +1300,7 @@ public: void resized() { - Component* const editor = getChildComponent(0); - - if (editor != nullptr) + if (Component* const editor = getChildComponent(0)) editor->setBounds (getLocalBounds()); } @@ -1463,10 +1452,10 @@ namespace MessageManagerLock mmLock; #endif - AudioProcessor* const filter = createPluginFilter(); - - if (filter != nullptr) + if (AudioProcessor* const filter = createPluginFilter()) { + filter->wrapperType = AudioProcessor::wrapperType_VST; + JuceVSTWrapper* const wrapper = new JuceVSTWrapper (audioMaster, filter); return wrapper->getAeffect(); } diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index dd359a0707..d444076e3b 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -2973,6 +2973,8 @@ const XmlElement* VSTPluginFormat::getVSTXML (AudioPluginInstance* plugin) { if (VSTPluginInstance* const vst = dynamic_cast (plugin)) return vst->getVSTXML(); + + return nullptr; } #endif diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp index f5930f5988..1d1ed9a2da 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.cpp @@ -24,7 +24,8 @@ */ AudioProcessor::AudioProcessor() - : playHead (nullptr), + : wrapperType (wrapperType_Undefined), + playHead (nullptr), sampleRate (0), blockSize (0), numInputChannels (0), @@ -315,4 +316,4 @@ void AudioPlayHead::CurrentPositionInfo::resetToDefault() timeSigNumerator = 4; timeSigDenominator = 4; bpm = 120; -} +} \ No newline at end of file diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessor.h b/modules/juce_audio_processors/processors/juce_AudioProcessor.h index cc4b4b4e55..26ede7d66e 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessor.h @@ -562,6 +562,22 @@ public: /** Not for public use - this is called to initialise the processor before playing. */ void setSpeakerArrangement (const String& inputs, const String& outputs); + /** Flags to indicate the type of plugin context in which a processor is being used. */ + enum WrapperType + { + wrapperType_Undefined = 0, + wrapperType_VST, + wrapperType_AudioUnit, + wrapperType_RTAS, + wrapperType_AAX, + wrapperType_Standalone + }; + + /** When loaded by a plugin wrapper, this flag will be set to indicate the type + of plugin within which the processor is running. + */ + WrapperType wrapperType; + protected: //============================================================================== /** Helper function that just converts an xml element into a binary blob.