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 383d1f17f0..a618002a57 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -295,9 +295,9 @@ public: vstEffect.plugInIdentifier = JucePlugin_VSTUniqueID; #ifdef JucePlugin_VSTChunkStructureVersion - vstEffect.plugInVersion = convertHexVersionToDecimal (JucePlugin_VSTChunkStructureVersion); + vstEffect.plugInVersion = JucePlugin_VSTChunkStructureVersion; #else - vstEffect.plugInVersion = convertHexVersionToDecimal (JucePlugin_VersionCode); + vstEffect.plugInVersion = JucePlugin_VersionCode; #endif vstEffect.processAudioInplaceFunction = processReplacingCB; @@ -1483,10 +1483,27 @@ private: #if JUCE_VST_RETURN_HEX_VERSION_NUMBER_DIRECTLY return (int32) hexVersion; #else - return (int32) (((hexVersion >> 24) & 0xff) * 1000 - + ((hexVersion >> 16) & 0xff) * 100 - + ((hexVersion >> 8) & 0xff) * 10 - + (hexVersion & 0xff)); + // Currently, only Cubase displays the version number to the user + // We are hoping here that when other DAWs start to display the version + // number, that they do so according to yfede's encoding table in the link + // below. If not, then this code will need an if (isSteinberg()) in the + // future. + auto major = (hexVersion >> 16) & 0xff; + auto minor = (hexVersion >> 8) & 0xff; + auto bugfix = hexVersion & 0xff; + + // for details, see: https://forum.juce.com/t/issues-with-version-integer-reported-by-vst2/23867 + + // Encoding B + if (major < 1) + return major * 1000 + minor * 100 + bugfix * 10; + + // Encoding E + if (major > 100) + return major * 10000000 + minor * 100000 + bugfix * 1000; + + // Encoding D + return hexVersion; #endif } diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 172e348844..d53d7ec858 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -1971,32 +1971,44 @@ private: if (v != 0) { - int versionBits[32]; - int n = 0; + // See yfede's post for the rational on this encoding + // https://forum.juce.com/t/issues-with-version-integer-reported-by-vst2/23867/6 - for (auto vv = v; vv != 0; vv /= 10) - versionBits [n++] = vv % 10; + auto major = 0, minor = 0, build = 0, bugfix = 0; - if (n > 4) // if the number ends up silly, it's probably encoded as hex instead of decimal.. + if (v < 10) // Encoding A { - n = 0; - - for (auto vv = v; vv != 0; vv >>= 8) - versionBits [n++] = vv & 255; + major = v; } - - while (n > 1 && versionBits [n - 1] == 0) - --n; - - s << 'V'; - - while (n > 0) + else if (v < 10000) // Encoding B { - s << versionBits [--n]; - - if (n > 0) - s << '.'; + major = (v / 1000); + minor = (v % 1000) / 100; + build = (v % 100) / 10; + bugfix = (v % 10); + } + else if (v < 0x10000) // Encoding C + { + major = (v / 10000); + minor = (v % 10000) / 1000; + build = (v % 1000) / 100; + bugfix = (v % 100) / 10; + } + else if (v < 0x650000) // Encoding D + { + major = (v >> 16) & 0xff; + minor = (v >> 8) & 0xff; + build = (v >> 0) & 0xff; } + else // Encoding E + { + major = (v / 10000000); + minor = (v % 10000000) / 100000; + build = (v % 100000) / 1000; + bugfix = (v % 1000); + } + + s << major << '.' << minor << '.' << build << '.' << bugfix; } return s;