Old 04-25-2019, 12:48 PM   #1
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,602
Default Gain Staging made easy

Hi everyone

here's a combinaison of two scripts to make the gain stagin before mixing dead easy

WARNING!

ONLY WORK WITH OPTIONS THESE OPTIONS TOGGLE ON

Preferences -> automation : hidden envelopes: Display read automation feedback
Preferences -> automation : hidden envelopes: allow writing automation


Here's a visual demo


https://youtu.be/wiYBbMZxub8

You need two script

1) make all track latach preview with pre fx volume envelope armed
Code:
reaper.Main_OnCommand(40296, 0)
reaper.Main_OnCommand(40408, 0)
reaper.Main_OnCommand(40408, 0)
reaper.Main_OnCommand(40297, 0)
function main()

 for tr = 0, reaper.CountTracks(0) -1 do
     local track = reaper.GetTrack(0,tr)
     reaper.Main_OnCommand(40408, 0)
      
          local env = reaper.GetTrackEnvelopeByName(track ,"Volume (Pre-FX)")
           br_env = reaper.BR_EnvAlloc(env, false)
           active, visible, armed, inLane, laneHeight, defaultShape, _, _, _, _, faderScaling = reaper.BR_EnvGetProperties( br_env )
            --if visible == true  then
           reaper.BR_EnvSetProperties( br_env, true, 
                                              false, 
                                             true, 
                                            inLane, 
                                            laneHeight, 
                                            defaultShape, 
                                            faderScaling )
            
           reaper.BR_EnvFree(br_env, true)
          reaper.SetTrackAutomationMode(track, 5)
      end    

end
    

main()--Volume (Pre-FX) --40408
reaper.UpdateArrange()

2) write value on pre fx volume lane and bring back track to trim/read

Code:
initpos = reaper.GetCursorPosition()
projend = reaper.GetProjectLength(0)
reaper.GetSet_LoopTimeRange2(0, true, false, 0, projend, false)
reaper.SetEditCurPos2(0, 0, false, false)
reaper.Main_OnCommand(42013, 0)
function main()
  for tr = 0, reaper.CountTracks(0) -1 do
         track = reaper.GetTrack(0,tr) 
         env = reaper.GetTrackEnvelopeByName(track, "Volume (Pre-FX)")
            br_env =  reaper.BR_EnvAlloc( env , false)
            active, visible, armed, inLane, laneHeight, defaultShape, _, _, _, _, faderScaling = reaper.BR_EnvGetProperties( br_env )
            --if visible == true  then
            reaper.BR_EnvSetProperties( br_env, true, 
                                               false, 
                                             false, 
                                             inLane, 
                                            laneHeight, 
                                             defaultShape, 
                                             faderScaling )
            
           reaper.BR_EnvFree(br_env, true)
          reaper.SetTrackAutomationMode(track, 0)
  end    
end
    

main()--Volume (Pre-FX)
reaper.SetEditCurPos2(0, initpos, false, false)
reaper.UpdateArrange()
You can use a cycle action to make ONE toggle action with two scripts

Last edited by Reno.thestraws; 04-25-2019 at 03:15 PM.
Reno.thestraws is offline   Reply With Quote
Old 04-25-2019, 01:51 PM   #2
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 5,457
Default

that gif is crashing everything I try to play it on, except reaper but nearly.

I do not understand what's happening from the point the faders turn red to the end.
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds is offline   Reply With Quote
Old 04-25-2019, 02:11 PM   #3
karbomusic
Human being with feelings
 
karbomusic's Avatar
 
Join Date: May 2009
Posts: 23,864
Default

The GIF works fine here but being 58MB I could see it causing issues for some apps.
karbomusic is online now   Reply With Quote
Old 04-25-2019, 03:25 PM   #4
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,602
Default

Quote:
Originally Posted by EpicSounds View Post
that gif is crashing everything I try to play it on, except reaper but nearly.

