Beginner's question

The Nyquist manual has been written for the standalone version of Nyquist. Nyquist in Audacity is the same computer language, but there are some subtle differences, particularly in relation to how time is handled. These differences can make some of the examples in the manual difficult to understand, so those examples are probably not a good place to start when learning how to use Nyquist in Audacity.

We have some documentation on the Audacity wiki that is about using Nyquist in Audacity. This is probably a better place to start so as to avoid becoming confused by those things:

It doesn’t “reach” the peak level, it simply returns the peak for the first 1000000 samples (about 11 sec).
In contrast, the “ny:all” argument says how much shall be played of the sound. The output can also automatically be normalised to 0.9. The function for this is “s-save-autonorm …”. The rest arguments stay the same. However, noise and highfrequent sounds can be fairly annoying at such a level and cancelling (i.e stopping) the execution of the playing reacts sometimes with a delay.
Returning the sound to Audacity and playing it is clearly not the same. I’ve introduced this command only because the tutorials always use “play”, which doesn’t work properly in audacity, because it atempts to write a file to disk (what sometimes can fail).
I sometimes use the s-save command for certain reasons in the nyquist prompt:

  1. You can play sounds that do not match the sample rate of the track. If you simply return a sound with 22.05 kHz to a 44.1 kHz track, it will play at double speed and an octave higher. With the s-save trick, you don’t have to change the sample rate of the track when you want to “preview” a resampled sound.
  2. You can pass additional information to the dialog box, that appears when the code returns no sound to Audacity, such as in the example above.
  3. You can play an alternative sound from the one you return to audacity. For example you can listen to an envelope, that is applied to a pure sine wave and at the same time return a sound that applies the same envelope to the selected track.
  4. When testing code, you do not have to undo the prompt execution. You take the sound from your track, manipulate it, play it with s-save and in the track the original sound remains the same.
  5. The last point has also the advantage that the stack of undo operations doesn’t use too much hard disk space, which can become a problem when you’re trying your code dozens of times.

By the way, Nyquist and XLISP are full of functions which have different names but do exactly the same. For example:

  • ‘sum’, ‘sim’ and ‘add’ do all combine two sounds to a single one (which will be played at the same time).
  • ‘mult’, ‘prod’ do both multiply a sound with another one (a envelope for example) when only a number is used as first element (constant volume increase/decrease), they will furthermore do the same as ‘scale’ and ‘loud’ (depending on circumstances).
  • ‘first’ and ‘car’ return the first element of a list.
    (The same can be done with: ‘s-read-format’, ‘environment-time’, ‘warp-time’, ‘rand-item-value’ and ‘event-time’)
    Although '(print (first ‘(a b c)))’ and '(print (event-time ‘(a b c)))’ return the same value, they should be applied meaningfully within a code. You see, XLISP is very open and code can therefore appear very confusing for beginners (and old stagers too). The worst case if you don’t understand your own code after a few weeks, that certainly indicates that you’ve done something very, very wrong…

