Skip to content

Commit

Permalink
VST2: Ensured that the VST2 version number is encoded correctly for d…
Browse files Browse the repository at this point in the history
…isplay in Cubase and when hosting VST2 plug-ins in JUCE
  • Loading branch information
hogliux committed Oct 3, 2017
1 parent abe8676 commit c382827
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 26 deletions.
29 changes: 23 additions & 6 deletions modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp
Expand Up @@ -295,9 +295,9 @@ class JuceVSTWrapper : public AudioProcessorListener,
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;
Expand Down Expand Up @@ -1483,10 +1483,27 @@ class JuceVSTWrapper : public AudioProcessorListener,
#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
}

Expand Down
52 changes: 32 additions & 20 deletions modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp
Expand Up @@ -1971,32 +1971,44 @@ struct VSTPluginInstance : public AudioPluginInstance,

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;

This comment has been minimized.

Copy link
@yfede

yfede Oct 3, 2017

I think "build" and "bugfix" names are to be swapped in this file for the hosting.
You are labelling the third part "build" and the fourth "bugfix", whereas "bugfix" is regarded as the third in the wrapper code (which I believe is the correct way)

This comment has been minimized.

Copy link
@hogliux

hogliux Oct 3, 2017

Author Contributor

Thanks. Just committed a fix for this which will appear on develop soon.

}

return s;
Expand Down

0 comments on commit c382827

Please sign in to comment.