Re: [Csnd] Scaling amplitude depending on number of instruments

This is a request for another ‘missing’ opcode

It would be great to have an opcode in Csound that does what thorin’s UDO does.

  • dealing with amplitudes in a smart, intuitive, adaptive, and ‘invisible’ way would be great - much used, and useful.

Maybe a new opcode could be added with this or other algorithms or options.


Umm… on that UDO… I realised after posting that my formula was a bit off.
This does better.

;reduces amplitude of an audio signal based on the number of currently active instruments.
;reduction is 3db every doubling of current instances.
;ktime smooths the changes to avoid clicks (defaults to 0.08 seconds)
;iinsnum is the instrument number to monitor (defaults to calling instrument p1. 0 monitors all instruments.)
opcode activedamp, a,aOj
asig, ktime, iinsnum xin
setksmps 1
iinsnum = (iinsnum == -1 ? p1 : iinsnum)
kinsnums active iinsnum, 0, 0
klognum = max(1,kinsnums) * -3
kampfac2 = ampdbfs(log2(max(1,kinsnums)) * -3); drop 3db every doubling.
asig *= lineto(kampfac2, limit:k(ktime, 0.008, 5))
xout asig


Thanks, Thorin,

I love ALL your Csound work. Inspiring…