I would like asking a second question. This question concerns an aspect that I do not manage to find in the textbook “Nyquist Reference manual version 2.37 Roger B. Dannenberg”.
This question concerns the synthaxe of a script. How as it is had to organize a script?
It is necessary to follow this order presented in the chapter " Introduction and overview / Examples": to begin with the waveform [(defun mkwave ()], then pass in notes or in succession of notes [(defun notes (osc-tri 84)] or [(play (seq ( c4 ) ( d4) ( e4 )] for example.
Then pass in the envelope [(defun env-note(
(mult (note
(env (]
, finally to end with a linear function [( pwl )]?

There is no concrete order, you should execute your modules according to some logic though.
When you want to model a jar, you don’t begin with burning the clay.
The clay for music is a tone (which is in German the exact same word for both “Ton”). The tone is built up from cycles of a certain wave form (sine sawtooth, custom etc.). If your prototype oscilator is made, you can play the notes at different pitches, but they will most likely sound quite boring.
You now try to give the notes a structure, where the volume changes over time. That’s the envelope you assign to each note. (with attack delay sustain and release or however you want).
Simultaneously, you can add a certain timbre to the notes, which can also change over time. For example, when you’re listening to a bell, you will notice that not all sounds (overtones) are hearable at the same time. the highest ones disappear prior to the lower ones. That’s a filtering comparable to our PWL example (but reversed, the frequency and bandwidth decreases).
There are other envelopes that can have an influence on the sound - like the noise amount for blowed instruments or voices, the feed back of a guitar, the distortion of a forte trumpet etc. However, you want to apply these special effects rather individually on certain notes than on all of them.
Nyquist works therefore with “behaviours” which can be applied to single notes or the whole score and they can be constant or change over time (this will be explained in further tutorials in the documentation). The best advice is still experiment, experiment and experiment again.

I hope that the moderators will understand what I wrote awkwardly.
In fact, I am the order of the textbook.

Well, I have to admit that I don’t understand the last sentence :slight_smile:
However, since we speak four languages in switzerland but english, I can fully understand if a thought can’t be expressed with highest precision.

Hello Sirs.
I would be grateful to a moderator for using.
I have write this script which is clumsy. it generates three chords which notes are of diverse durations. These chords are separated by silences. I think that the end of the script is badly written.

(defun tone ()
(stretch-abs 22.0
(scale 0.05 (osc-pulse 440 0))))
(defun tone1 ()
(stretch-abs 9.0
(scale 0.4 (osc-tri 116))))
(defun tone2 ()
(stretch-abs 7.0
(scale 0.2 (osc-tri 622))))
(defun tone3 ()
(stretch-abs 12.0
(scale 0.1 (osc-tri 2349))))

(defun tone4 ()
(stretch-abs 5
(scale 0.2 (hzosc 440))))
(defun tone5 ()
(stretch-abs 9
(scale 0.3 (hzosc 622))))

(defun tone6 ()
(stretch-abs 9
(scale 0.02 (osc-saw 440))))
(defun tone7 ()
(stretch-abs 23
(scale 0.03 (osc-saw 622))))

(abs-env (sim (tone)(tone1)(tone2)(tone3)
(sum (at 49 (tone4))
(sum (at 49 (tone5))
(sum (at 71 (tone6))
(sum (at 71 (tone7))))))))

On the other hand, I wanted to note exactly in the script, the value in hertz of the note eb4 " tone5 " which is 622,25. When I asked the computer to calculate the result, it did not arrive there. The computer did not stop calculating. Then, I began again another time, and there, the computer in given the result rather quickly. Understand you this problem?

(defun tone3 ()
(stretch-abs 12.0
(scale 0.1 (osc-tri 2349.31))))

(defun tone5 ()
(stretch-abs 9
(scale 0.3 (hzosc 622.25))))

Beforehand I thank you for the time which you take to answer.

There are two easy ways to create a specific frequency.
For sine tones there is:

(hzosc 622.25)

For other waveforms that can be produced with “osc” you can write:

(osc (hz-to-step 622.25))

I have a question very simple to rest. it concerns the following script
(play (mult (lfo 100 10) (pwl 3 1.25 4.5)))

My question is the following one: why the audio sent back by the software lasts only 2 or 3 seconds. As a rule(in principle), it should last 10 seconds if I understand well (lfo 100 10) There is a function [(mult] which multiplies values as a rule. But here, what happens after all?
Beforehand I thank the moderator who will answer.

Firstly, you don’t need to use “play” in Audacity to generate the sound. “play” is used in standalone Nyquist to play the sound. In Audacity, just leave that out and the sound will be generated into the selected track.

(lfo 100 10)

“lfo” is a low frequency oscillator. It generates a signal at the “control rate” not at the track sample rate.

The “control rate” in Audacity/Nyquist is 1/20th of the audio sample rate (the “sound rate”).
If your track sample rate is 44100 Hz, then the control rate will be 2205 Hz. You can check this using the command:

(print *control-srate*)

This means that if you generate 1 second of audio at the control rate, then there will be 2205 samples in that generated signal. However, if you then return that signal to Audacity into a track with a sample rate of 44100 Hz, then 2205 samples will only occupy 1/20th of a second.

Th next point is that when running Nyquist as an effect in Audacity, the duration of the track selection is taken as 1 unit of local time. Therefore, when you run

(lfo 100 10)

It creates 10 “units of local time” - that is, 10 times the duration of the track selection. However, you are generating it at the control rate, which is 1/20th of the track sample rate, so instead of getting 10 times the duration of the selection you will get 10/20 = 1/2 the duration of the selection.

In order to generate 10 seconds of audio, irrespective of the duration of the selection, you must either do it from within a “generate” type plug-in, or use “abs-env”.

(abs-env (lfo 100 10))

but note that this is still at the control rate, so when returned to the track it will be 1/20 of the duration that you want (0.5 seconds).
In order to get 10 seconds, you can resample the sound to the “sound rate” before returning it to Audacity:

(force-srate *sound-srate* (abs-env (lfo 100 10)))

Here the sound (lfo 100 10) is multiplied by a control signal (pwl 3 1.25 4.5)

See here for some examples of envelopes and “pwl”: Introduction and Overview

Hello Sirs.
I thank steve for its comments.
I would like to ask another question on a problem of duration by an audio file generated by Nyquist. I noted well that the duration of the selection in the audio track is important. That this duration is taken as unit of time and which is multiplied by the value " 10 " (lfo 100 10). I noted that these 10 units of local time, that is 10 seconds, are reduced to 0,5 seconds because of the rate of control (10:20=0,5s).
Now, please read this script
(scale 0.5
(pan (scale 0.48 (sine 60 10))
(scale (/ 1 0.697522) (lfo 20 30)))))

I do not understand why this script generates an audio file of 10 seconds where there are 2 sounds of the same duration. In this case, I had selected 1 second in the audio track. The sound of the right channel should last 30 x 1 seconds 30:20 = 1,5 s.

If I use this script
(force-srate sound-srate
(scale 0.5
(pan (scale 0.48 (sine 60 10))
(scale (/ 1 0.697522) (lfo 20 30))))))

The generated audio file has the same duration: 10 seconds (I had selected one second in the audio track). Here, the sound of the canal of right, should last 20 seconds more than the sinusoidal sound.
Beforehand, I thank the moderator for its help

Let us firstly look at the source code of the pan function
excerpt from my nyquist-reference plug-in)

Source-code for this Function (182/358):
Category: Sound Synthesis, as found in :  Nyquist.Lsp

Pans sound (a behavior) according to where (another behavior or a number). Sound must be monophonic. Where may be a monophonic sound (e.g. (ramp) or simply a number (e.g. 0.5). In either case, where should range from 0 to 1, where 0 means pan completely left, and 1 means pan completely right. For intermediate values, the sound to each channel is scaled linearly. Presently, pan does not check its arguments carefully.

Snippet for Nyquist-prompt:
(setf s (abs-env (pan (osc-note c4) (ramp))))
(s-save-autonorm  s ny:all "" :play t)

As you can see, Your sine tone is simply multiplied with the control signal (LFO) for one channel and the inverse of it goes to the other channel. The sine wave has a length of 10 s and the Lfo one of 30 s.
Now, what happens if two sounds are multiplied? If you typed in (mult 10 20), the result would be clear, it is a commonplace multiplication and you’ll get 200 as the result.
Sounds behave somewhat different. At first, all samples at a certain time index are multiplied one with the other. Since all values for the sine wave are 0 after 10 s the following values can be discarded and the resulting sound will also be of length 10 s.
If you reduced the duration of the control signal to 3 s, the output would also be 3 s.
We therefore perceive that the resulting sound after a multiplication will always take the duration of the shortest sound.
By the way, this applies not to summations, because 0 + any value gives still a meaningful result, thus the result of ‘sum’ will take the longest duration.
The force-rate command won’t change anything because one of the multiplied sounds (the sine tone) has already a sample rate of 44100 or so. LFO has a sample rate of 2205 but is already up sampled. Otherwise, the sample values couldn’t be multiplied one with another.
Please bear in mind that pan takes the following arguments:

  • A monophonic sound (the sine wave) which can be placed in the stereo field according to
  • the control signal which can be a number or sound from 0 to 1.
    Your code violates two limits:
  1. The Lfo signal varies between -1 and 1. You must at 1 to ensure that the signal is above 0.
  2. if your scale expression ‘(/…’ is evaluated, you are going to multiply the signal with 1.43365, which is clearly above 1. In the end, the sine wave is therefore scaled too.

What happens if we multiply our sine wave with a negative number? Astonishingly enough, the phase will be inverted. Thus you produse 20 times per second a sine wave, followed by a cosine wave. In some cases, the violation of the limits of the control signal will produce ugly results (including clicks and clipping).
The normal procedure for the preparation of the control sound would be:

  • make the duration exactly as long as the sound to be panned.
  • multiply by 0.5. The lfo goes now from -0.5 to 0.5.
  • add 0.5. the sound goes finally from 0 to 1.
    Those values can be adapted to suit your needs, e.g. if you want the sound to stay prominently in the left channel, you could multiply by 0.25 and add 0.3.
    The sound would now go from 0.05 to 0.55.
...(sum 0.5 (scale 0.5 (lfo 20 10)))...


The first sound (sine 60 10) is only 10 seconds.

Also, as Robert pointed out, the “where” parameter in “pan” should range from 0 to 1, where 0 means pan completely left, and 1 means pan completely right.

Bookmark this page to make it easier to look up functions in the manual: Index

Hello Sirs.
I thank the moderators for their help.
On the other hand, I am sorry, I did not understand the end of Robert J.H.'s message.

“…multiply by 0.5. The lfo goes now from -0.5 to 0.5…”
It is the function [(sum] which multiplies? Either, is it necessary to multiply the duration in seconds of the sinusoidal wave by the value " 0.5" (10x0.5 = 5)? I have the impression that the function [(sum] is used to add behaviors.

“…add 0.5. the sound goes finally from 0 to 1…”
There either I do not understand. Is it the function [(scale] that allows to add the value " 0.5"? I had the impression that this function allows to send back the intensity of a sound by multiplying by the value chosen later ((scale 0.5 = we multiply by the value " 0.5").

Finally, it seems to me that when we use a lfo to modify a sinusoidal wave for example, and when we wish to place in the space the distorted sinusoidal wave, best is not to hear the lfo. Thus, I made tries in this direction, by placing on the same side the sinusoidal wave and the lfo. On the other hand, I am very often confronted with a problem of saturation of the sinusoidal wave.
For exemple:
(sum 0.5
(pan (scale 0.6 (sine 60 10))
(scale 0.8 (lfo 8 10)))))

But I presume that these problems come because I did not well understand how to settle the parameters of this script. I would thus be grateful to a moderator for using again.
Beforehand thank you.

This has one of the same problems as your previous code.
Let’s break down the code into steps, starting at the innermost functions:

(lfo 8 10)
This creates a sine wave, 10 seconds/units duration, 8 Hz, at the control rate. When run as an effect, the duration will be 10 times the current selection unless we cause it to be evaluated using “real” time rather than “local” time. The amplitude is between +1 and -1, so the peak amplitude is 1.0.

(scale 0.8 )
This scales (multiplies) the sound by 0.8, so the peak amplitude will be 0.8.
Test this by running (scale 0.8 (lfo 8 10))

(sine 60 10)
This creates a sine wave, 10 seconds/units duration, with a pitch of 60 “steps” (MIDI note 60) at the sound rate. When run as an effect, the duration will be 10 times the current selection unless we cause it to be evaluated using “real” time rather than “local” time. The amplitude is between +1 and -1, so the peak amplitude is 1.0.

(scale 0.6 )
This scales (multiplies) the sound by 0.6, so the peak amplitude will be 0.6.
Test this by running (scale 0.6 (sine 60 10))

(pan )
This causes to be panned by the control signal .
As shown in my previous post, must be in the amplitude range 0 to +1. Your code is wrong because the amplitude range of in your code is between -0.8 and +0.8

You have not said exactly what you are trying to do, but I’m assuming that you want to pan between -80% and +80%, in which case your code needs to be something like:

(pan (scale 0.6 (sine 60 10))
  (sum 0.5 (scale 0.4 (lfo 8 10))))

It is probably easier to understand if we break this down into sections:
Remember that the pan function with a “where” parameter of +0.5 will be centre panned, so we want the control signal to go up by 0.4 above the centre pan position and 0.4 below the centre pan position.
(scale 0.4 (lfo 8 10)) will generate a low frequency tone with an amplitude from -0.4 to +0.4
If we then add (sum) 0.5 to this tone, (sum 0.5 (scale 0.4 (lfo 8 10))), it will be raised in the track so that its amplitude is in the range +0.1 to +0.9.

We could also write the code as:

(setf mysound (scale 0.6 (sine 60 10)))
(setf where (sum 0.5 (scale 0.4 (lfo 8 10))))

(pan mysound where)

Keep in mind that LISP code is executed from the most inner paran-pair ‘()’ to the outer ones. We produce firstly a sine wave at 20 Hz - that’s the LFO control signal. This wave form gently goes from 0 to 1 to 0 to -1 and to 0 again - 20 times per second. We want to use this signal for the positioning of the actual sound (the sine wave) in the stereo field. Unfortunately, pan needs a signal that ranges from 0 to 1 i.e. the scale is 1. Our waveform has a scale of 2 (-1 to 1), therefore we gonna multiply with 0.5 or in other words, we scale it by 0.5 to get a range -0.5 to 0.5 (= 1 in total). In this case, you can use either ‘mult’, ‘scale’ or even ‘prod’ - the result is always the same - the sound is multiplied by a number in order to limit its range. The duration has nothing whatsoever to do with this operation, that’s a separate thing.

Since scale is used above, the answer must be no; ‘sum’ is used to move the whole waveform up by 0.5 to end up with a control signal that goes from 0 to 1. You can examine the different steps by giving back intermediate results to audacity and having a look at the waveform, e.g. type

(lfo 10)
; or
(sum 0.5 (lfo 20))
; or
(mult 0.5 (lfo 10))
; or
(scale 0.5 (lfo 10))
; or
(mult (lfo 10) 0.5))
; or this one (which does not work)
(scale (lfo 10) 0.5))
; and so on

The last two examples sho the difference between scale and mult: scale can only have a constant or number as the first argument (there are of course other differences which you may encounter in the future).

Hmpf, not so good…

  • the durations do still not have the same lengths (that’s the second argument for ‘sine’ and ‘lfo’).
  • The scale factor of 0.8 would be fine, but the signal goes from -0.4 to 0.4, you should add a value of 0.4 to 0.6 immediately after the scaling of the ‘lfo’.
  • You add 0.5 after the panning of the sound, You thus create a DC-offset - a thing that must be avoided in order to protect your speakers. always try to center the final result.
; verbose example
(abs-env; resets the environment such that unit = 1 s
         (pan; takes two arguments
               (sine ; the mono sound for pan
                     60 ; Midi-note C5 (not Hz!)
                        10) ;Duration of the sine tone
               (sum 0.5; moves the LFO upwards
                    (scale 0.5; shrinks the LFO vertically to 1/2.
                           (lfo; a sine wave at control-srate
                                20; cycles per second
                                   10))))); duration of the LFO signal=duration  sine.

to adjust the volume of the result, you can insert a ‘scale’ command (e.g. (scale 0.8 …) before ‘abs-env’ or ‘pan’ or ‘sine’ and add the closing paren at the right place (for the first 2 ex. at the end).

Hello Sirs.
I thank Robert J.H. for these explanations. I think of having understood. On the other hand, there is another problem. If you well want to observe the following script
(pan (scale 0.48 (sine 60 10))
(scale (/ 1 0.697522) (lfo 2 10))))

If I resumes the previous explanation:
(scale (/1 0.697522) (lfo 2 10)) generate a low frequency tone with an amplitude from ? [+0.43… to +1.43…]
[1: 0,697522= 1,43…]
If I want that the amplitude evolves from [+0.1 to +0.9]. It is thus necessary to move of 5 “notches” towards the “left”.
-0.2 -0.1 0(extrem left) +0.1 +0.2 +0.3 +0.4 (+0.43) +0.5(center) +0.6 +0.7 +0.8 + 0.9 +1(extrem right) +1.1 +1.2 +1.3 +1.4 (+1.43…)
The sound will be carried in the track so that its amplitude is included between [+0,13… and +0,93…]

Thus, my question is the following one: how made one to multiply by a negative value?
[(sum - 0.5 (scale (/1 0.697522) (lfo 2 10)))]

On the other hand, and it is it who worries me, the following solves the problem of saturation on the left canal.
(pan (scale 0.48 (sine 60 10))
(sum 0.5 (scale (/1 0.697522) (lfo 2 10)))))

Thus, I wonder if I perfectly understood.
Beforehand I thank warmly the moderator who will want to help me again.
(sum 0.5 (scale (/ 1 0.697522) (lfo 2 30)))))

On the other hand, I had an idea. He could be interesting to exploit, sometimes, the fact that certain regulations create noises exactly. It could be a search for stamp wished by a composer for example.

There’s still a great deal of misunderstanding, I am afraid.
Please forget your previous code examples, they do not fit into the conventions of the pan command.
Especially the strange scale factor of (/ 1 0.697522).
Can you please explain why do you insist on this value? It is simply too big, as it goes from -1.43 to +1.43 or so.
The only alternative you can use is (scale (/ 1 2.0) … or a value higher than 2 (which gives as result 0.5 or less).
The value after ‘sum’ decides where the sound should be placed in average (0, where 0 means totally left (but the scale must also be 0), 0.5 is the center (with max. scale of 0.5) and 1 is right channel only (scale is 0 again).
As you can see, the scale factor must lie between 0 and 0.5.
If you want that the sound travels between the left border and the center, you can make your decision like this:
The center must lie between left and center, therefore the value after ‘sum’ must be 0.25.
The distance to the right border is 0.75 and the one to the left is 0.25 - which is the smallest one. Simply take this value as upper limit for the scale function (less is always permitted).
This sum and scale factors have nothing whatsoever to do with the “saturation” of the sound (although I don’t exactly understand what you mean with that).
Give us a hint what you want to do next and what sound you want to achieve.
Have fun.

Hello Sirs.
There is a site where the beginners with the language Nyquist can try scripts(“Nyquist for Newcomers” by Brad Lindseth).
It is another problem of panoramic view. Please read this script proposed by Brad Linseth:

(defun stereo ()
(pan (scale .7 (fmosc (hz-to-step 100) (scale 20 (mod)))) (lfo 500 10)))
(defun mod () (fmosc (hz-to-step .1) (lfo .0096 10)))

If I add: (abs-env (stereo)) the console Nyquist creates an audio file of 10 seconds.
A moderator could give me some information onto this script, because I do not understand well how he works.
I hear on the left canal two sounds the height of which varies around an axis. We hears on the right canal one of both sounds which we hear on the left canal.
The problem is that I was not able to found by information about the function (mod ) in the language Nyquist.
If this script does not present error as the previous script which I had evoked [(play (piece (scale .48 (sine 60 10)) (scale (/1 0.697522) (lfo 20 30))))] and which is on the same site of Brad Linseth, I would be grateful to a moderator for expressing its opinion.
Beforehand thank you.

I presume that you are referring to this site?

That code is incorrect. It has the same problem as previous examples in this topic - the “where” parameter should be within the range of 0 to 1 but it isn’t.
I’ve formatted the code to make it easier to read and added some comments. Does this make it easier to understand? Can you see the error?

Without comments:

(defun stereo ()
    (scale 0.7 
           (fmosc (hz-to-step 100)
                  (scale 20 (mod))))
    (lfo 500 10)))

(defun mod ()
  (fmosc (hz-to-step 0.1) (lfo 0.0096 10)))

(abs-env (stereo))

With comments:

;;; Main function. Requires a stereo track
(defun stereo ()
    ;; this generates the <sound> that we will pan
    (scale 0.7 
           (fmosc (hz-to-step 100)
                  (scale 20 (mod))))
    ; this is the "where" parameter
    (lfo 500 10)))

;;; This function is used in creating the <sound>
(defun mod ()
  (fmosc (hz-to-step 0.1) (lfo 0.0096 10)))

;; Calling the functions:

; you can call the (mod) function like this: 
;; (abs-env (mod))

;; call the (stereo) function like this:
(abs-env (stereo))

Hello Sirs.
Yes, the site where I found this script is good http: //
The problem has to be situated at the level of the value given to the function " scale " ( 20 ). On the other hand, and it is which creates the confusion with me, we can find regulations interesting with these “errors”.
For example:
(defun stereo ()
(pan (scale 0.5 (fmosc (hz-to-step 440)(scale 50 (mod))))
(lfo 5 20)))

(defun mod ()
(fmosc (hz-to-step 0.1) (lfo .0096 20)))

(abs-env (stereo))

This script generates a sound which oscillates above and below a value. In a particular musical context, it could be an effect looked for by a musician. We can even use the value: (scale 200 (mod))))
This value amplifies the interval of the glissando around the note. Simply, in this script, we do not master the speed which the height changes. Here, the glissando begins slowly, accelerates then begins to slow down.

Hello Sirs.
I wrote a script by inspiring me of scripts that I found on this forum. My script does not work. I tried various regulations but I do not succeed in generating an audio file.
Would you have the kindness to read my script to say to me where is situated the problem, or, the problems?
Beforehand I thank you.

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

(defun mftone2 () 
 (pan (osc (hz-to-step 440) 12))
  (sum 0.6 (mult 1.5 (amosc (hz-to-step 0.1)
   (scale-srate (noise 2e - 4) 2e - 4)))))
  (at 1 (mftone1 697 1209 2))
  (at 5 (mftone2))))

noise takes one argument.
I suspect that you mean “2e-4” not “2e - 4” or in other words “0.0002”

Also, the parentheses do not match up correctly in mftone2.

I’m not sure exactly what you are trying to do, but perhaps you mean this:

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

(defun mftone2 ()
  (pan (osc (hz-to-step 440) 12)
    (sum 0.6 
      (mult 1.5 
        (amosc (hz-to-step 0.1)
               (scale-srate (noise 2e-4) 2e-4))))))
  (at 1 (vector (mftone1 697 1209 2)
                (mftone1 697 1209 2)))
  (at 5 (mftone2))))

However, note that there is still an error here because (again) the second parameter in the “pan” function should be in the range of 0 to 1 and in this code it exceeds 1. This bug causes the right channel to clip.