Beginner's question

Hello Sirs.
I thank Steve for his comment. If I had noted the value " 12 "it was because I believed that this value would be the duration in seconds of the sound affected by a random pan. After all, I try to generate a sound at the end of 35 seconds. I would like that this sound lasts 12 seconds. It will be affected by a random pan during a little less than 12 seconds.
I was not unfortunately able to tried the corrected script, because it does not work with my software Audacity 2.0.3
So, I wrote another rather close script by hoping that it will work with a correction.
Beforehand, I thank the moderator who will take time to correct these clumsiness.

(defun mftone1 (hz1 hz2 dur)
(mult 0.5
(sum (osc (hz-to-step hz1) dur))
(osc (hz-to-step hz2) dur)))

(defun mftone2 (hz1 dur)
(mult 0.5
(osc (hz-to-step hz1) dur)))

(defun mftone3 ()
(pan (osc (hz-to-step 440) 0.2)
(sum 0.6
(mult 1.5
(amosc (hz-to-step 0.1)
(scale-srate (noise 2e-4) 2e-4))))))

(at 0 (pan (mftone2 697 10) 0.1))
(at 10 (pan (mftone2 1477 19) 0.9))
(at 30 (pan (mftone1 697 1477 1) 0.2))
(at 35 (mftone3))))

This script is bad because the sound “mftone3” lasts only 200 thousandth of the second.

I propose that you re-read all the previous posts to find the wrong values, which are stil not yet corrected.
the value 0.2 is a duration, neither the amplitude nor anything else.
It is best to write all functions down which you come across, with the proper arguments at the proper places. Additionally, you can add the limits for the specific functions.
For example:
(PAN sound where)

  • sound: mono values -1 to 1
  • where: signal/sound/number val 0 to 1 (otherwise clipping)
    If you’ve forgotten the arguments of a function, you can look them up (if the function is not with prefix ‘snd-’) right from within the Nyquist prompt:
    (args 'pan)
    Don’t forget the '.
    (grindef 'pan) shows the source code. Press the debug button to study the information.
    You can place these functions after the code that is already in the prompt. When you’re done, just remove the line and go on testing your script.

Hello Sirs.
I found this code on the forum. it generates glissandis. On the other hand, it is very difficult to have a control of this code.
The code is the following one:
(defmacro sweep (dur)
`(stretch-abs 1 (mult (pwl 0 0.8 dur 0.05 dur)
(hzosc (sum 440 (mult 3360 (ramp dur)))))))

(defun lowpass (sig hz)
(force-srate (* hz 2) sig)(snd-srate sig)))

(s-rest 1) (s-rest 1)
(at-abs 15 (lowpass (sweep 4)840))))

Would it be possible to use this random effect hanging a few seconds of a sound? Let us imagine the following sinusoidal sound:
(scale 0.5
(osc (hz-to-step 697) 19)))

It would be possible, for example, to allocate to the sound these glissandis during 4 seconds. Of time t1 = 4s in time t2 = 8s for example. Before t1 and after t2, we would hear that the sound sisnusoïdal.
Beforehand thank you for the information.

To help us know what you are talking about When giving examples from the forum, please include a link to the post that you are referring to.
To copy the link to the specific post, click on the “permalink” button in the top left corner of the post, then copy the address from your web browser.

Also, please use the “Code” tags when entering code.

You are quoting from Robert’s post (A Study in Pink - #23 by Robert_J_H) so I’ll leave it to him to comment on his code.