Value jumps using Skew with NormalizableRange

I’m working on trying to setup a Mod Frequency control that skews the range to make it more usable, but setting the skew value to something that sounds good leads to there being a visible “jump” between the first and second values along the slider as opposed to a smooth movement throughout. I understand the idea is to take the exponentially increasing frequency values and applying a base2 logarithm, but I’m not sure how to use the skew value to do that. Any suggestions greatly appreciated!

auto mod_rate = std::make_unique<juce::AudioParameterFloat>
    (
        juce::ParameterID
        {
            "mod_rate",
            8
        },
        "Mod Rate",
        juce::NormalisableRange<float>(0.1f, 25.0f, 0.01f, 0.3f), // Changed from 0.1f to 0.01f
        0.005f
    );

See

Here is one with an additional mid point setting:

template<typename FloatType>
inline juce::NormalisableRange<FloatType> getLogMidRange(
    const FloatType xMin, const FloatType xMax, const FloatType xMid, const FloatType xInterval) {
    const FloatType rng1{std::log(xMid / xMin) * FloatType(2)};
    const FloatType rng2{std::log(xMax / xMid) * FloatType(2)};
    return {
        xMin, xMax,
        [=](FloatType, FloatType, const FloatType v) {
            return v < FloatType(.5) ? std::exp(v * rng1) * xMin : std::exp((v - FloatType(.5)) * rng2) * xMid;
        },
        [=](FloatType, FloatType, const FloatType v) {
            return v < xMid ? std::log(v / xMin) / rng1 : FloatType(.5) + std::log(v / xMid) / rng2;
        },
        [=](FloatType, FloatType, const FloatType v) {
            const FloatType x = xMin + xInterval * std::round((v - xMin) / xInterval);
            return x <= xMin ? xMin : (x >= xMax ? xMax : x);
        }
    };
}
1 Like

This worked, thanks!