[SOLVED] Proper way to connect XY-pad to Knobs

So I have this custom XY pad, which is connected to two juce::Sliders (knobs) as follows:

The OnValueChange() lambda of the knobs is set so it will trigger the XY-pad to set the new value onto the handle.

The XY Pad is set up to call Slider::setValue() when the user interacts with the pad via mouse.

What’s happening now is when I use the XY-Pad, it calls the Slider, which calls the lambda I set, which updates the value on the XY pad. The result is very jerky motion. (interestingly this is only the case with one hos so far…)

So I tried to circumvent this by setting the setValue() with the dontSendUpdate flag. So now it only updates the graphics and sends no update. Then I tried to set the audio paramaeter on the AudioProcessorValueTreeState by hand like so:

value_tree.state.setProperty("xy_x",  new_value, nullptr);

But as far as I can tell this still triggers the lambda.

So I need one of two things:

  • A way to set the value on the valuetree without triggering OnValueChange()
  • A pendant for OnValueChange which is only triggered when I turn a knob, not when I set Values manually

Anyone with an idea?

1 Like

Ok I found a rather simple solution, where I lock the setX() and setY() functions of the pad on mouseDown() and unlock them on mouseUp() :slightly_smiling_face: