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).