I do not understand what's happening from the point the faders turn red to the end.
SOrry for that, I replaced the gif with a youtube video


In short, the script allow to use the fader as PRE FX VOLUME when it's on

SO you can quickly do a gain structure BEFORE hitting plugs or hardware with MCP and switch back to traditionnal post FX volume after

How it works?

when you launch the first part of the script, all track are in latch preview mode with volume PRE FX envelope armed


when you launch the second part of the script, all tracks come back in trim mode and the PRE FX VOLUME is printed on the envelope


You can do it without scipt by set global automation overwrite to latch preview, open every pre fx vol envelope, do you balance, then use action "42017" "Automation: Write current values for actively-writing envelopes to entire envelope" and switch back to no global automation overide

but it's a lot of step AND you see all the ECP lane in your timeline
Reno.thestraws is offline   Reply With Quote
Old 04-25-2019, 03:56 PM   #5
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC USA
Posts: 6,778
Default

Or just set the meters prefader in options
Coachz is offline   Reply With Quote
Old 04-25-2019, 10:38 PM   #6
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,602
Default

it has nothing To do with metering Track metering is peak in RPR, pre or post, it doesn't help for a proper gain stage.


it's a quick way To use faders to control INPUT of tracks instead of item gain or any trim plug in.
Reno.thestraws is offline   Reply With Quote
Old 04-25-2019, 11:59 PM   #7
beingmf
Human being with feelings
 
beingmf's Avatar
 
Join Date: Jul 2007
Location: Jazz City
Posts: 3,903
Default

I totally can see myself using this. Thanks – will try in the next days!
__________________
Windows 7x64 SP1 | NVidia Quadro2000, 10.18.13.6191 | Marian Seraph AD2, 4.0.2.1
Experience the Blunzeworscht!
beingmf is online now   Reply With Quote
Old 04-26-2019, 12:19 AM   #8
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 7,125
Default

I always fail to see the sense of "proper" gain staging in computer audio.

-Michael
__________________
www.boa-sorte.de
mschnell is offline   Reply With Quote
Old 04-26-2019, 12:59 AM   #9
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,602
Default

Quote:
I always fail to see the sense of "proper" gain staging in computer audio.
Plug-ins that emulates hardware emulate also the sweet spot


Generally, it's -18dbfs RMS = 0VU (=1.23V = +4dbu)

So if you're using real hardware or hardware emulation, it's a good thing to hit the plug at this level so the plug or hardware react as expect and don't introduce unintentionaly saturation/SNR reduction/noise


Ok, no one will die if you get a little too loud in a plug (sometimes, the sound is even pleasant), but sue big sessions with chains of plug-ins 2-3 plug style "hardware", the Involuntary addition of saturation can quickly make the sound sour, flat and harsh
Reno.thestraws is offline   Reply With Quote
Old 04-26-2019, 03:33 AM   #10
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC USA
Posts: 6,778
Default

Quote:
Originally Posted by mschnell View Post
I always fail to see the sense of "proper" gain staging in computer audio.

-Michael
Yup, I just use my ears.
Coachz is offline   Reply With Quote
Old 04-26-2019, 03:53 AM   #11
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,602
Default

Quote:
Yup, I just use my ears
And that's why this script can help

Once your mix set up is made with all your plug and/or hardware placed on your mixer, just a quick balance with fader by ears to hit the sweet spot and tada, it's done, then you can still use faders for post fx balance
Reno.thestraws is offline   Reply With Quote
Old 04-26-2019, 04:16 AM   #12
beingmf
Human being with feelings
 
beingmf's Avatar
 
Join Date: Jul 2007
Location: Jazz City
Posts: 3,903
Default

Quote:
Originally Posted by mschnell View Post
I always fail to see the sense of "proper" gain staging in computer audio.
Nebula/Acqua and Airwindows!
__________________
Windows 7x64 SP1 | NVidia Quadro2000, 10.18.13.6191 | Marian Seraph AD2, 4.0.2.1
Experience the Blunzeworscht!
beingmf is online now   Reply With Quote
Old 04-26-2019, 05:39 AM   #13
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 7,125
Default

