commit 0094b495cc16d795f552f13c340c3ea4a8eb25cb
parent 6d57f75c6a5cc01bf34ba9e72346320395e6b7ee
Author: falkTX <falktx@falktx.com>
Date: Mon, 21 Jun 2021 16:01:52 +0100
Implement port groups for VST2 parameters
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/distrho/src/DistrhoPluginVST2.cpp b/distrho/src/DistrhoPluginVST2.cpp
@@ -1448,7 +1448,9 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
memset(properties, 0, sizeof(VstParameterProperties));
// full name
- DISTRHO_NAMESPACE::strncpy(properties->label, plugin.getParameterName(index), VestigeMaxLabelLen);
+ DISTRHO_NAMESPACE::strncpy(properties->label,
+ plugin.getParameterName(index),
+ sizeof(properties->label));
// short name
const String& shortName(plugin.getParameterShortName(index));
@@ -1456,7 +1458,7 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
if (shortName.isNotEmpty())
DISTRHO_NAMESPACE::strncpy(properties->shortLabel,
plugin.getParameterShortName(index),
- VestigeMaxShortLabelLen);
+ sizeof(properties->shortLabel));
// parameter hints
const uint32_t hints = plugin.getParameterHints(index);
@@ -1482,6 +1484,34 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
properties->flags |= kVstParameterCanRamp;
}
+ // parameter group (category in vst)
+ const uint32_t groupId = plugin.getParameterGroupId(index);
+
+ if (groupId != kPortGroupNone)
+ {
+ // we can't use groupId directly, so use the index array where this group is stored in
+ for (uint32_t i=0, count=plugin.getPortGroupCount(); i < count; ++i)
+ {
+ const PortGroupWithId& portGroup(plugin.getPortGroupByIndex(i));
+
+ if (portGroup.groupId == groupId)
+ {
+ properties->category = i + 1;
+ DISTRHO_NAMESPACE::strncpy(properties->categoryLabel,
+ portGroup.name.buffer(),
+ sizeof(properties->categoryLabel));
+ break;
+ }
+ }
+
+ if (properties->category != 0)
+ {
+ for (uint32_t i=0, count=plugin.getParameterCount(); i < count; ++i)
+ if (plugin.getParameterGroupId(i) == groupId)
+ ++properties->numParametersInCategory;
+ }
+ }
+
return 1;
}
}