Cabbage Logo
Back to Cabbage Site

How to make an LUFS Gain Rider

Hi there Cabbage Community!

I’m trying to make an LUFS Gain Rider that adjusts the signal’s volume every 4 seconds to match the Target LUFS.

What I’m struggling to figure out is how to add a 2s envelope from the current level to the new adjusted level. Using Interp I was able to get rid of clicking that was originally happening, but I’d still like the transition to the new gain to be longer. I’ve tried every combination of linseg, loopseg, trigLinseg, and logcurve that I can but I just can’t seem to make it work.

Here is my code so far…

ktim timeinsts
ktrig init 0
kM,kI,kS lufs ktrig,aL,aR
kAdjust init 1
printk 1, kS
if kS > -40 && ktim % 4 == 0 then
    if ampdb(-24)/ampdb(kS) < 3.5 then ;avoid way too loud accidents
        kAdjust = ampdb(-24)/ampdb(kS)
    endif
endif
aAdjust interp kAdjust
aL = aL * aAdjust
aR = aR * aAdjust
kM,kI,kS lufs ktrig,aL,aR
printk 1, kS

Have you tried using the port opcode?

1 Like

Also follow and follow2 opcodes

1 Like

ah yes port did the trick! Thank you!

I did try it after seeing it used in one of the dynamics examples, but I must not have connected it correctly.

I also took a look at connecting follow but I wasn’t too sure where in the signal it would be inserted. Is it meant to replace the lufs opcode?

You can add line like
aAdjust1 follow2 aAdjust ,2,2
This way you have 2 sek rise and 2 sek fall.