How do you calculate a bipolar exponential Slider skew?


#1

Hi:

I am trying to change the behavior of one of my sliders to have a bipolar exponential skew. In other words, the slider should go from -value to +value, with the middle value at zero, and an exponential increase in the value as you go away from the mid value, with the sign added on as needed.

It is probably easier to explain this with some code. This calculates a bipolar exponential warping that goes from -maxValue to maxValue, with a bit of a “dead zone” around the center of the slider value:

if(sliderValue>0.501f) displayValue=0.02f*powf(10.f, (1.f/0.499f)*(sliderValue-0.501f)*log10f(maxValue/0.02f)); else if (sliderValue<0.499f) displayValue=-0.02f*powf(10.f, (1.f/0.499f)*(0.499f-sliderValue)*log10f(maxValue/0.02f)); else displayValue=0.0f;

So, is there any way to do this with the existing Slider class, with some version of the Slew functions that I don’t know about? Or should I create my own subclass of the Slider class to perform this function?

Thanks,

Sean Costello


#2

I’m not aware how to do bipolar skew with the actual slider implementation.
i made my own subclass for that purpose.

btw.
For arbitrary shapes of x, between 0…1, try this to get rid of expensive math functions:

y = x / (x + (1 - (1/shape)) * (x - 1));

where:
shape = 0.5 -> lin
shape > 0.5 -> log
shape < 0.5 -> exp

Just plot it in Excel/Gnuplot or so to get the hang of it.
with some modifications you can use this as well for bipolar skew.

comboy


#3

Hi comboy,

I think that subclassing is the way to go. I came across the proportionOfLengthToValue() and valueToProportionOfLength() virtual functions in the Slider class definition, and these might be useful for creating the warpings I am looking for. It might be useful to add min, max and default values as members of the subclass data structure, with the appropriate set and get functions, and use these to calculate the translation of the “real world” slider values to values that work for VST and RTAS.

I’ll graph out your functions in Excel to see how they match the math library functions. As these would be for the UI only, I’m not sure how often they would be called. I tend to use the “pure” transcendentals in my internal calculations, but with a check to see if the value has changed and needs to be recalculated.

Thanks,

Sean Costello