Browse Source

Add: Add extra version

pull/471/head
sevenc-nanashi 7 months ago
parent
commit
13ab4c76f4
11 changed files with 161 additions and 1 deletions
  1. +1
    -0
      FEATURES.md
  2. +85
    -0
      distrho/DistrhoDetails.hpp
  3. +8
    -0
      distrho/DistrhoInfo.hpp
  4. +8
    -0
      distrho/DistrhoPlugin.hpp
  5. +7
    -0
      distrho/DistrhoPluginInfo.h.template
  6. +4
    -0
      distrho/src/DistrhoPluginChecks.h
  7. +9
    -0
      distrho/src/DistrhoPluginInternal.hpp
  8. +8
    -0
      distrho/src/DistrhoPluginLV2export.cpp
  9. +12
    -0
      distrho/src/DistrhoPluginVST2.cpp
  10. +18
    -1
      distrho/src/DistrhoPluginVST3.cpp
  11. +1
    -0
      dpf.doxygen

+ 1
- 0
FEATURES.md View File

@@ -27,6 +27,7 @@ If the limitation is within DPF, a link is provided to a description below on th
| UI host-resize | Yes | No | Yes | Yes | No | Yes | Yes | No | UI host-resize | | UI host-resize | Yes | No | Yes | Yes | No | Yes | Yes | No | UI host-resize |
| UI remote control | No | No | Yes | Yes | No | Yes | No | Yes | UI remote control | | UI remote control | No | No | Yes | Yes | No | Yes | No | Yes | UI remote control |
| UI send midi note | Yes | No | Yes | Yes | Yes | Yes | Yes | Yes | UI send midi note | | UI send midi note | Yes | No | Yes | Yes | Yes | Yes | Yes | Yes | UI send midi note |
| Extra version info | N/A | N/A | N/A | Yes | No | Yes | N/A | N/A | Extra version info |


For things that could be unclear: For things that could be unclear:




+ 85
- 0
distrho/DistrhoDetails.hpp View File

@@ -1051,6 +1051,91 @@ struct TimePosition {
} }
}; };


/**
The build version number is not available.
*/
static constexpr const uint32_t kDistrhoNoBuildVersion = (uint32_t)-1;

/**
Version information.

@see DISTRHO_PLUGIN_WANT_EXTRA_VERSION
*/
struct VersionInfo {
/**
Major version number.
*/
uint32_t major;

/**
Minor version number.
*/
uint32_t minor;

/**
Micro version number.
*/
uint32_t micro;

/**
Build version number. @n

This should be set to kDistrhoNoBuildVersion if the build number is not available.
*/
uint32_t build;

/**
Default constructor for a null version.
*/
VersionInfo() noexcept
: major(0),
minor(0),
micro(0),
build(kDistrhoNoBuildVersion) {}

/**
Constructor using custom values.
*/
VersionInfo(uint32_t maj, uint32_t min, uint32_t mic, uint32_t bld = kDistrhoNoBuildVersion) noexcept
: major(maj),
minor(min),
micro(mic),
build(bld) {}

/**
Constructor using uint32_t version number.
*/
VersionInfo(uint32_t ver) noexcept
: major((ver >> 16) & 0xFF),
minor((ver >> 8) & 0xFF),
micro((ver) & 0xFF),
build(kDistrhoNoBuildVersion) {}

/**
Convert to uint32_t version number.
*/
uint32_t toUint32() const noexcept
{
uint32_t ver = 0;
if (major > 0xFFFF)
ver |= 0xFFFF0000;
else
ver |= (major << 16);

if (minor > 0xFF)
ver |= 0xFF00;
else
ver |= (minor << 8);

if (micro > 0xFF)
ver |= 0xFF;
else
ver |= micro;

return ver;
}
};

/** @} */ /** @} */


// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------


+ 8
- 0
distrho/DistrhoInfo.hpp View File

@@ -547,6 +547,14 @@ START_NAMESPACE_DISTRHO
*/ */
#define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0 #define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0


/**
Enable extra version information.

@see Plugin::getVersion()
@see VersionInfo
*/
#define DISTRHO_PLUGIN_WANT_EXTRA_VERSION 0