Quote:
Originally Posted by Reno.thestraws View Post
Plug-ins that emulates hardware emulate also the sweet spot ...
... without an input gain control ???
That would seem like a decent shortcoming.

But of course you are right if they do some nonlinear stuff the gain that reaches that point in the algorithm does matter a lot.

Anyway this should be used "on demand" at exactly this point in the signal flow and not force a global, presumably "precise" gain staging by default.

-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 04-26-2019 at 05:44 AM.
mschnell is offline   Reply With Quote
Old 04-26-2019, 10:56 AM   #14
onewayout
Human being with feelings
 
Join Date: Feb 2008
Location: So Florida
Posts: 985
Default

Quote:
Originally Posted by mschnell View Post
... without an input gain control ???
That would seem like a decent shortcoming.

But of course you are right if they do some nonlinear stuff the gain that reaches that point in the algorithm does matter a lot.

Anyway this should be used "on demand" at exactly this point in the signal flow and not force a global, presumably "precise" gain staging by default.

-Michael
I'm very interested in this! What would you say are reasons not to gainstage? I definitely do not want to do any unnecessary work if I do not need too....
onewayout is offline   Reply With Quote
Old 04-26-2019, 11:25 AM   #15
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 9,602
Default

Here's a basic example

tone @ 220hz

fx chain
1- stereo channel with transparent gain
2- hardware emulation compression (ratio set to 1 to "not compress")
3- stereo channel with transparent gain that compensate the gain of plug 1
4- reaq to notch out 220hz
5- analyser to see harmonics/noise generate by the plug

https://drive.google.com/open?id=1A_...4eGauSCbr1eOfY


as you can see, the more gain hitting the plug, the more harmonics you get


Good thing/Bad thing?

I do not even want to debate it. Everyone does what he wants but I think to be aware of it and manage it according to what you want to do to the sound signal is a safer way to work
Reno.thestraws is offline   Reply With Quote
Old 04-26-2019, 01:49 PM   #16
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 7,125
Default

Quote:
Originally Posted by Reno.thestraws View Post
Good thing/Bad thing? ... I do not even want to debate it.
Yep !
Hence there is no "proper" workflow, but the personal taste (aka "ear") can be used to define the gain at any stage to get the most personally pleasant result .

-Michael
__________________
www.boa-sorte.de
mschnell is offline   Reply With Quote
Old 04-26-2019, 02:00 PM   #17
RJHollins
Human being with feelings
 
Join Date: Dec 2011
Posts: 1,354
Default

Quote:
Originally Posted by onewayout View Post
I'm very interested in this! What would you say are reasons not to gainstage? I definitely do not want to do any unnecessary work if I do not need too....
Since I've used some form of Gain-Staging for near 40 years ...

I can first point out that Gain-Staging [or better put UNITY Gain Staging], allows one to BYPASS any process in the FX Chain, and make proper A/B comparisons, WITHOUT level changes influencing judgement.

About the only situation UNITY is not employed ... the Final OUTPUT of the LIMITER [or final GAIN control], into DITHERING.
RJHollins is online now   Reply With Quote
Old 04-27-2019, 04:55 AM   #18
beingmf
Human being with feelings
 
beingmf's Avatar
 
Join Date: Jul 2007
Location: Jazz City
Posts: 3,903
Default

Empty project (for testing purposes): works.
Existing project: does not work.
Quote:
First script:12: 'reaper.BR_EnvAlloc' argument 1: expected TrackEnvelope*
__________________
Windows 7x64 SP1 | NVidia Quadro2000, 10.18.13.6191 | Marian Seraph AD2, 4.0.2.1
Experience the Blunzeworscht!
beingmf is online now   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 12:56 AM.


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