|Exponential parameter mapping|
References : Posted by Russell Borogove
Use this if you want to do an exponential map of a parameter (mParam) to a range (mMin - mMax).
Output is in mData...
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;
Added on : 25/03/02 by rerdavies[ AT ]msn[ DOT ]com
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.
Added on : 05/12/02 by kaleja[ AT ]estarcion[ DOT ]com
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.
Added on : 21/08/03 by act_ion[ AT ]yahoo[ DOT ]com
Just made my day!
pretty useful :) cheers Aktion
Added on : 08/09/06 by agillesp[ AT ]gmail
You can trade an (expensive) ln for a (cheaper) divide here because of the logarithmic identity:
ln(x) - ln(y) == ln(x/y)
|Add your own comment|
Comments are displayed in fixed width, no HTML code allowed!