Here's an e-mail I wrote on the VST mailing list talking about how to map VST parameters (in the range 0-1) to other more musically useful values:
[back]
You probably want exp(a*x+b)+c. The reason is that exp() won't quite go down to 0 no matter what the input, and it's probably more convenient to work in the range exp([1,log(2)]) and subtract one. Set a = (log(2)-1); b = 1; c = -1; x = your-input-value-in-the-range-[0,1] actualValueA = exp(a*x+b)+c; This results in an exponential response in the range [0,1] from the range [0,1]. You may also wish to just raise the input to some power, say 2. That would mean: actualValueB = x*x; It serves the same purpose of giving more resolution towards the bottom end, without all the complication :-) You also probably want the inverse values, so that getParameter() can get back a useful value (unless you just cache the input values): invActualValueA = (log(actualValueA-c)-b)/a; invActualValueB = sqrtf( actualValueB ); Another useful response function is the "dB" one with a special case for 0. You map some range of dB; say, (-96,0] to the range (0,1], and treat 0 special as "minus infinity". The functions then look like: dBFromValue = value ? value*96-96 : -INFINITY; gainFromDb = db == -INFINITY ? 0 : pow( 10., db/20. ); valueFromDb = db == -INFINITY ? 0 : (db+96)/96; dbFromGain = gain ? log10( gain ) * 20 : -INFINITY; Cheers, / h+ Disclaimer: I'm doing algebra in my head on a Sunday morning while I'm having some Irish Coffee. > -----Original Message----- > From: VST PlugIns [mailto:vst-plugins@lists.steinberg.net]On Behalf Of > Toby Newman > Sent: Sunday, April 14, 2002 8:36 AM > To: VST PlugIns > Subject: [vst-plugins] Re: A new free VST plugin > > > > > > Maybe you could make the controls a bit more user-friendly, as some of > > the most interesting settings are right at the bottom of the range, so > > you could make them respond logarithmically... y = exp(a * x + b) > > > Paul. > > > Very good idea. Could you extrapolate a little on how this is done? > > y = exp(a * x + b) > > What do each of these letters stand for?