1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

VST3 Client: Add support for IParameterFinder interface

This allows hosts such as Cubase and MultitrackStudio to locate
parameters based on the current mouse position.

Users must override and implement getControlParameterIndex in order for
the parameter to be reported to the host.

The DSPModulePluginDemo shows one possible strategy for implementing
this function.
This commit is contained in:
reuk 2024-04-29 18:07:17 +01:00
parent c4652ef7bc
commit c5b428dfe9
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
3 changed files with 78 additions and 3 deletions

View file

@ -1620,6 +1620,15 @@ public:
ladderControls);
}
/* Called by VST3 and AAX hosts to determine which parameter is under the mouse. */
int getControlParameterIndex (Component& comp) override
{
if (auto* parent = findParentComponentWithParamMenu (&comp))
return parent->getParameterIndex();
return -1;
}
private:
class ComponentWithParamMenu : public Component
{
@ -1636,11 +1645,27 @@ private:
.withMousePosition());
}
int getParameterIndex() const
{
return param.getParameterIndex();
}
private:
AudioProcessorEditor& editor;
RangedAudioParameter& param;
};
static ComponentWithParamMenu* findParentComponentWithParamMenu (Component* c)
{
if (c == nullptr)
return nullptr;
if (auto* derived = dynamic_cast<ComponentWithParamMenu*> (c))
return derived;
return findParentComponentWithParamMenu (c->getParentComponent());
}
class AttachedSlider final : public ComponentWithParamMenu
{
public:

View file

@ -1740,7 +1740,8 @@ private:
//==============================================================================
class JuceVST3Editor final : public Vst::EditorView,
public Steinberg::IPlugViewContentScaleSupport,
public Vst::IParameterFinder,
public IPlugViewContentScaleSupport,
private Timer
{
public:
@ -1759,7 +1760,10 @@ private:
tresult PLUGIN_API queryInterface (const TUID targetIID, void** obj) override
{
const auto result = testFor (*this, targetIID, UniqueBase<IPlugViewContentScaleSupport>{});
const auto result = testForMultiple (*this,
targetIID,
UniqueBase<Vst::IParameterFinder>{},
UniqueBase<IPlugViewContentScaleSupport>{});
if (result.isOk())
return result.extract (obj);
@ -2042,7 +2046,48 @@ private:
#endif
}
tresult PLUGIN_API findParameter (int32 xPos, int32 yPos, Vst::ParamID& resultTag) override
{
if (const auto paramId = findParameterImpl (xPos, yPos))
{
resultTag = *paramId;
return kResultTrue;
}
return kResultFalse;
}
private:
std::optional<Vst::ParamID> findParameterImpl (int32 xPos, int32 yPos) const
{
auto* wrapper = component.get();
if (wrapper == nullptr)
return {};
auto* componentAtPosition = wrapper->getComponentAt (xPos, yPos);
if (componentAtPosition == nullptr)
return {};
auto* editor = wrapper->pluginEditor.get();
if (editor == nullptr)
return {};
const auto parameterIndex = editor->getControlParameterIndex (*componentAtPosition);
if (parameterIndex < 0)
return {};
auto processor = owner->audioProcessor;
if (processor == nullptr)
return {};
return processor->getVSTParamIDForIndex (parameterIndex);
}
void timerCallback() override
{
stopTimer();

View file

@ -94,7 +94,12 @@ public:
If the given component represents a particular plugin parameter, then this
method should return the index of that parameter. If not, it should return -1.
Currently only AAX plugins will call this, and implementing it is optional.
If not overridden, this will return -1 for all components.
This function will be called by the host in AAX and VST3 plug-ins in order to map
screen locations to parameters. For example, in Steinberg hosts, this enables the
"AI Knob" functionality, which enables hardware to control the parameter currently
under the mouse.
*/
virtual int getControlParameterIndex (Component&);