In this animation here one slider animates smoothly, the other one is jerky - why (both use same graphic)?

I have two sliders that are using the same graphic.
The first one - the Frequency slider - operates very smoothly. Its range is 20Hz - 20000Hz.
The other one has jerky animation. Its range is 0.0f to 1.0f.
Why is that?

Animation

mHPResonance_slider.setTextBoxStyle(juce::Slider::NoTextBox, true, 40, 20);
mHPResonance_slider.setRange(0.0f, 1.0f, 0.01f);
mHPResonance_slider.setValue(audioProcessor.mHPResonance_value);   //set initial value
mHPResonance_slider.setSliderStyle(juce::Slider::RotaryVerticalDrag);
addAndMakeVisible(mHPResonance_slider);
mHPResonance_slider.addListener(this);

My hunch is there is some bug in the valueToText and textToValue conversions in the underlying AudioParameter, so that the mouse movement is somehow not converted into a linear monotonous function…
Or something else happening in your listener…

1 Like

Without knowing the whole code, looks like the good old parameter-changed feedback stuttering.

Maybe you notify the host the slider has changed, and get immediately the message that the value has changed, while the slider (in the movement) is already on a further position.

So you have do add something like this:

// Pseudo code
void parameterChanged(float newVal)
{
    if (!slider->isDragging)
    {
         slider->setVal(newVal)
    }
}
1 Like

Is the 3rd parameter (the step) the same?

Rail

1 Like

I tried inside sliderValueChanged() --PluginEditor.cpp

    else if (slider == &mHPResonance_slider)
    {
        if (!mHPResonance_slider.isMouseOverOrDragging())
        {
            audioProcessor.mHPResonance_value = (float)mHPResonance_slider.getValue();
            
        }

and even also if (!mHPResonance_slider.isMouseButtonDown() && !mHPResonance_slider.isMouseOverOrDragging())
Same issue.
@railjonrogut the step value is 0.01… I tried 0.001.

Check the parameter range for the attached parameter

Rail

createParameterLayout() in PluginProcessor.cpp

    layout.add(std::make_unique<juce::AudioParameterFloat>("mHPResonance", "HP Resonance",
        juce::NormalisableRange<float>(0.0, 1.0, 0.1, 1.0), 0.0));

I’m letting the APVTS update the slider.

@railjonrogut @chkn @daniel
I managed to sort it out - thanks for the input. This did it >

    else if (slider == &mHPResonance_slider)
    {
        if (mHPResonance_slider.isMouseButtonDown())
        {
            auto hpResonanceParam = audioProcessor.apvts.getParameter("mHPResonance");
            hpResonanceParam->setValueNotifyingHost(mHPResonance_slider.getValue());
        }
    }

PluginProcessor.cpp

    layout.add(std::make_unique<juce::AudioParameterFloat>("mHPResonance", "HP Resonance",
        juce::NormalisableRange<float>(0.0, 1.0, 0.01, 1.0), 0.0));

I had 0.1 and it should have been 0.01.

1 Like

cool… You can lose the code:

since the Attachment should initialize those… and they could cause you a headache later while debugging. The SliderAttachment will also update the Slider value notifying the host… so you don’t need the Slider::Listener either.

Rail

2 Likes