Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Music Search
KVR

KVR Forum » DSP and Plug-in Development
friendofphi
KVRer
 Posted: Fri May 04, 2012 3:47 pm reply with quote
I'd really like a nice equation to emulate mixer faders. Something that maps a slider 0-1 to a 0-1 gain that has a appropriate logarithmic curve. Efficiency is irrelevant.
^ Joined: 05 Mar 2012  Member: #276393
mystran
KVRAF
 Posted: Fri May 04, 2012 4:20 pm reply with quote
Well, in theory you can simply start with dBgain equation like the following:

gain = 10^(dBgain/20) = exp(log(10) * dbGain/20)

So if the slider position is in decibels (say -80 to +20 or whatever) you'd just plug the decibel gain into to above to calculate gain to apply.

The main problem with using the above directly is that you can't take the gain all the way down to zero. If you want that, you could offset the whole thing down a bit like so:

gain = 10^(dBgain/20) - 10^(dBgainMin/20)

where dBgainMin would be the logarithmic decibel gain at the minimum position (eg -80 in the above). Since 10^(-80/20) = 10^-4 = 0.0001 your "0dB gain" is now 0.9999 or roughly -0.000043dB which is very close to unity, but if you really wanted exact unity at unity-setting then we could fix that too to get the following

gain = (10^(dBgain/20) - 10^(dBgainMin/20)) / (1 - 10^(dbGainMin/20))

This is still really only a single exponential (since the second one is constant) so it's not too inefficient either. You could shape it further if you wanted particular positions to give some particular values, but the above should be rather workable. Basically with "dBgainMin" set to -80, you get very close to logarithmic response from about -60dB up, which then tapers smoothly to linear control at the very bottom of the range.

So the whole thing in pseudo-code (with slider in [0,1]) looks something like:

dBmin = -80
dBmax = +20
range = dBmax - dBmin

zeroShape = 10^(dBmin/20)
unityFix = 1 / (1 + zeroShape)

gain = (10^((range*slider-dBmin)/20)-zeroShape)*unityFix

If you want unity at max value, just set dBmax = 0.
If you want it go towards linear control earlier, set dBmin to a larger value (like -60 or something).
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
rootbear
KVRer
 Posted: Sat May 05, 2012 10:18 am reply with quote
friendofphi wrote:
I'd really like a nice equation to emulate mixer faders. Something that maps a slider 0-1 to a 0-1 gain that has a appropriate logarithmic curve. Efficiency is irrelevant.

if the fader value is 0.0 to 1.0, like the vst stuff I'm using, I just do value * value. Then you can go louder as needed, like * 10.0. But correct me if I'm wrong. I just thought that was the same as an analog volume control.
^ Joined: 07 Feb 2011  Member: #249871
aciddose
KVRAF
 Posted: Sat May 05, 2012 10:30 am reply with quote
no, an "analog control" is usually of the form 1/(1/r1 + 1/r2) but there are major variations.

a lot of db fader tapers go to about -40db and then trail off in a linear taper from there. the log taper can be a mixture of two linearly tapered strips and the equation above applies but there are other methods.

some just say "f*** decibels!" and have two linear sections, a super poor piece-wise linear approximation of the model taper.

with consoles or devices that have displays showing db, generally the faders will match the response of the vu meters or vice-versa.

generally you can assume if the device has a fader label to -50db, the led display shows a 50db range the faders are probably accurate at least to there.

you "can" use 4(n^2) but it feels way different and the labels wouldn't be evenly spaced.
^ Joined: 07 Dec 2004  Member: #50793
rootbear
KVRer
 Posted: Sat May 05, 2012 12:05 pm reply with quote
Well I don't care about models of volume controls I just meant that in general. In other words a formula that goes from 0 to 1 that sounds like the average volume control, though that average may be subjective. Actually your ear's own response would be the goal wouldn't it but back to the subject of the OP, a formula for linear 0.0 - 1.0 converted to logarithmic 0.0 - 1.0.

(10^(x)-1)/9 is all I could come up with based on what was said here, is that correct at least in the sense of the best approximation, or is there another formula I should try.
^ Joined: 07 Feb 2011  Member: #249871
mystran
KVRAF
 Posted: Sat May 05, 2012 3:12 pm reply with quote
rootbear wrote:

