Swapping min/max value on slider

Hi,

I’m looking to swap the min/max values on some sliders in my plugin, similar to how the Q Parameter functions in Brainworx’s SSL Channel Strip:

I’ve managed to draw the slider in reverse and calculate the desired value in processBlock() using the following code:

float parameterValue = apvts.getParameterRange(parameter_id.getParamID()).end - parameterParam->load() + apvts.getParameterRange(parameter_id.getParamID()).start;

Now I have the following difficulties:

  1. In juce::AudioProcessorValueTreeState::ParameterLayout, if the default value was the maxValue before, it now has to be the minValue. This makes sense but feels a bit odd to me—though it’s an easy fix.
  2. In the DAW, the parameter shows a different value than in my plugin. For example, my plugin might show 3.5 while the DAW shows 0.5 because I’m interpreting the value differently in my plugin.

How can I address these discrepancies? Would it be better to implement this functionality differently altogether?

Revert to the usual initialization, drawing, and value calculations, and try this instead:

class Slider_reverse : public JUCE_NAMESPACE::Slider
{
public:
	Slider_reverse (const String& componentName): JUCE_NAMESPACE::Slider(componentName) {};
	~Slider_reverse() {};
	double proportionOfLengthToValue (double proportion) override {   return JUCE_NAMESPACE::Slider::proportionOfLengthToValue(1.0f-proportion);};
	double valueToProportionOfLength (double value) override {   return 1.0f-(JUCE_NAMESPACE::Slider::valueToProportionOfLength(value)); };
};

Which should reverse the direction of the min/max without the problems you observed.

2 Likes