Slope freq value

Hi there,

and hello to everybody in the community!

I’m new, and I have a question about param, in Rack.

Usually, on filter, I slope the freq param value exponentially:

v = pow(v, slope) // usually slope = 3.5f

and than I rescale, accordly:

rescale(v, 0.0f, 1.0f, 20.0f, 20000.0f)

For DSP, this works nice. But for GUI? How would I display the value using Rack tools?

I see that now the actual code is this:

// Exponential
v = std::pow(displayBase, v);

and than rescaling:

v * displayMultiplier + displayOffset

but the curve is not the same. And I’m not able to display exactly from 20.0 to 20000.0 hz.

Is there a way to display it as I process later? Or I should inherite the class and made my own sloping function?

Hope you can help me, so I can give to you a virtual beer!

Thanks

What does your config() look like?

There’s not a way to get power scaling with ParamWidget, you’ll have to subclass it.

That’s the question :slight_smile: I don’t know how to fill the displayBase, displayMultiplier and displayOffset to display range 20-20k exponentially correctly.

If I do this (as for VCF):

configParam(FREQ_PARAM, 0.f, 1.f, 0.5f, "Frequency", " Hz", std::pow(2, 10.f), dsp::FREQ_C4 / std::pow(2, 5.f));

it goes from 8.1758 to 8372.02, which is pretty weird.

Thanks for the reply! Is there a way to get exp scale ranging rom 20.0 to 20k?

I think I need to resolve the system:

std::pow(displayBase, v) * displayMultiplier + displayOffset

with v = 0.0 => 20 and v = 1.0 => 20000. Tried using displayMultiplier = 19.53125, which is ok for upper limit, similar to lower (20k and 19.5312)

What works for me:

configParam(FREQ_PARAM, -16.f, 4.f, 1.f, "Freq", " Hz", 2.f, 
    1.f * std::pow(2.f, params[FREQ_PARAM].getValue()));

if I was using lower scale there is no reason why I could not rescale in scope of x

configParam(FREQ_PARAM, -16.f, 4.f, 1.f, "Freq", " Hz", 2.f, 
    1.f * std::pow(2.f, x(params[FREQ_PARAM].getValue())));

The filter scale would be Hz / -1 oct to Hz / 9 oct

I think it was more easy :stuck_out_tongue:

For param:

displayOffset = 0.0f;    
displayMultiplier = 20.0;
displayBase = 1000.0f; 

For DSP:

inline float getFloatParamValueExp(float value, float minValue, float maxValue) {
    value = std::pow(maxValue / minValue, value);

    return value * minValue;
}

Exp instead of pow scaling, but it seems to works nice :wink: What do you think?

if it works, why not!

Not sure why you’re calling params[FREQ_PARAM].getValue() in there. The value of parameters is always 0 in constructors, so you shouldn’t call that.

1 Like

If you’re working with Hz, you should use base 2, since that’s how 1V/oct works.

configParam(..., std::log2(minFreq), std::log2(maxFreq), std::log2(defaultFreq), "", "", 2);

and then

float freq = std::pow(2.f, params[...].getValue() + inputs[...].getVoltage());
1 Like