commit 4bcb4d4dc8d665dc7119f74f3a826c99c5798191
parent 1357e37f2c260e4bee11f5bb673ea85c3af52a06
Author: falkTX <falktx@falktx.com>
Date: Wed, 25 May 2022 05:04:42 +0100
More tweaks to getBusArrangement, add stereo tag to example meter
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
2 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp
@@ -1027,19 +1027,37 @@ public:
if (port.busId != ubusId)
continue;
+ v3_speaker_arrangement arr;
+
switch (port.groupId)
{
case kPortGroupMono:
- *speaker = V3_SPEAKER_M;
+ arr = V3_SPEAKER_M;
break;
case kPortGroupStereo:
- *speaker = V3_SPEAKER_L | V3_SPEAKER_R;
+ arr = V3_SPEAKER_L | V3_SPEAKER_R;
break;
default:
- *speaker = 0;
+ if (inputBuses.audio != 0 && ubusId == 0)
+ {
+ arr = 0x0;
+ for (uint32_t j=0; j<inputBuses.numMainAudio; ++j)
+ arr |= 1ull << (j + 33ull);
+ }
+ else if (inputBuses.sidechain != 0 && ubusId == inputBuses.audio)
+ {
+ arr = 0x0;
+ for (uint32_t j=0; j<inputBuses.numSidechain; ++j)
+ arr |= 1ull << (inputBuses.numMainAudio + j + 33ull);
+ }
+ else
+ {
+ arr = 1ull << (inputBuses.numMainAudio + inputBuses.numSidechain + ubusId + 33ull);
+ }
break;
}
+ *speaker = arr;
return V3_OK;
}
#endif // DISTRHO_PLUGIN_NUM_INPUTS
@@ -1056,19 +1074,37 @@ public:
if (port.busId != ubusId)
continue;
+ v3_speaker_arrangement arr;
+
switch (port.groupId)
{
case kPortGroupMono:
- *speaker = V3_SPEAKER_M;
+ arr = V3_SPEAKER_M;
break;
case kPortGroupStereo:
- *speaker = V3_SPEAKER_L | V3_SPEAKER_R;
+ arr = V3_SPEAKER_L | V3_SPEAKER_R;
break;
default:
- *speaker = 0;
+ if (outputBuses.audio != 0 && ubusId == 0)
+ {
+ arr = 0x0;
+ for (uint32_t j=0; j<outputBuses.numMainAudio; ++j)
+ arr |= 1ull << (j + 33ull);
+ }
+ else if (outputBuses.sidechain != 0 && ubusId == outputBuses.audio)
+ {
+ arr = 0x0;
+ for (uint32_t j=0; j<outputBuses.numSidechain; ++j)
+ arr |= 1ull << (outputBuses.numMainAudio + j + 33ull);
+ }
+ else
+ {
+ arr = 1ull << (outputBuses.numMainAudio + outputBuses.numSidechain + ubusId + 33ull);
+ }
break;
}
+ *speaker = arr;
return V3_OK;
}
#endif // DISTRHO_PLUGIN_NUM_OUTPUTS
diff --git a/examples/Meters/ExamplePluginMeters.cpp b/examples/Meters/ExamplePluginMeters.cpp
@@ -102,6 +102,19 @@ protected:
* Init */
/**
+ Initialize the audio port @a index.@n
+ This function will be called once, shortly after the plugin is created.
+ */
+ void initAudioPort(bool input, uint32_t index, AudioPort& port) override
+ {
+ // treat meter audio ports as stereo
+ port.groupId = kPortGroupStereo;
+
+ // everything else is as default
+ Plugin::initAudioPort(input, index, port);
+ }
+
+ /**
Initialize the parameter @a index.
This function will be called once, shortly after the plugin is created.
*/