|
|
|
11-12-2017, 02:22 PM
|
#1
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
REQ: JS Auto Trim Plugin
Recently an idea came to my mind about gain staging and I think it will be very useful for lots of people. I need a trim plugin that will automatically decrease the output volume -6 db (it can be any minus value as long as below 0 db), when input signal to the plugin reaches 0 db. Thus, we can put it to our first insert of master channel (assuming working at 32 or 64 bit floating point) and we never have to worry about clipping.
|
|
|
11-12-2017, 10:37 PM
|
#2
|
Human being with feelings
Join Date: May 2013
Location: Jakarta, Indonesia
Posts: 190
|
You can use free dpMeter2 from TBProaAudio to do similar task, maybe better, tho it will need a single click to match whatever value you wrote for the reference level.
|
|
|
02-06-2018, 08:46 PM
|
#3
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Quote:
Originally Posted by crimsonmerry
You can use free dpMeter2 from TBProaAudio to do similar task, maybe better, tho it will need a single click to match whatever value you wrote for the reference level.
|
I tried hornet vu meter, it's so close to my request but not exactly. I want it react to peaks.
|
|
|
02-06-2018, 10:33 PM
|
#4
|
Human being with feelings
Join Date: May 2014
Location: Germany
Posts: 643
|
Quote:
Originally Posted by ertugrulgul
I tried hornet vu meter, it's so close to my request but not exactly. I want it react to peaks.
|
This is exactly what dpMeter2 can do: match the gain with loudness and Peak/True Peak values.
Just do the measurement and shift click on the desired meter readout value.
|
|
|
02-15-2018, 06:52 AM
|
#5
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Quote:
Originally Posted by TBProAudio
This is exactly what dpMeter2 can do: match the gain with loudness and Peak/True Peak values.
Just do the measurement and shift click on the desired meter readout value.
|
Tried the plugin but it's not adjusting the gain automatically according to incoming signal to the plugin.
|
|
|
02-15-2018, 09:22 AM
|
#6
|
Human being with feelings
Join Date: May 2014
Location: Germany
Posts: 643
|
Quote:
Originally Posted by ertugrulgul
Tried the plugin but it's not adjusting the gain automatically according to incoming signal to the plugin.
|
Well, not automatically, but you need to do one click with the mouse.
|
|
|
02-15-2018, 12:25 PM
|
#7
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Seems straightforward enough - keep a gain value as a slider, and check every sample whether it needs to be reduced.
If you cut the gain immediately, it will cause a click. You can reduce this click by ramping the gain factor across each block. This smooths the correction out over time, but if your limit is at 0 then it might temporarily clip before it's finished adjusting. This is probably OK.
Here's an example implementation, but I haven't actually run this to check it works:
Code:
desc:Auto-Trim (with reduced click)
in_pin:left
in_pin:right
out_pin:left
out_pin:right
slider1:gain_db=0<-24,0,6}>Gain (dB)
slider2:limit_db=0<-12,0,1}>Limit (dB)
slider3:steps_db=6<1,12,1}>Step size (dB)
@block
gain_factor_target = pow(10, gain_db/20);
gain_factor_increment = (gain_factor_target - gain_factor)/samplesblock;
limit_factor = pow(10, limit_db/20);
steps_factor = pow(10, steps_db/20);
@sample
// Calculate peak based on target gain reduction, not actual one
peak = max(abs(spl0), abs(spl1))*gain_factor_target;
while (peak >= limit_factor) (
peak /= steps_factor;
gain_db -= steps_db;
sliderchange(1);
);
gain_factor += gain_factor_increment; // smoothly change gain between blocks
spl0 *= gain_factor;
spl1 *= gain_factor;
Last edited by geraintluff; 02-19-2018 at 07:07 AM.
Reason: Typo in code
|
|
|
02-15-2018, 12:42 PM
|
#8
|
Human being with feelings
Join Date: Feb 2017
Posts: 4,812
|
Quote:
Originally Posted by TBProAudio
This is exactly what dpMeter2 can do: match the gain with loudness and Peak/True Peak values.
Just do the measurement and shift click on the desired meter readout value.
|
|Do you know a link that you could share where i can understand the concepts of loudness and learn to work with your plugin and take the most of it?
Big thank you!
|
|
|
02-15-2018, 10:40 PM
|
#9
|
Human being with feelings
Join Date: May 2014
Location: Germany
Posts: 643
|
Quote:
Originally Posted by deeb
|Do you know a link that you could share where i can understand the concepts of loudness and learn to work with your plugin and take the most of it?
Big thank you!
|
Sorry, not for your specific question. But here is an article about Amazon Alexa and loudness matching.
Ii hope it helps
|
|
|
02-16-2018, 07:13 AM
|
#10
|
Human being with feelings
Join Date: Feb 2017
Posts: 4,812
|
thank you TB ! : )
|
|
|
02-19-2018, 06:53 AM
|
#11
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Quote:
Originally Posted by geraintluff
Seems straightforward enough - keep a gain value as a slider, and check every sample whether it needs to be reduced.
If you cut the gain immediately, it will cause a click. You can reduce this click by ramping the gain factor across each block. This smooths the correction out over time, but if your limit is at 0 then it might temporarily clip before it's finished adjusting. This is probably OK.
Here's an example implementation, but I haven't actually run this to check it works:
Code:
desc:Auto-Trim (with reduced click)
in_pin:left
in_pin:right
out_pin:left
out_pin:right
slider1:gain_db=0<-24,0,6}>Gain (dB)
slider2:limit_db=0<-12,0,1}>Limit (dB)
slider3:steps_db=6<1,12,1}>Step size (dB)
@block
gain_factor_target = pow(10, gain_db/20);
gain_factor_increment = (gain_factor_target - gain_factor)/samplesblock;
limit_factor = pow(10, limit_db/20);
steps_factor = pow(10, steps_db/20);
@sample
// Calculate peak based on target gain reduction, not actual one
peak = max(abs(spl0), abs(spl1)*gain_factor_target;
while (peak >= limit_factor) (
peak /= steps_factor;
gain_db -= steps_db;
sliderchange(1);
);
gain_factor += gain_factor_increment; // smoothly change gain between blocks
spl0 *= gain_factor;
spl1 *= gain_factor;
|
it says syntax error: missing ) or ]
|
|
|
02-19-2018, 07:08 AM
|
#12
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Quote:
Originally Posted by ertugrulgul
it says syntax error: missing ) or ]
|
I knew there had to be a typo somewhere.
Added missing ")", should compile now (although I unfortunately can't test it atm).
Code:
desc:Auto-Trim (with reduced click)
in_pin:left
in_pin:right
out_pin:left
out_pin:right
slider1:gain_db=0<-24,0,1}>Gain (dB)
slider2:limit_db=0<-12,0,1}>Limit (dB)
slider3:steps_db=6<1,12,1}>Step size (dB)
@block
gain_factor_target = pow(10, gain_db/20);
gain_factor_increment = (gain_factor_target - gain_factor)/samplesblock;
limit_factor = pow(10, limit_db/20);
steps_factor = pow(10, steps_db/20);
@sample
// Calculate peak based on target gain reduction, not actual one
peak = max(abs(spl0), abs(spl1))*gain_factor_target;
while (peak >= limit_factor) (
peak /= steps_factor;
gain_db -= steps_db;
sliderchange(1);
);
gain_factor += gain_factor_increment; // smoothly change gain between blocks
spl0 *= gain_factor;
spl1 *= gain_factor;
Last edited by geraintluff; 02-19-2018 at 07:13 AM.
|
|
|
02-19-2018, 07:45 AM
|
#13
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Quote:
Originally Posted by geraintluff
I knew there had to be a typo somewhere.
Added missing ")", should compile now (although I unfortunately can't test it atm).
|
Thank you man, it seem works now. If you try and find some improvable things or bugs, please don't forget to post it here.
|
|
|
02-19-2018, 07:55 AM
|
#14
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Btw could it be set to; always left -6db headroom when the incoming signal exceed 0db ? If it's possible it will be awesome.
|
|
|
02-19-2018, 08:02 AM
|
#15
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Quote:
Originally Posted by ertugrulgul
Btw could it be set to; always left -6db headroom when the incoming signal exceed 0db ? If it's possible it will be awesome.
|
I'm afraid I don't quite understand what you mean.
There are three sliders - current gain, limit and step size. With the default parameters values (double-click sliders, or full recompile/reset), every time the output goes above 0db (limit), it should reduce the gain by 6dB (step size).
So for example, an input peak of +1dB should result in a gain of -6dB. Is that what you're after?
|
|
|
02-19-2018, 08:09 AM
|
#16
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
I mean I want the signal after the plugin always at -6db, for instance if incoming signal to plugin is +3 db, plugin should reduce the gain by -9db for achieve -6db output.
|
|
|
02-19-2018, 08:11 AM
|
#17
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Quote:
Originally Posted by ertugrulgul
I mean I want the signal after the plugin always at -6db, for instance if incoming signal to plugin is +3 db, plugin should reduce the gain by -9db for achieve -6db output.
|
Try settting "limit" to -6dB, and "step size" to 1dB. It will then reduce the gain in 1dB increments, so that all peaks are below -6dB.
(If you're saying that it should be "inactive" until triggered by one initial peak: that could be added as a feature, but doesn't seem as intuitive to me.)
Last edited by geraintluff; 02-19-2018 at 08:18 AM.
|
|
|
02-19-2018, 08:34 AM
|
#18
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Quote:
Originally Posted by geraintluff
Try settting "limit" to -6dB, and "step size" to 1dB. It will then reduce the gain in 1dB increments, so that all peaks are below -6dB.
(If you're saying that it should be "inactive" until triggered by one initial peak: that could be added as a feature, but doesn't seem as intuitive to me.)
|
It's not working correctly with this way, maybe a bug releated.
|
|
|
02-19-2018, 08:39 AM
|
#19
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Quote:
Originally Posted by ertugrulgul
It's not working correctly with this way, maybe a bug releated.
|
What is it doing instead?
|
|
|
02-19-2018, 09:11 AM
|
#20
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Reducing the gain -1800 db
|
|
|
02-19-2018, 09:27 AM
|
#21
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Quote:
Originally Posted by ertugrulgul
Reducing the gain -1800 db
|
Ahaha - yes, I see. Serves me right for not properly testing my code.
Try this:
Code:
desc:Auto-Trim (with reduced click)
in_pin:left
in_pin:right
out_pin:left
out_pin:right
slider1:gain_db=0<-24,0,1}>Gain (dB)
slider2:limit_db=0<-12,0,1}>Limit (dB)
slider3:steps_db=6<1,12,1}>Step size (dB)
@block
gain_factor_target = pow(10, gain_db/20);
gain_factor_increment = (gain_factor_target - gain_factor)/samplesblock;
limit_factor = pow(10, limit_db/20);
steps_factor = pow(10, steps_db/20);
@sample
// Calculate peak based on target gain reduction, not actual one
peak = max(abs(spl0), abs(spl1))*gain_factor_target;
while (peak >= limit_factor) (
peak /= steps_factor;
gain_factor_target /= steps_factor;
gain_db -= steps_db;
sliderchange(1);
);
gain_factor += gain_factor_increment; // smoothly change gain between blocks
spl0 *= gain_factor;
spl1 *= gain_factor;
|
|
|
02-20-2018, 04:44 AM
|
#22
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Ok this is working, thank you so much.
|
|
|
02-20-2018, 08:48 AM
|
#23
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
One last thing Can you add an on/off button for using it only for trim? In other words; after reducing gain automatically, I want to bypass the auto setting and use it as a fixed attenuator.
|
|
|
02-20-2018, 08:57 AM
|
#24
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Quote:
Originally Posted by ertugrulgul
One last thing Can you add an on/off button for using it only for trim? In other words; after reducing gain automatically, I want to bypass the auto setting and use it as a fixed attenuator.
|
Try this - I've just added an "enabled" flag which optionally skips the peak analysis.
Does the code make sense?
Code:
desc:Auto-Trim (with reduced click)
in_pin:left
in_pin:right
out_pin:left
out_pin:right
slider1:gain_db=0<-24,0,1}>Gain (dB)
slider2:limit_db=0<-12,0,1}>Limit (dB)
slider3:steps_db=6<1,12,1}>Step size (dB)
slider4:enabled=1<0,1,1{off,on}}>Enabled
@block
gain_factor_target = pow(10, gain_db/20);
gain_factor_increment = (gain_factor_target - gain_factor)/samplesblock;
limit_factor = pow(10, limit_db/20);
steps_factor = pow(10, steps_db/20);
@sample
enabled ? (
// Calculate peak based on target gain reduction, not actual one
peak = max(abs(spl0), abs(spl1))*gain_factor_target;
while (peak >= limit_factor) (
peak /= steps_factor;
gain_factor_target /= steps_factor;
gain_db -= steps_db;
sliderchange(1);
);
);
gain_factor += gain_factor_increment; // smoothly change gain between blocks
spl0 *= gain_factor;
spl1 *= gain_factor;
|
|
|
02-20-2018, 09:06 AM
|
#25
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Perfect! Thank you man you're awesome.
|
|
|
04-03-2018, 12:32 PM
|
#26
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Hey man, I discovered an issue. With attacky sounds (a snare sample for instance), the plugin is killing the transients a bit, like a little fade in. The situation happens when rendering the audio which is starting immediately from very first bar, or playing the audio in daw while the cursor stands right before the items beginning.
|
|
|
04-04-2018, 03:38 PM
|
#27
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Ah - try this:
Code:
in_pin:left
in_pin:right
out_pin:left
out_pin:right
slider1:gain_db=0<-24,0,1}>Gain (dB)
slider2:limit_db=0<-12,0,1}>Limit (dB)
slider3:steps_db=6<1,12,1}>Step size (dB)
slider4:enabled=1<0,1,1{off,on}}>Enabled
@init
gain_factor = pow(10, gain_db/20);
@block
gain_factor_target = pow(10, gain_db/20);
gain_factor_increment = (gain_factor_target - gain_factor)/samplesblock;
limit_factor = pow(10, limit_db/20);
steps_factor = pow(10, steps_db/20);
@sample
enabled ? (
// Calculate peak based on target gain reduction, not actual one
peak = max(abs(spl0), abs(spl1))*gain_factor_target;
while (peak >= limit_factor) (
peak /= steps_factor;
gain_factor_target /= steps_factor;
gain_db -= steps_db;
sliderchange(1);
);
);
gain_factor += gain_factor_increment; // smoothly change gain between blocks
spl0 *= gain_factor;
spl1 *= gain_factor;
It adds an @init section which initialises gain_factor (which otherwise is set to 0).
|
|
|
04-11-2018, 03:30 PM
|
#28
|
Human being with feelings
Join Date: Jul 2014
Location: Turkey
Posts: 233
|
Thank you man
|
|
|
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 01:49 PM.
|