diff --git a/extras/AudioPluginHost/CMakeLists.txt b/extras/AudioPluginHost/CMakeLists.txt index 7fc47b550c..dd17e1151c 100644 --- a/extras/AudioPluginHost/CMakeLists.txt +++ b/extras/AudioPluginHost/CMakeLists.txt @@ -42,14 +42,15 @@ target_compile_definitions(AudioPluginHost PRIVATE JUCE_ALSA=1 JUCE_DIRECTSOUND=1 JUCE_PLUGINHOST_LADSPA=1 - JUCE_PLUGINHOST_VST=0 JUCE_PLUGINHOST_VST3=1 + JUCE_PLUGINHOST_VST=0 JUCE_USE_CAMERA=0 JUCE_USE_CDBURNER=0 JUCE_USE_CDREADER=0 JUCE_USE_CURL=0 JUCE_USE_FLAC=0 JUCE_USE_OGGVORBIS=1 + JUCE_VST3_HOST_CROSS_PLATFORM_UID=1 JUCE_WASAPI=1 JUCE_WEB_BROWSER=0) diff --git a/extras/Build/CMake/JUCEUtils.cmake b/extras/Build/CMake/JUCEUtils.cmake index 3b1f566a27..043b31636d 100644 --- a/extras/Build/CMake/JUCEUtils.cmake +++ b/extras/Build/CMake/JUCEUtils.cmake @@ -2257,7 +2257,9 @@ function(juce_add_pip header) target_compile_definitions(${JUCE_PIP_NAME} PRIVATE ${pip_moduleflags} - PUBLIC JUCE_VST3_CAN_REPLACE_VST2=0) + PUBLIC + JUCE_VST3_CAN_REPLACE_VST2=0 + JUCE_VST3_HOST_CROSS_PLATFORM_UID=1) _juce_get_pip_targets(${JUCE_PIP_NAME} pip_targets) diff --git a/extras/Projucer/Source/Application/StartPage/jucer_NewProjectWizard.cpp b/extras/Projucer/Source/Application/StartPage/jucer_NewProjectWizard.cpp index e611966779..b886637c3b 100644 --- a/extras/Projucer/Source/Application/StartPage/jucer_NewProjectWizard.cpp +++ b/extras/Projucer/Source/Application/StartPage/jucer_NewProjectWizard.cpp @@ -63,6 +63,7 @@ static void doBasicProjectSetup (Project& project, const NewProjectTemplates::Pr project.getMainGroup().addNewSubGroup ("Source", 0); project.getConfigFlag ("JUCE_STRICT_REFCOUNTEDPOINTER") = true; + project.getConfigFlag ("JUCE_VST3_HOST_CROSS_PLATFORM_UID") = true; project.getProjectValue (Ids::useAppConfig) = false; project.getProjectValue (Ids::addUsingNamespaceToJuceHeader) = false; diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index fc48ceb13e..603e415330 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -81,10 +81,17 @@ static int warnOnFailureIfImplemented (int result) noexcept //============================================================================== static int getHashForTUID (const TUID& tuid) noexcept { + #if JUCE_VST3_HOST_CROSS_PLATFORM_UID + const FUID fuid { tuid }; + const uint32 inputArray[] { fuid.getLong1(), fuid.getLong2(), fuid.getLong3(), fuid.getLong4() }; + #else + const auto& inputArray = tuid; + #endif + uint32 value = 0; - for (int i = 0; i < numElementsInArray (tuid); ++i) - value = (value * 31) + (uint32) tuid[i]; + for (const auto& item : inputArray) + value = (value * 31) + (uint32) item; return (int) value; } diff --git a/modules/juce_audio_processors/juce_audio_processors.h b/modules/juce_audio_processors/juce_audio_processors.h index e543a92fdb..6137be89b4 100644 --- a/modules/juce_audio_processors/juce_audio_processors.h +++ b/modules/juce_audio_processors/juce_audio_processors.h @@ -102,6 +102,15 @@ #define JUCE_CUSTOM_VST3_SDK 0 #endif +/** Config: JUCE_VST3_HOST_CROSS_PLATFORM_UID + If enabled, ensures that PluginDescription::uid will produce consistent values for VST3 plugins on all platforms. + It is recommended to enable this flag in all new projects. + Projects which predate this flag should leave it disabled, in case they need to interact with uid values which they previously stored. +*/ +#ifndef JUCE_VST3_HOST_CROSS_PLATFORM_UID + #define JUCE_VST3_HOST_CROSS_PLATFORM_UID 0 +#endif + #if ! (JUCE_PLUGINHOST_AU || JUCE_PLUGINHOST_VST || JUCE_PLUGINHOST_VST3 || JUCE_PLUGINHOST_LADSPA) // #error "You need to set either the JUCE_PLUGINHOST_AU and/or JUCE_PLUGINHOST_VST and/or JUCE_PLUGINHOST_VST3 and/or JUCE_PLUGINHOST_LADSPA flags if you're using this module!" #endif