mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
VST3 Host: Refresh parameter info after receiving kParamTitlesChanged
This commit is contained in:
parent
1d90ea72e7
commit
e5c32e3490
1 changed files with 39 additions and 32 deletions
|
|
@ -2290,14 +2290,9 @@ public:
|
|||
//==============================================================================
|
||||
struct VST3Parameter final : public Parameter
|
||||
{
|
||||
VST3Parameter (VST3PluginInstance& parent,
|
||||
Steinberg::int32 vstParameterIndex,
|
||||
Steinberg::Vst::ParamID parameterID,
|
||||
bool parameterIsAutomatable)
|
||||
VST3Parameter (VST3PluginInstance& parent, Steinberg::int32 vstParameterIndex)
|
||||
: pluginInstance (parent),
|
||||
vstParamIndex (vstParameterIndex),
|
||||
paramID (parameterID),
|
||||
automatable (parameterIsAutomatable)
|
||||
vstParamIndex (vstParameterIndex)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -2332,7 +2327,7 @@ public:
|
|||
{
|
||||
Vst::String128 result;
|
||||
|
||||
if (pluginInstance.editController->getParamStringByValue (paramID, value, result) == kResultOk)
|
||||
if (pluginInstance.editController->getParamStringByValue (cachedInfo.id, value, result) == kResultOk)
|
||||
return toString (result).substring (0, maximumLength);
|
||||
}
|
||||
|
||||
|
|
@ -2347,7 +2342,7 @@ public:
|
|||
{
|
||||
Vst::ParamValue result;
|
||||
|
||||
if (pluginInstance.editController->getParamValueByString (paramID, toString (text), result) == kResultOk)
|
||||
if (pluginInstance.editController->getParamValueByString (cachedInfo.id, toString (text), result) == kResultOk)
|
||||
return (float) result;
|
||||
}
|
||||
|
||||
|
|
@ -2356,32 +2351,34 @@ public:
|
|||
|
||||
float getDefaultValue() const override
|
||||
{
|
||||
return (float) getParameterInfo().defaultNormalizedValue;
|
||||
return (float) cachedInfo.defaultNormalizedValue;
|
||||
}
|
||||
|
||||
String getName (int /*maximumStringLength*/) const override
|
||||
{
|
||||
return toString (getParameterInfo().title);
|
||||
return toString (cachedInfo.title);
|
||||
}
|
||||
|
||||
String getLabel() const override
|
||||
{
|
||||
return toString (getParameterInfo().units);
|
||||
return toString (cachedInfo.units);
|
||||
}
|
||||
|
||||
bool isAutomatable() const override
|
||||
{
|
||||
return automatable;
|
||||
return (cachedInfo.flags & Vst::ParameterInfo::kCanAutomate) != 0;
|
||||
}
|
||||
|
||||
bool isDiscrete() const override
|
||||
{
|
||||
return discrete;
|
||||
return getNumSteps() != AudioProcessor::getDefaultNumParameterSteps();
|
||||
}
|
||||
|
||||
int getNumSteps() const override
|
||||
{
|
||||
return numSteps;
|
||||
const auto stepCount = cachedInfo.stepCount;
|
||||
return stepCount == 0 ? AudioProcessor::getDefaultNumParameterSteps()
|
||||
: stepCount + 1;
|
||||
}
|
||||
|
||||
StringArray getAllValueStrings() const override
|
||||
|
|
@ -2391,28 +2388,31 @@ public:
|
|||
|
||||
String getParameterID() const override
|
||||
{
|
||||
return String (paramID);
|
||||
return String (cachedInfo.id);
|
||||
}
|
||||
|
||||
Steinberg::Vst::ParamID getParamID() const noexcept { return paramID; }
|
||||
Steinberg::Vst::ParamID getParamID() const noexcept { return cachedInfo.id; }
|
||||
|
||||
void updateCachedInfo()
|
||||
{
|
||||
cachedInfo = fetchParameterInfo();
|
||||
}
|
||||
|
||||
private:
|
||||
Vst::ParameterInfo getParameterInfo() const
|
||||
{
|
||||
return cachedInfo;
|
||||
}
|
||||
|
||||
private:
|
||||
Vst::ParameterInfo fetchParameterInfo() const
|
||||
{
|
||||
JUCE_ASSERT_MESSAGE_THREAD
|
||||
return pluginInstance.getParameterInfoForIndex (vstParamIndex);
|
||||
}
|
||||
|
||||
VST3PluginInstance& pluginInstance;
|
||||
const Steinberg::int32 vstParamIndex;
|
||||
const Steinberg::Vst::ParamID paramID;
|
||||
const bool automatable;
|
||||
const int numSteps = [&]
|
||||
{
|
||||
auto stepCount = getParameterInfo().stepCount;
|
||||
return stepCount == 0 ? AudioProcessor::getDefaultNumParameterSteps()
|
||||
: stepCount + 1;
|
||||
}();
|
||||
const bool discrete = getNumSteps() != AudioProcessor::getDefaultNumParameterSteps();
|
||||
Vst::ParameterInfo cachedInfo = fetchParameterInfo();
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -3203,6 +3203,13 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void updateParameterInfo()
|
||||
{
|
||||
for (auto& pair : idToParamMap)
|
||||
if (auto* param = pair.second)
|
||||
param->updateCachedInfo();
|
||||
}
|
||||
|
||||
private:
|
||||
void deactivate()
|
||||
{
|
||||
|
|
@ -3361,11 +3368,8 @@ private:
|
|||
|
||||
for (int i = 0; i < editController->getParameterCount(); ++i)
|
||||
{
|
||||
auto paramInfo = getParameterInfoForIndex (i);
|
||||
auto* param = new VST3Parameter (*this,
|
||||
i,
|
||||
paramInfo.id,
|
||||
(paramInfo.flags & Vst::ParameterInfo::kCanAutomate) != 0);
|
||||
auto* param = new VST3Parameter (*this, i);
|
||||
const auto paramInfo = param->getParameterInfo();
|
||||
|
||||
if ((paramInfo.flags & Vst::ParameterInfo::kIsBypass) != 0)
|
||||
bypassParam = param;
|
||||
|
|
@ -3796,6 +3800,9 @@ void VST3HostContext::restartComponentOnMessageThread (int32 flags)
|
|||
if (hasFlag (flags, Vst::kParamValuesChanged))
|
||||
plugin->resetParameters();
|
||||
|
||||
if (hasFlag (flags, Vst::kParamTitlesChanged))
|
||||
plugin->updateParameterInfo();
|
||||
|
||||
plugin->updateHostDisplay (AudioProcessorListener::ChangeDetails().withProgramChanged (true)
|
||||
.withParameterInfoChanged (true));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue