# Scaling Question

## Recommended Posts

Hi guys, If my base is 440.0 and one level below is half and one level above is double I have 220.0...440.0...880.0, how do I map [-1.0,1.0] (or [0.0,1.0]) to that ? I'm confused because it's not linear. Thanks.

##### Share on other sites
Zipster    2359
First use a logarithmic mapping to get a linear range, and then map that to whatever other range you want. So if you had 220, 440, and 880, map that to log2(220) = 7.78, log2(440) = 8.78, and log2(880) = 9.78. Your're minimum could be log2(1) = 0, and your maximum could be log2(1048576) = 20, which you map to [-1, 1] or [0, 1] using standard linear shifting/scaling techniques.

##### Share on other sites
alvaro    21247
Quote:
 Original post by EndemoniadaIf my base is 440.0 and one level below is half and one level above is double I have 220.0...440.0...880.0, how do I map [-1.0,1.0] (or [0.0,1.0]) to that ? I'm confused because it's not linear.

#include <math.h>double frequency(double octaves_from_A4){  return 440.0 * pow(2.0, octaves_from_A4);}

##### Share on other sites
Thanks a lot guys, now I can make a logarithmic slider.