Skip to content

Commit f3157f0

Browse files
committed
VST3 Client: Implement PreSonus::IContextInfoHandler::notifyContextInfoChange in JuceVST3EditController
1 parent f908e52 commit f3157f0

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

modules/juce_audio_plugin_client/juce_audio_plugin_client_VST3.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ class JuceVST3EditController final : public Vst::EditController,
880880
#if JucePlugin_Enable_ARA
881881
public Presonus::IPlugInViewEmbedding,
882882
#endif
883+
public Presonus::IContextInfoHandler,
883884
public AudioProcessorListener,
884885
private ComponentRestarter::Listener
885886
{
@@ -1135,6 +1136,48 @@ class JuceVST3EditController final : public Vst::EditController,
11351136
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProgramChangeParameter)
11361137
};
11371138

1139+
void notifyContextInfoChange() override
1140+
{
1141+
if (! PluginHostType().isStudioOne())
1142+
return;
1143+
1144+
if (auto* instance = getPluginInstance())
1145+
{
1146+
bool hasUsableContextInfoChange = false;
1147+
AudioProcessor::TrackProperties trackProperties;
1148+
FUnknownPtr<Presonus::IContextInfoProvider> contextInfoProvider (componentHandler);
1149+
Steinberg::int32 channelColour = 0;
1150+
if (contextInfoProvider->getContextInfoValue (channelColour, Presonus::ContextInfo::kColor)
1151+
== kResultTrue)
1152+
{
1153+
// PreSonus uses RGBA
1154+
uint8 r = (channelColour) &0x000000FF;
1155+
uint8 g = (channelColour >> 8) & 0x000000FF;
1156+
uint8 b = (channelColour >> 16) & 0x000000FF;
1157+
uint8 a = (channelColour >> 24) & 0x000000FF;
1158+
trackProperties.colour = std::make_optional (Colour (r, g, b, a));
1159+
hasUsableContextInfoChange = true;
1160+
}
1161+
1162+
Vst::TChar channelName[128] = {0};
1163+
if (contextInfoProvider->getContextInfoString (channelName, 128, Presonus::ContextInfo::kName)
1164+
== kResultTrue)
1165+
{
1166+
trackProperties.name = std::make_optional (toString (channelName));
1167+
hasUsableContextInfoChange = true;
1168+
}
1169+
1170+
if (! hasUsableContextInfoChange)
1171+
return;
1172+
1173+
if (MessageManager::getInstance()->isThisTheMessageThread())
1174+
instance->updateTrackProperties (trackProperties);
1175+
else
1176+
MessageManager::callAsync ([trackProperties, instance]
1177+
{ instance->updateTrackProperties (trackProperties); });
1178+
}
1179+
}
1180+
11381181
//==============================================================================
11391182
tresult PLUGIN_API getCompatibleParamID (const TUID pluginToReplaceUID,
11401183
Vst::ParamID oldParamID,
@@ -1692,6 +1735,7 @@ class JuceVST3EditController final : public Vst::EditController,
16921735
UniqueBase<Vst::IUnitInfo>{},
16931736
UniqueBase<Vst::IRemapParamID>{},
16941737
UniqueBase<Vst::ChannelContext::IInfoListener>{},
1738+
UniqueBase<Presonus::IContextInfoHandler>{},
16951739
SharedBase<IPluginBase, Vst::IEditController>{},
16961740
UniqueBase<IDependent>{},
16971741
#if JucePlugin_Enable_ARA

modules/juce_audio_processors/format_types/juce_VST3Headers.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-W#warnings",
139139
#include <public.sdk/source/vst/vstpresetfile.h>
140140

141141
#include "pslextensions/ipslviewembedding.h"
142+
#include "pslextensions/ipslcontextinfo.h"
142143
#else
143144
// needed for VST_VERSION
144145
#include <pluginterfaces/vst/vsttypes.h>
@@ -211,6 +212,7 @@ JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-W#warnings",
211212
#endif
212213

213214
#include "pslextensions/ipslviewembedding.h"
215+
#include "pslextensions/ipslcontextinfo.h"
214216

215217
//==============================================================================
216218
namespace Steinberg
@@ -238,6 +240,8 @@ namespace Steinberg
238240
namespace Presonus
239241
{
240242
DEF_CLASS_IID (IPlugInViewEmbedding)
243+
DEF_CLASS_IID (IContextInfoHandler)
244+
DEF_CLASS_IID (IContextInfoProvider)
241245
}
242246

243247
#endif // JUCE_VST3HEADERS_INCLUDE_HEADERS_ONLY

0 commit comments

Comments
 (0)