i'd like to model my lfo rate param like:
0.0f (min value) => 0.01 hz
0.5f (default value) => 5.01 hz
1.0f (max value) => 20.0 hz
but i'm not able to get those values.
here's my attempt:
Code: Select all
const float base = 20.0f;
float min = 0.01f;
float vMin = log(min) / log(base);
std::cout << vMin << " | " << std::pow(base, vMin) << std::endl;
float max = 20.0f;
float vMax = log(max) / log(base);
std::cout << vMax << " | " << std::pow(base, vMax) << std::endl;
float middle = rescale(0.5f, 0.0f, 1.0f, vMin, vMax); // 5.01hz
std::cout << middle << " | " << std::pow(base, middle) << std::endl;
1. middle position is 0.447214 (not 5.01)
2. scale is not [0.0, 1.0f] anymore
i think im overcomplicated such a easy thing...
EDIT: the same scale should applied for this kind of range, which looks pretty the same:
0 => 0
0.5 => 5.0
1 => 20
or
0 => 0.01
0.5 => 2.51
1 => 10