1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-21 01:24:21 +00:00

VST3: Fixed invalid AudioProcessorParameterGroup unit IDs

This commit is contained in:
Tom Poole 2020-12-18 18:33:55 +00:00
parent d9b2a61454
commit 1fbd6dff9b
3 changed files with 52 additions and 2 deletions

View file

@ -233,7 +233,19 @@ public:
static Vst::UnitID getUnitID (const AudioProcessorParameterGroup* group)
{
return group == nullptr ? Vst::kRootUnitId : group->getID().hashCode();
if (group == nullptr || group->getParent() == nullptr)
return Vst::kRootUnitId;
// From the VST3 docs:
// Up to 2^31 parameters can be exported with id range [0, 2147483648]
// (the range [2147483649, 429496729] is reserved for host application).
auto unitID = group->getID().hashCode() & 0x7fffffff;
// If you hit this assertion then your group ID is hashing to a value
// reserved by the VST3 SDK. Use a different group ID.
jassert (unitID != Vst::kRootUnitId);
return unitID;
}
int getNumParameters() const noexcept { return vstParamIDs.size(); }
@ -263,6 +275,21 @@ private:
{
parameterGroups = audioProcessor->getParameterTree().getSubgroups (true);
#if JUCE_DEBUG
auto allGroups = parameterGroups;
allGroups.add (&audioProcessor->getParameterTree());
std::unordered_set<Vst::UnitID> unitIDs;
for (auto* group : allGroups)
{
auto insertResult = unitIDs.insert (getUnitID (group));
// If you hit this assertion then either a group ID is not unique or
// you are very unlucky and a hashed group ID is not unique
jassert (insertResult.second);
}
#endif
#if JUCE_FORCE_USE_LEGACY_PARAM_IDS
const bool forceLegacyParamIDs = true;
#else