(10^(x)-1)/9 is all I could come up with based on what was said here, is that correct at least in the sense of the best approximation, or is there another formula I should try.

That's not very logarithmic at all. You're using the formula I suggested, yes, but that formula has design parameters (namely "range" is the most important one) and you are essentially designing a slider that has nominal 20dB log-range, but tapers to linear at the bottom of that range (compare: I was suggesting around 60 or more nominal range; this makes it look a whole lot different).

That said, I'm not necessary against x*x (I use it for some level controls myself) but it's not really ideal because you have only a little range on top before it start becoming linear (so there's no much accuracy around -40dB for example).
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
antto
KVRAF
- profile
- pm
- www
 Posted: Sat May 05, 2012 3:26 pm reply with quote
here are 3 pot measurements i did from my x0xb0x
the pots are "log" .. but you decide

----
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!
^ Joined: 04 Sep 2006  Member: #118997  Location: 127.0.0.1
mystran
KVRAF
 Posted: Sat May 05, 2012 4:16 pm reply with quote
antto wrote:
here are 3 pot measurements i did from my x0xb0x
the pots are "log" .. but you decide

That's those crappy "two-linear segments" tapers that aciddose mentioned. So whoever sourced the components for your x0x apparently didn't want to pay extra for proper log-pots (apparently there are rumors that such things actually exist).

Anyway, the "linear pot plus shaping resistor" idea is explained here for example. If you're designing new analog circuits, I think that's the easier way to go since you can use a cheap linear pot and still get a smooth response.
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
antto
KVRAF
- profile
- pm
- www
 Posted: Sun May 06, 2012 1:01 am reply with quote
mystran wrote:
..So whoever sourced the components for your x0x apparently didn't want to pay extra for proper log-pots (apparently there are rumors that such things actually exist).

i think the TB-303 uses pots with the same "cheap log" response
----
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!
^ Joined: 04 Sep 2006  Member: #118997  Location: 127.0.0.1
mystran
KVRAF
 Posted: Sun May 06, 2012 9:05 pm reply with quote
antto wrote:
mystran wrote:
..So whoever sourced the components for your x0x apparently didn't want to pay extra for proper log-pots (apparently there are rumors that such things actually exist).

i think the TB-303 uses pots with the same "cheap log" response

No idea to be honest. Unsurprisingly it appears that the originals aren't even made anymore. I found some information regarding 303 pots but that doesn't really talk anything about the log-tapers on the originals. Not that it's such a huge deal, proper log-response mostly just feels nicer.
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
camsr
KVRAF
 Posted: Mon May 07, 2012 1:27 am reply with quote
I wouldn't mind any piecewise linear or hocus pocus function-based fader at all. As long as it was documented with the device I am okay with whatever. The piecewise linear curve would work just fine for a mix fader, and might be preferred in some circumstances.

I love digital! All this stuff is a cinch to create and really adds custom vibe to everything!
----
^ Joined: 16 Feb 2005  Member: #58183
friendofphi
KVRer
 Posted: Thu May 10, 2012 2:12 am reply with quote
I'm going to start with the first post here, I don't really see how converting from db helps, -80db to 20db doesn't match to 0-1.

I'm using the square function, which seems to work nicely. It sounds like it's getting louder in even increments. And I can easily root to do meters. I appreciated that graph, it would be cool to overlay the x^2 on it.
^ Joined: 05 Mar 2012  Member: #276393
Richard_Synapse
KVRist
 Posted: Thu May 10, 2012 2:37 am reply with quote
I often use square as well for volume, unless I have a reason not to (it's also the response most DAWs use, last time I checked).

Richard
----
Synapse Audio Software - www.synapse-audio.com
^ Joined: 19 Dec 2010  Member: #245936
WOK
KVRAF
 Posted: Thu May 10, 2012 2:47 am reply with quote
friendofphi wrote:
I'd really like a nice equation to emulate mixer faders. Something that maps a slider 0-1 to a 0-1 gain that has a appropriate logarithmic curve. Efficiency is irrelevant.

Like the red line here:
http://tinyurl.com/cu7szta   ?
----

Plugins and Music
^ Joined: 24 Feb 2004  Member: #13779  Location: Germany
 KVR Forum Index » DSP and Plug-in Development All times are GMT - 8 Hours Printable version Page 1 of 1