|
|
|
07-20-2010, 11:58 AM
|
#1
|
Human being with feelings
Join Date: May 2007
Posts: 88
|
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...
|
|
|
07-20-2010, 12:27 PM
|
#2
|
Human being with feelings
Join Date: Apr 2008
Location: Miami
Posts: 2,298
|
|
|
|
07-20-2010, 01:17 PM
|
#3
|
Human being with feelings
Join Date: May 2007
Posts: 88
|
thanks!
...but ...
i was searching for a JS-Effect...
can't really code
any hints?
|
|
|
07-20-2010, 01:20 PM
|
#4
|
Human being with feelings
Join Date: Apr 2008
Location: Miami
Posts: 2,298
|
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.
|
|
|
07-20-2010, 01:46 PM
|
#5
|
Human being with feelings
Join Date: Apr 2008
Location: Miami
Posts: 2,298
|
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.
|
|
|
07-20-2010, 02:35 PM
|
#6
|
Human being with feelings
Join Date: Apr 2008
Location: Saarlänner
Posts: 1,141
|
Quote:
Originally Posted by ngarjuna
...
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;
|
|
|
07-20-2010, 02:37 PM
|
#7
|
Human being with feelings
Join Date: Apr 2008
Location: Miami
Posts: 2,298
|
Thanks!
|
|
|
07-21-2010, 05:09 AM
|
#8
|
Human being with feelings
Join Date: May 2007
Posts: 88
|
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
|
|
|
07-21-2010, 07:17 AM
|
#9
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
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.
|
|
|
07-22-2010, 04:22 AM
|
#10
|
Human being with feelings
Join Date: May 2007
Posts: 88
|
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?
|
|
|
07-22-2010, 04:54 AM
|
#11
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Quote:
Originally Posted by obstgegenrechz
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.
|
|
|
07-22-2010, 05:33 AM
|
#12
|
Human being with feelings
Join Date: Nov 2009
Location: memory
Posts: 633
|
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" )?
|
|
|
07-22-2010, 07:13 AM
|
#13
|
Human being with feelings
Join Date: May 2009
Posts: 1,265
|
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;
|
|
|
07-25-2010, 03:39 AM
|
#14
|
Human being with feelings
Join Date: May 2007
Posts: 88
|
Awesome Mich!!!
this works perfect for now
thanks heaps!
|
|
|
04-07-2011, 11:34 AM
|
#15
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
|
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
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...
|
|
|
04-08-2011, 08:32 AM
|
#16
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Indeed it is not logarithmic. But it does go all the way down to zero, which was one of the requirements of obstgegenrechz.
|
|
|
04-08-2011, 09:49 AM
|
#17
|
Human being with feelings
Join Date: May 2009
Posts: 1,265
|
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.
|
|
|
04-12-2011, 04:23 AM
|
#18
|
Human being with feelings
Join Date: Mar 2007
Location: Mediterrenean Sea
Posts: 977
|
|
|
|
04-12-2011, 06:25 AM
|
#19
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,417
|
Quote:
Originally Posted by Mich
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.
|
|
|
04-12-2011, 09:41 AM
|
#20
|
Human being with feelings
Join Date: Nov 2008
Location: Darmstadt, Germany
Posts: 673
|
Quote:
Originally Posted by Fabian
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.
|
|
|
04-12-2011, 12:34 PM
|
#21
|
Human being with feelings
Join Date: May 2009
Posts: 1,265
|
Quote:
Originally Posted by Fabian
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 .
|
|
|
04-12-2011, 12:44 PM
|
#22
|
Human being with feelings
Join Date: May 2009
Posts: 1,265
|
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
|
|
|
04-12-2011, 02:49 PM
|
#23
|
Human being with feelings
Join Date: Nov 2008
Location: Darmstadt, Germany
Posts: 673
|
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))
Last edited by l0calh05t; 04-12-2011 at 03:02 PM.
|
|
|
01-25-2012, 08:40 AM
|
#24
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
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.
|
|
|
01-25-2012, 12:02 PM
|
#25
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
What you are proposing is possible, but:
Quote:
Originally Posted by amagalma
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;
);
|
|
|
01-25-2012, 01:32 PM
|
#26
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Quote:
Originally Posted by amagalma
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;
|
|
|
01-25-2012, 09:29 PM
|
#27
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
THANK YOU !!! You rock!!! ))
I am going to try it tomorrow!
|
|
|
01-27-2012, 12:50 AM
|
#28
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
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)
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 03:19 AM.
|