iPlug2 Forum

How do I get the control that a Param belongs to?

I am aiming to perform an attached network sending action to a Control that sends also when the DAW is automating the control. I understood I need to override OnParamChangeUI

void NELVirtualControlSurface::OnParamChangeUI(int paramIdx, iplug::EParamSource source = iplug::kUnknown) {     // Set dirty (true) on the Control this parameter belongs to
}

But I am confused about how to identify which Control the param belongs to, in order to SetDirty(true) on it.

That’s probably not quite what you want to do.

I suspect you want to use SendParameterValueFromDelegate to send to the GUI. Note that this call does not set the parameter itself - if you need to do that I think you probably also want to call SetParameterValue (that call will do all the things that you’d need to do, such as informing the host).

So I think what you want is:
SetParameterValue() // Load parameter into engine
SendParameterValueFromDelegate() // Update GUI

This assumes that you actually want to modify a parameter updating the control at the same time, rather than work on the control. Also, this assumes that your network code is with the engine (not the UI) in the case of a distributed design, which is I think the design you’d want. @olilarkin may be able to be more specific.`

Also - whilst you are here, sorry to cross threads, but could you look at this? https://github.com/iPlug2/iPlug2/issues/600

OK, I am trying to understand how to do as you suggest. I don’t really understand what this is telling me to do, from the docs to SPVFD …

* If you override this method you should call the base class implementation to make sure OnParamChangeUI gets triggered

I should call the base class implementation of what?

The comment is about overriding (providing an implementation for a virtual method). What I am suggesting here is that you call SPVFD, so the comment doesn’t apply.

Ah ok… so I don’t need to override and implement SPVFD. Actually that puzzles me more. The semantics are confusing; SendParameterValueFromDelegate() … what is Sending to where from Delegate?

Is this call basically a Getter ? Sorry I am a bit green with C++ and iPlug2, but I still think semantically this could be clearer

SendParameteValueFromDelegate() can be thought of as sending the value to the GUI part of the plugin from the engine - that is it’s normal use. In that sense is can be considered a setter that acts on the GUI. SetParameterValue() is a setter for the engine. The “delegate” is the part of the plug-in that communicates with the GUI - this is because for some types of plug-ins the GUI and the engine are separate (or even on separate computers for networking stuff) - but that is not always the case. For non-distributed plugins these things all exist within the same plug-in.

Ok, thanks for explaining , it’s getting a little clearer now!

Good! Hope it all works out!

OK. So I am at a stage where Reaper automation does in fact move the values in the iPlug UI.

If the user does this with the mouse, the attached action sends OSC messages. But the automation doesn’t. I tried

 IGraphics* pGraphics = GetUI(); 
pGraphics-> GetDelegate()->DirtyParametersFromUI();

in overridden OnIdle() of the main plug in Class. Should this be dirtying the parameters from the Delegate, and thereby triggering the OSC actions?

Actions are the wrong place for sending OSC, if you want it both triggered by the control and automation. Actions are things that happen in response to UI interactions, such as moving a slider or pressing a button.

You should move the OSC sending stuff to OnParamChangeUI(), and send OSC messages in response to parameter changes there (i think ideally you may want to use another thread for sending the network messages, but maybe don’t worry about that for now). That will also fire when you change a control that is linked to a parameter.

Thanks @olilarkin . I have refactored as you suggested and its kind of working fine. When a param is being automated/captured, does iPlug2 allow for temporary override when the user changes an automated parameter?

When you click a control that is associated with a parameter, iPlug2 calls a “beginParamChange” method of the plugin API, and when you release the mouse it calls “endParamChange”. VST, AU etc use these methods to let the host disable its automation when the user is interacting with the plug-in GUI