compression

Hello Sirs.
Please read this code:

(stretch-abs 15 (reson (s-exp (mult (osc 69))) (pwl 0.150 1 3500 1) 11 20))

I find interesting to use compression on the sound produced by the code. In this case, I use the regulations following by the effect compression of the software Audacity: threshold -52/ noise -50/ ratio 6:5:1/ attack 0.20s/release 2.0s/
My question is the following one: it is possible to write a code which generates a sound affected by a compression identical to the regulations indicated above.
R.B.D. proposes the following code:

(defun compress (input map rise-time fall-time)
 (let ((in-squared (mult input input)))
 (setf avg (snd-avg in-squared 1000 500 OP-AVERAGE))  
 (setf env (snd-follow avg 0.001 0.2 1.0 20))  
 (setf logenv (snd-log env))  
 (setf shaped-env (shape logenv map 1.0))  
 (setf gain (snd-exp shaped-env)) 

  (mult (seq (s-rest (/ 20.0 88.2)) (cue input)) gain)))

But I do not understand how this code works.
Beforehand thank you for your help).

I’m not sure what you are trying to do, but that code is not correct.

It should be possible to reproduce very similar behaviour in Nyquist because the compressor that is included with Audacity is based on a compressor that was originally written in Nyquist.

That code is explained here: http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/examples/rbd/18-follow.lsp.htm