Map value in a range with skew factor

Hi all!

I would like to map a value in a [-1, 1] range into another range (like [100, 16000]) which has a reference skew factor. I saw that the jmap functions can do this in linear ranges without skew factors.

How could I achieve this?

Thank you very much!

juce::NormalisableRange is very useful for skewed ranges. For example:

juce::NormalisableRange<float> targetRange {100.0f, 16000.0f};
range.setSkewForCentre (500.0f);

const juce::NormalisableRange<float> sourceRange {-1.f, 1.f};
const auto sourceValue = 0.5f;

const auto normalisedValue = sourceRange.convertTo0to1 (sourceValue);

const auto targetValue = targetRange.convertFrom0to1 (normalisedValue);
1 Like

Thank you @ImJimmi !

Just read about the convertTo0to1 and convertFrom0to1 function. Very nice and useful! Thanks :slight_smile:

1 Like