Cannot make work modifier key on VST3 with cubase

Hi,

I use an AudioProcessorValueTreeState object with slider attachment. I’ve a feature that restore the my slider to the default value when I click on it with the alt modifier key.

To achieve this I use the method void mouseUp(const MouseEvent& event) and inspect the event if the alt key is down event.mods.isAltDown(), if it’s true then I restore my slider to the default value:

void MyComponent::mouseUp(const MouseEvent& event) {
  if(event.mods.isAltDown()) {
    const auto parameter = valueTreeState_.getParameter(parameterId_);
    const auto defaultValue = parameter->getDefaultValue();
    parameter->setValue(defaultValue);
  }
}

It works like a charm except on cubase with vst3. When I do that with my slider on a value of X, I see this one going to the default value then going back directly to the previous X value.

If I use the Xcode debugger, and put a break point and do a step by step it seems to work sometime. Really weird… Isn’t a performance issue on vst3?

Does anyone already encounter this issue?

Thanks

Do you need to use setValueNotifyingHost() rather than just setValue()?

You may also need to surround the change with begin/endChangeGesture:

parameter->beginChangeGesture();
parameter->setValueNotifyingHost (defaultValue);
parameter->endChangeGesture();

Thank you so much @martinrobinson-2 it works perfectly! I would never imagine to use this method since it worked with vst2 but not with vst3. Now I know it.

No problem! Much of this is sometimes host-specific, unfortunately. But the above approach seems to persuade most hosts to allow parameter changes, record and playback automation and so on