|
|
|
05-30-2016, 05:17 AM
|
#1
|
Human being with feelings
Join Date: May 2010
Location: Norway
Posts: 7,318
|
JS Volume Adjustment Q
Hi!
In
JS Volume Adjustment
what exactly does "Max Volume" do here?
Code:
// This effect Copyright (C) 2004 and later Cockos Incorporated
// License: GPL - http://www.gnu.org/licenses/gpl.html
desc: Volume Adjustment
//tags: utility gain
//author: Cockos
slider1:6<-60,1,0.1>Adjustment (dB)
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;
__________________
Reaper x64, win 11
Composer, text-writer, producer
Bandcamp
|
|
|
05-30-2016, 03:51 PM
|
#2
|
Human being with feelings
Join Date: Oct 2013
Location: Seattle, WA
Posts: 876
|
Look at the min(max()) statement. It functions as a hard limit.
|
|
|
05-30-2016, 11:25 PM
|
#3
|
Human being with feelings
Join Date: May 2010
Location: Norway
Posts: 7,318
|
Quote:
Originally Posted by SaulT
Look at the min(max()) statement. It functions as a hard limit.
|
Ok, so it's not limiting the volume-adjustment of first slider,
it just adds a hard limiter?
__________________
Reaper x64, win 11
Composer, text-writer, producer
Bandcamp
|
|
|
05-30-2016, 11:47 PM
|
#4
|
Human being with feelings
Join Date: Oct 2013
Location: Seattle, WA
Posts: 876
|
Quote:
Ok, so it's not limiting the volume-adjustment of first slider,
it just adds a hard limiter?
|
Yes.
Let's break down what happens. Slider1 is changed. This sets doseek to 1, which computes the difference between the current volume modifier, adj1_s, and the target value of adj1. @block is executed at the beginning of every sampleblock, so the difference is cut into 1/sampleblock steps, e.g. if we were going from a 3 dB boost to a 6 dB boost and the sampleblock was 1024, then dadj would be set to
2^(3/6) = 1.4142...
2^(6/6) = 2
(2 - 1.4142)/1024 = -0.000572
This value is then added to adj1_s each sample of the block via dadj at the bottom there. At the end adj1_s will equal the target value of adj1. Since doseek will have been set to 0, dadj will then be zero. It's a linear ramp, in other words.
Okay, so looking at the meat of the gain adjustment, moving from the inside out:
Code:
spl0=min(max(spl0*adj1_s,-adj2),adj2);
spl0*adj1_s is the same as saying "spl0 times the current volume modifier"
max(x,-adj2) means we take the higher of our negative maximum or spl0*adj1_s
min(x,adj2) means that we take the lower of our positive maximum or spl0*adj1_s
And of course, the last statement with dadj is covered earlier - its value is zero except during a sampleblock that slider1 has been changed.
Last edited by SaulT; 05-31-2016 at 12:07 AM.
|
|
|
05-31-2016, 12:04 AM
|
#5
|
Human being with feelings
Join Date: Oct 2013
Location: Seattle, WA
Posts: 876
|
Here is a different way to think of it. Instead of the linear ramp, I'll use a one-pole smoothing filter. Same basic functionality, but you can change your transition time from instantaneous to several seconds. Automate it for fade ins? *shrug*
Code:
desc:smooth gain utility function
slider1:3<-30,30,0.1>Adjustment (dB)
slider2:0<-60,15,0.1>Max Volume (dB)
slider3:200<5,2000,1>Smoothing (ms)
@slider
adj1=10 ^ (slider1/20);
adj2=10 ^ (slider2/20);
coeff = exp(-1/(slider3/1000*srate));
@sample
adj1_s = adj1_s*coeff + adj1*(1-coeff);
spl0=min(max(spl0*adj1_s,-adj2),adj2);
spl1=min(max(spl1*adj1_s,-adj2),adj2);
|
|
|
05-31-2016, 12:46 AM
|
#6
|
Human being with feelings
Join Date: May 2010
Location: Norway
Posts: 7,318
|
Thanks!
I just needed to understand the last slider,
as I was using the first for automation
and suddenly saw the second looking misplaced at -2.
For all I know it could ruin my mix-balance with 2db
If I started out now I'd use your smoother version.
__________________
Reaper x64, win 11
Composer, text-writer, producer
Bandcamp
|
|
|
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 02:17 PM.
|