| I've been experimenting some more....
For a slightly firmer compressor, arctan(arctan(x)) works really well,
and doesn't really require a normalising multiplication after.
Amplitudes between 0.5 and 2.0 are compressed to amplitudes between
0.44 and 0.84.
opcode ArctanDoubleCompressor, a, a
ain xin
aout = taninv(taninv(ain))
xout aout
endop
Pete
On Wed, Apr 20, 2016 at 2:42 PM, Peter Burgess
wrote:
> Hi there, I was just reading through an old csound post about limiters
> and compressors, and came across this:
>
> kghongaku wrote:
>
> i've always wanted to try non-linear transfer functions like
> 2*atan(x)/3.1415927 for 0dbs=1.0
>
> k.
>
> I also remember someone talking about this recently. So I've given it
> a try, and it's great! I've been struggling to get some procedurally
> generated basses in check, and this does a great job! So now I'm
> thinking about how to make it as fast as possible. I've obviously
> turned the *2 and /pi into one multiplication, but I'm thinking I can
> do better than that.
>
> I am guessing that if a floating point number has less digits that are
> a 1, that the calculation would be quicker, right? I know floating
> point numbers are more complicated than integers. so I don't want to
> just assume that's correct, and I can't find an answer to that
> specific question even with a fair bit of googling. Does anyone here
> know anything about it?
>
> If I am right about that, the next optimization I'm making is to
> examine the number in binary, and reduce the amount of binary 1's
> while trying to keep a close approximation. Incase anyone's
> interested, here is 2 / pi to 13 decimal places and the close
> approximation I've opted for:
>
> Actual number to 13dp:
>
> 0.6366197723675 =
> 0.1010001011111001100000110110111001001110001011010010111111...
> trailing digitis...
>
> A good approximation by rounding binary digits:
>
> 0.63671875 = 0.1010001
>
> I know it's very simple, and people could easily make there own, but
> for the hell of it, here's the approximated UDO:
>
> opcode ArctanCompressor, a, a
> ain xin
> aout = taninv(ain) * 0.63671875
> xout aout
> endop
>
> This approximation theoretically allows you to go just over 1, but
> you'd have to be using some pretty absurd amplitudes to achieve that.
> I'm now figuring out some additions that will allow you to set a
> threshold, below which you still get normal dynamic range... if that
> comes to anything, I'll post it.
>
> The next question is, how quick is the arctan function in comparison
> with a normal compressor?
>
> Pete
>
> --
> http://algorythmradio.com
> https://soundcloud.com/algorythmradio
|