[Csnd] how to reinit lufs ktrig w multiple opcode instances

Hi everybody,

Really digging the new Lufs opcode. However, when I use it in a UDO and have 3 or more instances of this UDO, the audio stops getting passed through and/or processed properly. I think it has something to do with the ktrig init 0(or lack thereof on multiple instances, but I am not sure...). I have tried passing global k statements per UDO instance, but that did not work either. Any advice here is greatly appreciated, thank you.

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

sr=48000
ksmps=64
0dbfs=1.0
nchnls=2

opcode LufGainer, aa, aaki
ainL, ainR, ktargetDB, isig xin
ktrig init 0
kupRamp linseg -1000, 0.3, 0, 100, 0
ktargetDB min kupRamp, ktargetDB
kM,kI,kS lufs ktrig, ainL, ainR
printks "%f -> M: %f, I: %f, S: %f LUFS\n", 0.3, isig, kM, kI, kS
aOffset = ampdb(ktargetDB - kI)
xout ainL * aOffset, ainR * aOffset
endop

instr 1
aamp linseg 0, p3, 1
a1 poscil aamp,1000,1
a2 poscil aamp,1200,1
a1, a2 LufGainer a1, a2, -10, 1 #last arg here not functional, for debugging only
a1, a2 LufGainer a1, a2, -10, 2
a1, a2 LufGainer a1, a2, -10, 3
outs a1, a2
endin

</CsInstruments>
<CsScore>
f1 0 8192 10 1

i1 0 5
</CsScore>
</CsoundSynthesizer>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

Jun 9 2021, walker has written:

Hi everybody,

Really digging the new Lufs opcode.

...

I think it has something to do with the ktrig init 0(or lack thereof on multiple instances, but I am not sure...).

...
I am not sure, but maybe you could try something like:
kTrig init 1
; rest of your opcode
xout(a1, a2)
kTrig = 0
endop

I hope this helps!

Best wishes,

Jeanette

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

hi -

i had a look at your code, and i think the reason why it is not working is the expression
  ampdb(ktargetDB - kI)

not sure what you want to do here, but if you change your udo to this and look at the printout, you will see very strange values:

opcode LufGainer, aa, aaki
ainL, ainR, ktargetDB, isig xin
ktrig init 0
kupRamp linseg -1000, 0.3, 0, 100, 0
ktargetDB min kupRamp, ktargetDB
kM,kI,kS lufs ktrig, ainL, ainR
;printks "%f -> M: %f, I: %f, S: %f LUFS\n", 0.3, isig, kM, kI, kS
kOffset = ampdb(ktargetDB - kI)
printk .5, kOffset
xout ainL*kOffset, ainR*kOffset
endop

definitely it is not a performance issue. my execution reports:
  Elapsed time at end of performance: real: 5.118s, CPU: 0.311s

perhaps this helps a bit, best -
  joachim