/** /**
Whether the plugin introduces latency during audio or midi processing. Whether the plugin introduces latency during audio or midi processing.
@see Plugin::setLatency(uint32_t) @see Plugin::setLatency(uint32_t)


+ 8
- 0
distrho/DistrhoPlugin.hpp View File

@@ -249,11 +249,19 @@ protected:
virtual const char* getLicense() const = 0; virtual const char* getLicense() const = 0;
#endif #endif


#if DISTRHO_PLUGIN_WANT_EXTRA_VERSION
/**
Get the plugin version.
@see VersionInfo
*/
virtual VersionInfo getVersion() const = 0;
#else
/** /**
Get the plugin version, in hexadecimal. Get the plugin version, in hexadecimal.
@see d_version() @see d_version()
*/ */
virtual uint32_t getVersion() const = 0; virtual uint32_t getVersion() const = 0;
#endif


/** /**
Get the plugin unique Id.@n Get the plugin unique Id.@n


+ 7
- 0
distrho/DistrhoPluginInfo.h.template View File

@@ -75,6 +75,13 @@
*/ */
// #define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0 // #define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0


/**
Enable extra version information.

@see VersionInfo
*/
// #define DISTRHO_PLUGIN_WANT_EXTRA_VERSION 0

/** /**
Whether the plugin introduces latency during audio or midi processing. Whether the plugin introduces latency during audio or midi processing.
@see Plugin::setLatency(uint32_t) @see Plugin::setLatency(uint32_t)


+ 4
- 0
distrho/src/DistrhoPluginChecks.h View File

@@ -61,6 +61,10 @@
# define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0 # define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0
#endif #endif


#ifndef DISTRHO_PLUGIN_WANT_EXTRA_VERSION
# define DISTRHO_PLUGIN_WANT_EXTRA_VERSION 0
#endif

#ifndef DISTRHO_PLUGIN_WANT_LATENCY #ifndef DISTRHO_PLUGIN_WANT_LATENCY
# define DISTRHO_PLUGIN_WANT_LATENCY 0 # define DISTRHO_PLUGIN_WANT_LATENCY 0
#endif #endif


+ 9
- 0
distrho/src/DistrhoPluginInternal.hpp View File

@@ -525,12 +525,21 @@ public:
return fPlugin->getLicense(); return fPlugin->getLicense();
} }


#if DISTRHO_PLUGIN_WANT_EXTRA_VERSION
VersionInfo getVersion() const noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, VersionInfo());

return fPlugin->getVersion();
}
#else
uint32_t getVersion() const noexcept uint32_t getVersion() const noexcept
{ {
DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, 0); DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, 0);


return fPlugin->getVersion(); return fPlugin->getVersion();
} }
#endif


long getUniqueId() const noexcept long getUniqueId() const noexcept
{ {


+ 8
- 0
distrho/src/DistrhoPluginLV2export.cpp View File

@@ -1176,11 +1176,19 @@ void lv2_generate_ttl(const char* const basename)
} }


{ {
#if DISTRHO_PLUGIN_WANT_EXTRA_VERSION
const VersionInfo version(plugin.getVersion());

const uint32_t majorVersion = version.major;
/* */ uint32_t minorVersion = version.minor;
const uint32_t microVersion = version.micro;
#else
const uint32_t version(plugin.getVersion()); const uint32_t version(plugin.getVersion());


const uint32_t majorVersion = (version & 0xFF0000) >> 16; const uint32_t majorVersion = (version & 0xFF0000) >> 16;
/* */ uint32_t minorVersion = (version & 0x00FF00) >> 8; /* */ uint32_t minorVersion = (version & 0x00FF00) >> 8;
const uint32_t microVersion = (version & 0x0000FF) >> 0; const uint32_t microVersion = (version & 0x0000FF) >> 0;
#endif


// NOTE: LV2 ignores 'major' version and says 0 for minor is pre-release/unstable. // NOTE: LV2 ignores 'major' version and says 0 for minor is pre-release/unstable.
if (majorVersion > 0) if (majorVersion > 0)


+ 12
- 0
distrho/src/DistrhoPluginVST2.cpp View File

@@ -36,6 +36,10 @@


#include "xaymar-vst2/vst.h" #include "xaymar-vst2/vst.h"


#if DISTRHO_PLUGIN_WANT_EXTRA_VERSION
# warning "VST2 does not support version number higher than 0xFF nor the build version"
#endif

