mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
VST3: Add support for defining a custom VST3 component class ID
This commit is contained in:
parent
a1a56cd54c
commit
1294562075
2 changed files with 92 additions and 50 deletions
|
|
@ -220,10 +220,42 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#if DOXYGEN
|
#if DOXYGEN
|
||||||
|
/** An optional user defined preprocessor definition for declaring the VST3
|
||||||
|
plugin identifier as used by the host.
|
||||||
|
|
||||||
|
This is useful if you're creating a VST3 plugin using JUCE that needs to
|
||||||
|
replace a VST3 plugin that was not originally created using JUCE.
|
||||||
|
|
||||||
|
If there are multiple identifiers this plugin needs to replace take a look
|
||||||
|
at JUCE_VST3_COMPATIBLE_CLASSES. If required, both preprocessor definitions
|
||||||
|
can be used in combination for maximum compatibility.
|
||||||
|
|
||||||
|
The definition of this preprocessor must be defined at the project
|
||||||
|
level, normally in your CMake or Projucer project files.
|
||||||
|
|
||||||
|
If JUCE_VST3_CAN_REPLACE_VST2 is enabled, the VST3 plugin will have the
|
||||||
|
same identifier as the VST2 plugin and therefore this preprocessor
|
||||||
|
definition will have no effect!
|
||||||
|
|
||||||
|
This preprocessor definition should be defined as a string containing 32
|
||||||
|
hex characters, for example...
|
||||||
|
|
||||||
|
@code
|
||||||
|
JUCE_VST3_COMPONENT_CLASS="0F1E2D3C4B5A69788796A5B4C3D2E1F0"
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
@see JUCE_VST3_COMPONENT_CLASS
|
||||||
|
*/
|
||||||
|
#define JUCE_VST3_COMPONENT_CLASS
|
||||||
|
|
||||||
/** An optional user defined preprocessor definition for declaring a comma
|
/** An optional user defined preprocessor definition for declaring a comma
|
||||||
separated list of VST2 and VST3 plugin identifiers that this VST3 plugin
|
separated list of VST2 and VST3 plugin identifiers that this VST3 plugin
|
||||||
can replace in a DAW session.
|
can replace in a DAW session.
|
||||||
|
|
||||||
|
At the time of writing not all hosts support this feature, if you don't
|
||||||
|
have multiple plugins with different identifiers already released, consider
|
||||||
|
using JUCE_VST3_COMPONENT_CLASS instead.
|
||||||
|
|
||||||
The definition of this preprocessor must be defined at the project
|
The definition of this preprocessor must be defined at the project
|
||||||
level, normally in your CMake or Projucer project files.
|
level, normally in your CMake or Projucer project files.
|
||||||
|
|
||||||
|
|
@ -265,7 +297,7 @@ private:
|
||||||
If the parameter IDs between compatible versions differ
|
If the parameter IDs between compatible versions differ
|
||||||
VST3ClientExtensions::getCompatibleParameterIds() should also be overridden.
|
VST3ClientExtensions::getCompatibleParameterIds() should also be overridden.
|
||||||
|
|
||||||
@see VST3Interface VST3ClientExtensions::getCompatibleParameterIds()
|
@see JUCE_VST3_COMPONENT_CLASS, VST3Interface, VST3ClientExtensions::getCompatibleParameterIds()
|
||||||
*/
|
*/
|
||||||
#define JUCE_VST3_COMPATIBLE_CLASSES
|
#define JUCE_VST3_COMPATIBLE_CLASSES
|
||||||
#endif // DOXYGEN
|
#endif // DOXYGEN
|
||||||
|
|
|
||||||
|
|
@ -117,18 +117,76 @@ struct VST3Interface
|
||||||
return iid;
|
return iid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Converts a 32-character hex notation string to a VST3 interface ID.
|
||||||
|
|
||||||
|
@see jucePluginId, vst2PluginId
|
||||||
|
*/
|
||||||
|
static inline Id hexStringToId (const char* hex)
|
||||||
|
{
|
||||||
|
jassert (std::strlen (hex) == 32);
|
||||||
|
|
||||||
|
const auto getByteValue = [](const char* str)
|
||||||
|
{
|
||||||
|
const auto getCharacterValue = [](const char c)
|
||||||
|
{
|
||||||
|
if (c >= '0' && c <= '9')
|
||||||
|
return (std::byte) (c - '0');
|
||||||
|
|
||||||
|
if (c >= 'A' && c <= 'F')
|
||||||
|
return (std::byte) (c - 'A' + 10);
|
||||||
|
|
||||||
|
if (c >= 'a' && c <= 'f')
|
||||||
|
return (std::byte) (c - 'a' + 10);
|
||||||
|
|
||||||
|
// Invalid hex character!
|
||||||
|
jassertfalse;
|
||||||
|
return std::byte{};
|
||||||
|
};
|
||||||
|
|
||||||
|
return getCharacterValue (str[0]) << 4
|
||||||
|
| getCharacterValue (str[1]);
|
||||||
|
};
|
||||||
|
|
||||||
|
return { getByteValue (hex),
|
||||||
|
getByteValue (hex + 2),
|
||||||
|
getByteValue (hex + 4),
|
||||||
|
getByteValue (hex + 6),
|
||||||
|
getByteValue (hex + 8),
|
||||||
|
getByteValue (hex + 10),
|
||||||
|
getByteValue (hex + 12),
|
||||||
|
getByteValue (hex + 14),
|
||||||
|
getByteValue (hex + 16),
|
||||||
|
getByteValue (hex + 18),
|
||||||
|
getByteValue (hex + 20),
|
||||||
|
getByteValue (hex + 22),
|
||||||
|
getByteValue (hex + 24),
|
||||||
|
getByteValue (hex + 26),
|
||||||
|
getByteValue (hex + 28),
|
||||||
|
getByteValue (hex + 30) };
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns a 16-byte array indicating the VST3 interface ID used for a given
|
/** Returns a 16-byte array indicating the VST3 interface ID used for a given
|
||||||
JUCE VST3 plugin.
|
JUCE VST3 plugin.
|
||||||
|
|
||||||
Internally this is what JUCE will use to assign an ID to each VST3 interface,
|
Internally this is what JUCE will use to assign an ID to each VST3 interface,
|
||||||
unless JUCE_VST3_CAN_REPLACE_VST2 is enabled.
|
unless JUCE_VST3_CAN_REPLACE_VST2 is enabled.
|
||||||
|
|
||||||
@see vst2PluginId, hexStringToId
|
If JUCE_VST3_COMPONENT_CLASS is defined it will return this value when the
|
||||||
|
interface type is Type::component. This is useful if you're releasing a
|
||||||
|
VST3 plugin with JUCE that needs to replace a version of a VST3 plugin
|
||||||
|
that wasn't originally built using JUCE.
|
||||||
|
|
||||||
|
@see vst2PluginId, hexStringToId, JUCE_VST3_COMPONENT_CLASS
|
||||||
*/
|
*/
|
||||||
static inline Id jucePluginId (uint32_t manufacturerCode,
|
static inline Id jucePluginId (uint32_t manufacturerCode,
|
||||||
uint32_t pluginCode,
|
uint32_t pluginCode,
|
||||||
Type interfaceType = Type::component)
|
Type interfaceType = Type::component)
|
||||||
{
|
{
|
||||||
|
#ifdef JUCE_VST3_COMPONENT_CLASS
|
||||||
|
if (interfaceType == Type::component)
|
||||||
|
return hexStringToId ( JUCE_VST3_COMPONENT_CLASS );
|
||||||
|
#endif
|
||||||
|
|
||||||
const auto word0 = std::invoke ([&]() -> uint32_t
|
const auto word0 = std::invoke ([&]() -> uint32_t
|
||||||
{
|
{
|
||||||
switch (interfaceType)
|
switch (interfaceType)
|
||||||
|
|
@ -194,54 +252,6 @@ struct VST3Interface
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Converts a 32-character hex notation string to a VST3 interface ID.
|
|
||||||
|
|
||||||
@see jucePluginId, vst2PluginId
|
|
||||||
*/
|
|
||||||
static inline Id hexStringToId (const char* hex)
|
|
||||||
{
|
|
||||||
jassert (std::strlen (hex) == 32);
|
|
||||||
|
|
||||||
const auto getByteValue = [](const char* str)
|
|
||||||
{
|
|
||||||
const auto getCharacterValue = [](const char c)
|
|
||||||
{
|
|
||||||
if (c >= '0' && c <= '9')
|
|
||||||
return (std::byte) (c - '0');
|
|
||||||
|
|
||||||
if (c >= 'A' && c <= 'F')
|
|
||||||
return (std::byte) (c - 'A' + 10);
|
|
||||||
|
|
||||||
if (c >= 'a' && c <= 'f')
|
|
||||||
return (std::byte) (c - 'a' + 10);
|
|
||||||
|
|
||||||
// Invalid hex character!
|
|
||||||
jassertfalse;
|
|
||||||
return std::byte{};
|
|
||||||
};
|
|
||||||
|
|
||||||
return getCharacterValue (str[0]) << 4
|
|
||||||
| getCharacterValue (str[1]);
|
|
||||||
};
|
|
||||||
|
|
||||||
return { getByteValue (hex),
|
|
||||||
getByteValue (hex + 2),
|
|
||||||
getByteValue (hex + 4),
|
|
||||||
getByteValue (hex + 6),
|
|
||||||
getByteValue (hex + 8),
|
|
||||||
getByteValue (hex + 10),
|
|
||||||
getByteValue (hex + 12),
|
|
||||||
getByteValue (hex + 14),
|
|
||||||
getByteValue (hex + 16),
|
|
||||||
getByteValue (hex + 18),
|
|
||||||
getByteValue (hex + 20),
|
|
||||||
getByteValue (hex + 22),
|
|
||||||
getByteValue (hex + 24),
|
|
||||||
getByteValue (hex + 26),
|
|
||||||
getByteValue (hex + 28),
|
|
||||||
getByteValue (hex + 30) };
|
|
||||||
}
|
|
||||||
|
|
||||||
VST3Interface() = delete;
|
VST3Interface() = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue