Old 07-20-2010, 11:58 AM   #1
obstgegenrechz
Human being with feelings
 
obstgegenrechz's Avatar
 
Join Date: May 2007
Posts: 88
Default Logarithmic Volume Fader

Hey People!

i'm looking for a plugin that has got just one slider, which behaves like a Volume-Slider in Reaper's Mixer.

Is there anything like this?

Reason: I wanna map my Midi-Keyboard's Fader to this Parameter to be able to fade out/in totally, not -25dB at the bottom...
obstgegenrechz is offline   Reply With Quote
Old 07-20-2010, 12:27 PM   #2
ngarjuna
Human being with feelings
 
ngarjuna's Avatar
 
Join Date: Apr 2008
Location: Miami
Posts: 2,298
Default

Something like this maybe:

http://www.sonalksis.com/freeg.htm
ngarjuna is offline   Reply With Quote
Old 07-20-2010, 01:17 PM   #3
obstgegenrechz
Human being with feelings
 
obstgegenrechz's Avatar
 
Join Date: May 2007
Posts: 88
Default

thanks!

...but ...
i was searching for a JS-Effect...
can't really code

any hints?
obstgegenrechz is offline   Reply With Quote
Old 07-20-2010, 01:20 PM   #4
ngarjuna
Human being with feelings
 
ngarjuna's Avatar
 
Join Date: Apr 2008
Location: Miami
Posts: 2,298
Default

I made my own JS trim plugin and it was 100% based on code that someone posted in a thread (I'm not a coder either). Let me see if I can track that down, it was really simple and sounds like it would be exactly what you want.
ngarjuna is offline   Reply With Quote
Old 07-20-2010, 01:46 PM   #5
ngarjuna
Human being with feelings
 
ngarjuna's Avatar
 
Join Date: Apr 2008
Location: Miami
Posts: 2,298
Default

Here's the Trim plugin I have been using.

Code:
// This effect Copyright (C) 2004 and later Cockos Incorporated
// License: GPL - http://www.gnu.org/licenses/gpl.html
desc: volume adjustment
slider1:0<-60,24,1>Trim
slider2:0<-150,150,1>max volume (dB)

@slider
  adj1=2 ^ (slider1/6); 
  adj2=2 ^ (slider2/6);
  doseek=1;

@block
doseek ? (
  dadj=(adj1-adj1_s)/samplesblock;
  doseek=0;
):(
  dadj=0;
  adj1_s=adj1;
);

@sample
spl0=min(max(spl0*adj1_s,-adj2),adj2);
spl1=min(max(spl1*adj1_s,-adj2),adj2);
adj1_s+=dadj;
I can't find the thread I snipped that from, unfortunately.

Edit: I can't quite figure out how to disable smilies in Edit Post....the line with the smiley is "End_Parentheses""colon""Start_Parentheses".

Last edited by ngarjuna; 07-20-2010 at 02:37 PM.
ngarjuna is offline   Reply With Quote
Old 07-20-2010, 02:35 PM   #6
Blechi
Human being with feelings
 
Blechi's Avatar
 
Join Date: Apr 2008
Location: Saarlänner
Posts: 1,141
Default

Quote:
Originally Posted by ngarjuna View Post
...
Edit: I can't quite figure out how to disable smilies in Edit Post....the line with the smiley is "End_Parentheses""colon""Start_Parentheses".
Just replace the quote tags by code tags:

Code:
// This effect Copyright (C) 2004 and later Cockos Incorporated
// License: GPL - http://www.gnu.org/licenses/gpl.html
desc: volume adjustment
slider1:0<-60,24,1>Trim
slider2:0<-150,150,1>max volume (dB)

@slider
adj1=2 ^ (slider1/6);
adj2=2 ^ (slider2/6);
doseek=1;

@block
doseek ? (
dadj=(adj1-adj1_s)/samplesblock;
doseek=0;
);(
dadj=0;
adj1_s=adj1;
);

@sample
spl0=min(max(spl0*adj1_s,-adj2),adj2);
spl1=min(max(spl1*adj1_s,-adj2),adj2);
adj1_s+=dadj;
Blechi is offline   Reply With Quote
Old 07-20-2010, 02:37 PM   #7
ngarjuna
Human being with feelings
 
ngarjuna's Avatar
 
Join Date: Apr 2008
Location: Miami
Posts: 2,298
Default

Thanks!
ngarjuna is offline   Reply With Quote
Old 07-21-2010, 05:09 AM   #8
obstgegenrechz
Human being with feelings
 
obstgegenrechz's Avatar
 
Join Date: May 2007
Posts: 88
Default

This Line:
slider1:0<-60,24,1>Trim

... tells me that the volume will be "just" 60dB more quiet. What i'm looking for is a fader that actually Mutes the output

therefore i'm looking for a slider that actually works in a logarithmic way... like the Track-Volume-Faders in Reaper work...

the FreeG-VST-Plugin you mentioned works this way too, but i wonder if there's a way to do it with a JS-Plug...

thanks for your help anyway mate!

joe
obstgegenrechz is offline   Reply With Quote
Old 07-21-2010, 07:17 AM   #9
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

I would simply detect whether the slider has reached its bottom value, and then set the gain to zero:

Code:
slider1:0.0<-60.0,24.0,0.1>Trim

...

@slider

trim = slider1 <= -60.0 ? 0.0 : 2 ^ (slider1 / 6);
True, it would go straight from -59.9dB to -inf without any steps in between, but at -60dB I don't think anyone will notice. If you do think one would notice, then you could always extend the range to e.g. -72.0dB or -150.0dB.
Tale is offline   Reply With Quote
Old 07-22-2010, 04:22 AM   #10
obstgegenrechz
Human being with feelings
 
obstgegenrechz's Avatar
 
Join Date: May 2007
Posts: 88
Default

well but there should be a way to calculate a sliders value into a logarithmic value? .... or is it exponential?

oh maths

is it just the value on the GUI that can just be dislayed in a linear way?
obstgegenrechz is offline   Reply With Quote
Old 07-22-2010, 04:54 AM   #11
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Quote:
Originally Posted by obstgegenrechz View Post
well but there should be a way to calculate a sliders value into a logarithmic value? .... or is it exponential?
I'm not sure if this is what you mean, but you can also do:

Code:
AMP_dB = 8.68588963806504;
trim = exp(slider1 / AMP_DB);
However, this will give you more or less the same results, and of course it still creeps towards zero without ever actually reaching it.
Tale is offline   Reply With Quote
Old 07-22-2010, 05:33 AM   #12
cerberus
Human being with feelings
 
Join Date: Nov 2009
Location: memory
Posts: 633
Default

i'm using : AMP_dB = 8.6858896380650365530225783783321;

in a js...

would it be more accurate to generally use the value tale posted (same, but
only to 14 places, with the 14th decimal place digit rounded up from "3" to "4" )?
cerberus is offline   Reply With Quote
Old 07-22-2010, 07:13 AM   #13
Mich
Human being with feelings
 
Join Date: May 2009
Posts: 1,265
Default

Code:
// This effect Copyright (C) 2004 and later Cockos Incorporated
// License: GPL - http://www.gnu.org/licenses/gpl.html
desc: volume
slider1:1<0,1,0.01>Trim

@slider
adj1 = slider1;
doseek=1;

@block
doseek ? (
dadj=(adj1-adj1_s)/samplesblock;
doseek=0;
);(
dadj=0;
adj1_s=adj1;
);

@sample
spl0=spl0*adj1_s;
spl1=spl1*adj1_s;
adj1_s+=dadj;
Mich is offline   Reply With Quote
Old 07-25-2010, 03:39 AM   #14
obstgegenrechz
Human being with feelings
 
obstgegenrechz's Avatar
 
Join Date: May 2007
Posts: 88
Default

Awesome Mich!!!
this works perfect for now

thanks heaps!
obstgegenrechz is offline   Reply With Quote
Old 04-07-2011, 11:34 AM   #15
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

Resurrecting an old thread here, sorry... but I'm trying to get my head around how this code really works, because I don't get it. This is supposed to be a logarithmic volume fader, right?

Quote:
Originally Posted by Mich View Post
Code:
// This effect Copyright (C) 2004 and later Cockos Incorporated
// License: GPL - http://www.gnu.org/licenses/gpl.html
desc: volume
slider1:1<0,1,0.01>Trim

@slider
adj1 = slider1;
doseek=1;

@block
doseek ? (
dadj=(adj1-adj1_s)/samplesblock;
doseek=0;
);(
dadj=0;
adj1_s=adj1;
);

@sample
spl0=spl0*adj1_s;
spl1=spl1*adj1_s;
adj1_s+=dadj;
A change of the slider is evenly distributed over a whole samplesblock number of samples, right?

That is, say slider1 is at its initial value 1, and I move it to 0.7. Then at the following invocation of the @block code,
dadj is set constant at -0.3/samplesblock, and this constant increment is added to adj1_s on each sample. Right?

Now, if I move the fader further down to 0.4, again the increment dadj is set to -0.3/samplesblock,
so irrespective of where I am on the scale, I get the same increment over the same number of samples.

So, how is this a logarithmic fader? To me it looks linear...

What am I missing?
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 04-08-2011, 08:32 AM   #16
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Indeed it is not logarithmic. But it does go all the way down to zero, which was one of the requirements of obstgegenrechz.
Tale is offline   Reply With Quote
Old 04-08-2011, 09:49 AM   #17
Mich
Human being with feelings
 
Join Date: May 2009
Posts: 1,265
Default

The fader is logarithmic ... in the common sense of definition of faders in the audio world anyway. Usually fader's scaling is linear in dB value. dB's are a logarithmic representation of the amplitude. So you want a logarithmic fader you just ditch converting dBs to a linear fader (the only fader type JS provides) and use the amplitude value (ranging from 0 to 1 "slider1:1<0,1,0.01>Trim") straight away, which will give you a fader that will behave like a logarithmic dB fader, with the drawback you don't get dB markings but raw amplitude values instead.

The value smoothing for changes however is linear interpolation.
Mich is offline   Reply With Quote
Old 04-12-2011, 04:23 AM   #18
antiClick
Human being with feelings
 
antiClick's Avatar
 
Join Date: Mar 2007
Location: Mediterrenean Sea
Posts: 977
Default

Maybe you are interested in this old request

http://forum.cockos.com/project.php?issueid=1994
antiClick is offline   Reply With Quote
Old 04-12-2011, 06:25 AM   #19
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
Default

Quote:
Originally Posted by Mich View Post
So you want a logarithmic fader you just ditch converting dBs to a linear fader (the only fader type JS provides) and use the amplitude value (ranging from 0 to 1 "slider1:1<0,1,0.01>Trim") straight away, which will give you a fader that will behave like a logarithmic dB fader.
OK, so linear in gain is logarithmic in dB... I guess that's true, and you are probably right that this is the common sense. But I may not be so common then... as I've always though "logarithmic" refers to logarithmic in gain (which would be linear in dB, right?)

That is, the output gain is logarithmically related the position of the fader, so that if I move the fader a specific distance (or angle) from x0 to x1, it raises/lowers the output by an amount dependent on the specific position of x0 on the scale; larger inc/decrements at the upper scale and smaller inc/decrements as we reach the lower scale. Just as shown here:

(from http://sound.westhost.com/pots.htm)

Or maybe I'm just seriously confused here. If so, please enlighten me...
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...

Last edited by Fabian; 04-12-2011 at 06:53 AM.
Fabian is offline   Reply With Quote
Old 04-12-2011, 09:41 AM   #20
l0calh05t
Human being with feelings
 
l0calh05t's Avatar
 
Join Date: Nov 2008
Location: Darmstadt, Germany
Posts: 673
Default

Quote:
Originally Posted by Fabian View Post
Or maybe I'm just seriously confused here. If so, please enlighten me...
Nope, you're right, Mich is wrong. The posted JS is indeed a linear fader. The problem with the original request is that there is no such thing as a logarithmic fader that goes to absolute zero, as that would by -infinity decibels.
__________________
Raw data for raw nerves | 1.05946309...
My Blog | My free VST plugins | WDL-OL CMake fork
l0calh05t is offline   Reply With Quote
Old 04-12-2011, 12:34 PM   #21
Mich
Human being with feelings
 
Join Date: May 2009
Posts: 1,265
Default

Quote:
Originally Posted by Fabian View Post
OK, so linear in gain is logarithmic in dB... I guess that's true, and you are probably right that this is the common sense. But I may not be so common then... as I've always though "logarithmic" refers to logarithmic in gain (which would be linear in dB, right?)
Yes, that thing is indeed a linear _gain_ fader.

I was more trying to say that usually faders are commonly linear in dB (which is a logarithmic mapping from gain, thus a logarithmic _gain_ fader), that is you move 1 unit the gain changes by x dB (which is a change of 10^(x/20) in gain) you move 2 units it changes by 2*x dB (which is a 10^(2*x/20) gain change), etc ... and if you the apply a logarithmic mapping to that linear dB fader (which itself is a logarithmic mapping of gain) you'd get a logarithmic logarithmic fader ... and that's the part where I got confused because if you simply drop the dB conversion you'd actually end up with an _exponential_ _dB_ fader, which of course is a linear gain fader, and not like I proclaimed a logarithmic dB fader (which does not exist because dB is mostly negative and log only defined for positive values).
Anyway sorry for the confusion ... it seems I'm confused about this myself .
Mich is offline   Reply With Quote
Old 04-12-2011, 12:44 PM   #22
Mich
Human being with feelings
 
Join Date: May 2009
Posts: 1,265
Default

Code:
// This effect Copyright (C) 2004 and later Cockos Incorporated
// License: GPL - http://www.gnu.org/licenses/gpl.html
desc: volume
slider1:1<0,1,0.01>Trim

@slider
adj1 = slider1 <= 0 ? 0 : exp(4 /* <-- shape factor */  *log(slider1)/log(10));
doseek=1;

@block
doseek ? (
dadj=(adj1-adj1_s)/samplesblock;
doseek=0;
);(
dadj=0;
adj1_s=adj1;
);

@sample
spl0=spl0*adj1_s;
spl1=spl1*adj1_s;
adj1_s+=dadj;
This now should be logarithmic. Though the interpolation of the value changes is still linear.

Last edited by Mich; 04-12-2011 at 12:46 PM. Reason: fixed special case slider1<=0
Mich is offline   Reply With Quote
Old 04-12-2011, 02:49 PM   #23
l0calh05t
Human being with feelings
 
l0calh05t's Avatar
 
Join Date: Nov 2008
Location: Darmstadt, Germany
Posts: 673
Default

it isn't logarithmic, but a power law (or root law, depending on which side you look at it from)

exp(4*log(x)/log(10)) = x^(4/log(10))
__________________
Raw data for raw nerves | 1.05946309...
My Blog | My free VST plugins | WDL-OL CMake fork

Last edited by l0calh05t; 04-12-2011 at 03:02 PM.
l0calh05t is offline   Reply With Quote
Old 01-25-2012, 08:40 AM   #24
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Hello!

I just found this thread as I was looking for a trim plugin that I could use with the foot pedals of my FCB1010.
I use Mich's code with only one small change:
slider1:1<0,1,0.0078125>Trim
This value is 1/128, so it coincides better to the 128 steps [0-127] that any MIDI CC has.

The problem is that FCB1010's action is not very smooth, so it doesn't produce a smooth line of CCs, resulting in some kind of zipper noise/distortion when moving the fader with the foot.

Is it possible to make a small addition to this code that would make the movement of the fader more smooth? Unfortunately, I have no idea on programming so I can't do it myself!

The idea for a smoother movement of the fader is this:
We need an additional slider for a TIME value (in ms). The TIME value sets the time that it takes the fader to move from max position to min position and vice versa.
For example for TIME=500ms, then if the trim slider was at max position (value of 1.0 - no trim) and suddenly received a message for the min position (0.0 - mute), then it should not jump directly to that value but should slide passing from all the in-between values arriving at the min position after 500ms.
Any change from one value to another should be proportional.
For example for TIME=500ms, then a change from value 0.75 of the trim slider to value 0.25 (which is a difference of 0.50, half of 1.0) should take half of 500ms, thus 250ms. Another example: from value 0.15 to value 0.25 (a difference of 0.10, which is 10% of 1.0) should take 10% of 500ms, thus 50ms.

Could someone code this? Mich?

Thank you for your time!

Last edited by amagalma; 01-25-2012 at 08:45 AM.
amagalma is offline   Reply With Quote
Old 01-25-2012, 12:02 PM   #25
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

What you are proposing is possible, but:

Quote:
Originally Posted by amagalma View Post
The problem is that FCB1010's action is not very smooth, so it doesn't produce a smooth line of CCs, resulting in some kind of zipper noise/distortion when moving the fader with the foot.
Actually I think the zipper noise is caused by a small typo in the code:

Code:
doseek ? (
dadj=(adj1-adj1_s)/samplesblock;
doseek=0;
):( // <-- Replaced the semicolor with a colon
dadj=0;
adj1_s=adj1;
);
Tale is offline   Reply With Quote
Old 01-25-2012, 01:32 PM   #26
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Quote:
Originally Posted by amagalma View Post
We need an additional slider for a TIME value (in ms). The TIME value sets the time that it takes the fader to move from max position to min position and vice versa.
Here you go:

Code:
// This effect Copyright (C) 2004 and later Cockos Incorporated
// License: GPL - http://www.gnu.org/licenses/gpl.html

desc:Smooth volume
slider1:1<0,1,0.007874>Trim
slider2:500<0,10000,1>Time (ms)

@init

shape = 4;

dt = 1/srate;
adj_s = 1;

@slider

adj = slider1 <= 0 ? 0 : exp(shape * log10(slider1));
rc = 0.2 * max(slider2 * 0.001, samplesblock / srate);
a = dt / (rc + dt);

@sample

adj_s += a * (adj - adj_s);
!adj && !adj_s ? adj_s = adj;

spl0 *= adj_s;
spl1 *= adj_s;
Tale is offline   Reply With Quote
Old 01-25-2012, 09:29 PM   #27
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

THANK YOU !!! You rock!!! ))

I am going to try it tomorrow!
amagalma is offline   Reply With Quote
Old 01-27-2012, 12:50 AM   #28
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I tried it and it works perfectly! Thank you very much again!

P.S. I fine tuned the slider values to my liking as follows:
slider1:1<0,1,0.0078125>Trim
slider2:650<50,3000,50>Inertia Time (ms)
amagalma is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.