START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
@@ -1530,7 +1534,11 @@ static intptr_t VST_FUNCTION_INTERFACE vst_dispatcherCallback(vst_effect* const
return 0; return 0;


case VST_EFFECT_OPCODE_VENDOR_VERSION: case VST_EFFECT_OPCODE_VENDOR_VERSION:
#if DISTRHO_PLUGIN_WANT_EXTRA_VERSION
return sPlugin->getVersion().toUint32();
#else
return sPlugin->getVersion(); return sPlugin->getVersion();
#endif


case VST_EFFECT_OPCODE_VST_VERSION: case VST_EFFECT_OPCODE_VST_VERSION:
return VST_VERSION_2_4_0_0; return VST_VERSION_2_4_0_0;
@@ -1651,7 +1659,11 @@ const vst_effect* VSTPluginMain(const vst_host_callback audioMaster)
effect->magic_number = 0x56737450; effect->magic_number = 0x56737450;
#endif #endif
effect->unique_id = sPlugin->getUniqueId(); effect->unique_id = sPlugin->getUniqueId();
#if DISTRHO_PLUGIN_WANT_EXTRA_VERSION
effect->version = sPlugin->getVersion().toUint32();
#else
effect->version = sPlugin->getVersion(); effect->version = sPlugin->getVersion();
#endif


// VST doesn't support parameter outputs. we can fake them, but it is a hack. Disabled by default. // VST doesn't support parameter outputs. we can fake them, but it is a hack. Disabled by default.
#ifdef DPF_VST_SHOW_PARAMETER_OUTPUTS #ifdef DPF_VST_SHOW_PARAMETER_OUTPUTS


+ 18
- 1
distrho/src/DistrhoPluginVST3.cpp View File

@@ -4590,13 +4590,30 @@ static const char* getPluginVersion()


if (version.isEmpty()) if (version.isEmpty())
{ {
char versionBuf[64];
#if DISTRHO_PLUGIN_WANT_EXTRA_VERSION
const VersionInfo versionInfo = sPlugin->getVersion();

if (versionInfo.build != kDistrhoNoBuildVersion) {
std::snprintf(versionBuf, sizeof(versionBuf)-1, "%d.%d.%d.%d",
versionInfo.major,
versionInfo.minor,
versionInfo.micro,
versionInfo.build);
} else {
std::snprintf(versionBuf, sizeof(versionBuf)-1, "%d.%d.%d",
versionInfo.major,
versionInfo.minor,
versionInfo.micro);
}
#else
const uint32_t versionNum = sPlugin->getVersion(); const uint32_t versionNum = sPlugin->getVersion();


char versionBuf[64];
std::snprintf(versionBuf, sizeof(versionBuf)-1, "%d.%d.%d", std::snprintf(versionBuf, sizeof(versionBuf)-1, "%d.%d.%d",
(versionNum >> 16) & 0xff, (versionNum >> 16) & 0xff,
(versionNum >> 8) & 0xff, (versionNum >> 8) & 0xff,
(versionNum >> 0) & 0xff); (versionNum >> 0) & 0xff);
#endif
versionBuf[sizeof(versionBuf)-1] = '\0'; versionBuf[sizeof(versionBuf)-1] = '\0';
version = versionBuf; version = versionBuf;
} }


+ 1
- 0
dpf.doxygen View File

@@ -255,6 +255,7 @@ PREDEFINED = DOXYGEN \
DISTRHO_PLUGIN_IS_RT_SAFE=1 \ DISTRHO_PLUGIN_IS_RT_SAFE=1 \
DISTRHO_PLUGIN_IS_SYNTH=1 \ DISTRHO_PLUGIN_IS_SYNTH=1 \
DISTRHO_PLUGIN_WANT_DIRECT_ACCESS=1 \ DISTRHO_PLUGIN_WANT_DIRECT_ACCESS=1 \
DISTRHO_PLUGIN_WANT_EXTRA_VERSION=1 \
DISTRHO_PLUGIN_WANT_LATENCY=1 \ DISTRHO_PLUGIN_WANT_LATENCY=1 \
DISTRHO_PLUGIN_WANT_MIDI_INPUT=1 \ DISTRHO_PLUGIN_WANT_MIDI_INPUT=1 \
DISTRHO_PLUGIN_WANT_MIDI_OUTPUT=1 \ DISTRHO_PLUGIN_WANT_MIDI_OUTPUT=1 \


Loading…
Cancel
Save