mouseDown / mouseDrag won't write automations in Logic?

Hi there, I am struggling here with an issue that only seems to happen in Logic (Reaper, PT, Cubase and Nuendo work fine).

I created a custom XY pad in a component, where basically when the user clicks in the area, I write the X and Y position of the click to a slider using slider.setValue().

The pad works perfectly FINE in all DAWs, and automating through the DAWs also works perfectly fine, HOWEVER, when I am drawing the automation in the GUI, in logic, it completely ignores the automation.

This only happens if I automate through clicking on the pad… if I automate through logic (drawing the curves), everything works fine.

The way I am implemented the pad is as follows:

I use onMouseDown and onMouseDrag to set X and Y slider values through x_slider.setValue() and y_slider.setValue()

        //if mouse is in the area
        if (event.getPosition().getX() > 0
            && event.getPosition().getY() > 0
            && event.getPosition().getX() < getWidth()
            && event.getPosition().getY() < getHeight()
            )
        {
            //get x and y positions
            x_position = event.getPosition().getX();
            y_position = event.getPosition().getY();

            //set x slider value
            if (x_slider.getValue() != x_position / (getWidth()/2)-1)
                x_slider.setValue(x_position / (getWidth()/2)-1);

            //set y slider value
            if (y_slider.getValue() != (-y_position / (getHeight()/2)+1))
                y_slider.setValue(-y_position / (getHeight()/2)+1);
            
            //repaint pad
            thumbPoint.setXY(x_position, y_position);
            repaint();

Then, to reflect the changes done through automations, I have the onValueChanged method of the sliders repainting the pad.

        //get x and y slider values and convert them to x and y locations
        auto temp_x = (x_slider.getValue()+1)*(getWidth()/2);
        auto temp_y = (1-y_slider.getValue())*(getHeight()/2);

       //if positions are different from previous positions, proceed to update
        if (thumbPoint.getX() != temp_x || thumbPoint.getY() != temp_y)
            thumbPoint.setXY(temp_x, temp_y);
        
        repaint();

Everything works perfectly fine, everywhere, but on Logic… any ideas?

Logic version is 10.7.

In Logic,
It seems you always need to call beginChangeGesture() and endChangeGesture() in order for things to register properly.

https://docs.juce.com/master/classAudioProcessorParameter.html#aae70f0cce34b664206323bc277096ddc

1 Like

in cubase too. but i’d be surprised if slider.setValue() didn’t send a proper gesture

Apologies for the somewhat silly question (total noob here), but how am I supposed to implement this?
I tried doing so like

    void mouseDown (const juce::MouseEvent& event) override
    {
        //XY CODE
       //......
       //XY CODE ENDS

        juce::AudioProcessorParameter::beginChangeGesture();
    }

and to “end” the gesture in mouseUp, but obviously I am doing something wrong as I cannot compile?

This is not a static method, it is a method of the parameter.
So you need to call it on your parameter(s).
myParam.beginChangeGesture()

Hmmm… x_slider.beginChangeGesture(); wont work either.

Am I supposed to call this method in the AudioProcessor?

On the parameter that is controlled by the slider.

So I’m a bit lost - the parameter is in the apvts in the audioprocessor - how can i reach it from the editor’s mouseDown method?

Thanks for the patience :slight_smile:

No problem!
Well, you had to access the parameter via an ID to link it to a slider, right? Probably passing the APVT to a SliderAttachment along with the parameter ID?
So in mouseDown and mouseUp you can call getParameter on your APVT. So it would give you something like for mouseDown

if ( auto* myParam = myApvt.getParameter( myParamID ) )
    myParam->beginChangeGesture();
1 Like

OMG YES! You’re the best! This works now!

I added the “begin” on mouseDown and the “end” on mouseUp, and now logic WORKS!

Do you reckon for whatever reason might be important to add a setValueNotifyingHost on the mouseDrag? doesn’t seem to be needed but who knows…

Good :slight_smile:
Yes it is important, setValueNotifyingHost is what informs the host (Logic) that the value changed (to create a new point in the automation)

Weird, because without it, it seems to work perfectly fine! Oh, well, I’ll add it non the less -thanks SO much!