Exponential parameter mapping

References : Posted by Russell Borogove
Notes :
Use this if you want to do an exponential map of a parameter (mParam) to a range (mMin - mMax).
Output is in mData...
Code :
float logmax = log10f( mMax );
float logmin = log10f( mMin );
float logdata = (mParam * (logmax-logmin)) + logmin;

mData = powf( 10.0f, logdata );
if (mData < mMin)
  mData = mMin;
if (mData > mMax)
  mData = mMax;

from : rerdavies[AT]msn[DOT]com
comment : No point in using heavy functions when lighter-weight functions work just as well. Use ln instead of log10f, and exp instead of pow(10,x). Log-linear is the same, no matter which base you're using, and base e is way more efficient than base 10.

from : kaleja[AT]estarcion[DOT]com
comment : Thanks for the tip. A set of VST param wrapper classes which offers linear float, exponential float, integer selection, and text selection controls, using this technique for the exponential response, can be found in the VST source code archive -- finally.

from : act_ion[AT]yahoo[DOT]com
comment : Just made my day! pretty useful :) cheers Aktion

from : agillesp[AT]gmail
comment : You can trade an (expensive) ln for a (cheaper) divide here because of the logarithmic identity: ln(x) - ln(y) == ln(x/y)