problem of overdrive

Hello Sirs.
Among the scripts data in examples for the novices appear in particular, those of Sir P.J. Morales. One of these script is called: " Gong like sounds ".

(defun add-partial (dur frq scal)
(amosc (hz-to-step frq) (pwev scal dur (* scal 1e-2))))

(defun gong-1 ()
(sim (add-partial 4 240 3.0)
(add-partial 4 277 2.5)
(add-partial 4 385 2.0)
(add-partial 4 605 3.0)
(add-partial 4 340 1.0)
(add-partial 4 670 1.0)
(add-partial 4 812 1.0)))

(defun add-partial-2 (frq scal)
(amosc (hz-to-step frq) (pwev scal (/ (* 6 240) frq) (* scal 1e-2))))

(defun gong-2 ()
(sim (add-partial-2 240 3.0)
(add-partial-2 277 2.5)
(add-partial-2 385 2.0)
(add-partial-2 605 3.0)
(add-partial-2 340 1.0)
(add-partial-2 670 1.0)
(add-partial-2 812 1.0)))

(defun add-partial-3 (frq fratio dur amp)
(amosc (hz-to-step (* frq fratio)) (pwev amp (/ dur fratio) (* amp 1e-2))))

(defun gong-3 (frq dur)
(sim (add-partial-3 frq 1.0 dur 2.0)
(add-partial-3 frq 2.0 dur 2.0)
(add-partial-3 frq 2.4 dur 2.0)
(add-partial-3 frq 3.0 dur 2.0)
(add-partial-3 frq 4.5 dur 3.0)
(add-partial-3 frq 5.33 dur 3.0)
(add-partial-3 frq 6.0 dur 3.0)))


(abs-env (sim (at 0.0 (gong-3 329 5))
(at 0.2 (gong-3 360 6))
(at 0.4 (gong-3 380 5))
(at 0.6 (gong-3 300 8))
(at 0.8 (gong-3 430 4))
(at 2.0 (gong-3 640 4))
(at 2.2 (gong-3 610 5))
(at 2.4 (gong-3 580 4))
(at 2.6 (gong-3 660 5))))

By using the command there is a problem with Audacity 2.0.2. The problem is that there is a saturation. We can solve this problem by using the command" Effects - Amplification " of this software.
On the other hand, my question is the following one: is there a script which would allow to avoid this saturation?

Beforehand thank you for your answer.

(defun add-partial (dur frq scal)
(amosc (hz-to-step frq) (pwev scal dur (* scal 1e-2))))

The 3rd parameter [scal] sets the level.
Try running this in the Nyquist Prompt to create a sound with a peak amplitude of 0.5

(defun add-partial (dur frq scal)
(amosc (hz-to-step frq) (pwev scal dur (* scal 1e-2))))

(add-partial 1 100 0.5)



(defun gong-1 ()
(sim (add-partial 4 240 3.0)
(add-partial 4 277 2.5)
(add-partial 4 385 2.0)
(add-partial 4 605 3.0)
(add-partial 4 340 1.0)
(add-partial 4 670 1.0)
(add-partial 4 812 1.0)))

This function uses the “add-partial” function multiple times and adds then together [mixes them] using “sim”.
Just by looking at the 3rd parameter in each call of “add-partial” it is obvious that the peak waveform will be huge. For example;
(add-partial 4 240 3.0) will have a peak amplitude of 3 [3 times bigger than the track height].
When we use the function “gong-1” it will be necessary to reduce the level a lot.

Rather than just using (gong-1) to call the function, we could amplify it with:

(mult 0.05 (gong-1))

Looking at the code as a whole we can see that [near the bottom] “(gong-3 …)” is used multiple times.
(gong-3 …)” calls the function “(add-partial-3 …
Again we can use “mult” to “multiply” [amplify] the output:

(defun add-partial-3 (frq fratio dur amp)
  (amosc (hz-to-step (* frq fratio))
    (pwev amp (/ dur fratio) (* amp 1e-2))))

(defun gong-3 (frq dur)
  (sim (add-partial-3 frq 1.0 dur 2.0)
    (add-partial-3 frq 2.0 dur 2.0)
    (add-partial-3 frq 2.4 dur 2.0)
    (add-partial-3 frq 3.0 dur 2.0)
    (add-partial-3 frq 4.5 dur 3.0)
    (add-partial-3 frq 5.33 dur 3.0)
    (add-partial-3 frq 6.0 dur 3.0)))

(mult 0.04
  (abs-env
    (sim 
      (at 0.0 (gong-3 329 5))
      (at 0.2 (gong-3 360 6))
      (at 0.4 (gong-3 380 5))
      (at 0.6 (gong-3 300 8))
      (at 0.8 (gong-3 430 4))
      (at 2.0 (gong-3 640 4))
      (at 2.2 (gong-3 610 5))
      (at 2.4 (gong-3 580 4))
      (at 2.6 (gong-3 660 5)))))