Browse Source

VST2: Ensured that the VST2 version number is encoded correctly for display in Cubase and when hosting VST2 plug-ins in JUCE

tags/2021-05-28
hogliux 8 years ago
parent
commit
c38282778d
2 changed files with 55 additions and 26 deletions
  1. +23
    -6
      modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
  2. +32
    -20
      modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp

+ 23
- 6
modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp View File

@@ -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
}


+ 32
- 20
modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp View File

@@ -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;


Loading…
Cancel
Save