karota
July 10, 2021, 6:45pm
1
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
karota
July 15, 2021, 9:05am
3
Thank you @ImJimmi !
Just read about the convertTo0to1 and convertFrom0to1 function. Very nice and useful! Thanks
1 Like