I’ll split up your code into sections, and demonstrate what each bit does:

```
(setf adsr (pwlv 0 0.05 1 0.3 0.4 0.5 0.4 1 0))
```

This creates an “envelope”, which is a low sample rate control signal.

A “control signal” is just a “sound”, but at a low sample rate, and changing much more slowly that a normal audio waveform.

By default, “PWLV” creates control signals (“sounds”) that have a sample rate 1/20th of the track sample rate.

If you return this kind of “sound”, on it’s own, back to the Audacity track, the length of the sound will be 1/20th of the length that you generated.

The sound returned by PWLV is assigned as the value of “adsr”.

Example,

**(pwlv 0 0.05 1 0.3 0.4 0.5 0.4 1 0)** creates a signal that has length “1”.

If this is in a “generate” type effect (in the Generate menu), then that is “1 second”.

If this is in a “process” type effect (in the "Effect menu), then “1 unit” of time gets stretch to equal the length of the selection.

The “Nyquist Prompt” is, by default, a “process” type effect, so running this command in the Nyquist Prompt will return as sound that is 1/20th of the length of the selection:

```
(setq wigglerate 3)
(hzosc wigglerate)
```

HZOSC generates a sine wave at the specified frequency, which in this case is 3Hz. The sample rate of the Audacity track is used.

The default duration is 1 second, which when run in a process type effect is mapped to the length of the selection:

```
(setq wigglerate 3)
(sum 1 (hzosc wigglerate))
```

Adding “1” to the sine wave, offsets it vertically, so that it has a range of 0 to 2.

I have zoomed out vertically so that you can see the top part of the waveform:

```
(setq wiggle 0.3)
(setq wigglerate 3)
(setf adsr (pwlv 0 0.05 1 0.3 0.4 0.5 0.4 1 0))
(mult adsr wiggle (sum 1 (hzosc wigglerate)))
```

Here we have generated a low frequency control signal “adsr”, and a 3Hz sine wave which is offset vertically, and then we are combining them by multiplication.

Nyquist is clever here, because although the sample rate of adsr does not match the sample rate of the sine wave, Nyquist can handle that and uses the length in seconds, which in both cases is “1”. However, if we are running this in the Nyquist Prompt, 1 second is mapped to the length of the selection.

Each sample in the sine wave is scaled (multiplied) by the value of adsr at the corresponding time.

Note that we are multiplying three things:

- the control signal “adsr”,
- a constant value “wiggle”, which is = 0.3
- the sine wave (hzosc wigglerate)

```
(- 1 (* 2 wiggle))
```

This part is a bit of a distraction. “wiggle” is just the value 0.3, so the above expression simply evaluates to:

1 - (2 * 0.3)

= 0.4

so this:

```
(mult adsr (- 1 (* 2 wiggle)))
```

could be written more simply as:

```
(mult adsr 0.4)
```

which gives us:

SIM is the same as SUM, and is simply a function for adding signals or numbers.

```
(setf adsr (pwlv 0 0.05 1 0.3 0.4 0.5 0.4 1 0))
(setq wiggle 0.3)
(setq wigglerate 3)
(setf envelope
(sim
(mult adsr (- 1 (* 2 wiggle)))
(mult adsr wiggle (sum 1 (hzosc wigglerate)))))
```

So here we are adding the envelope (mult adsr 0.4), with the wiggly line created in the final line, and assigning the result as the value if ENVELOPE:

We can now multiply this envelope with any sound that we like. In the initial code, it multiplies the envelope by the sound from the Audacity track “S”. Alternatively you could generate a sound, and multiply (scale) it with the envelope, for example, here I generate a 440 Hz sawtooth waveform, and multiply it by the envelope:

```
(setf adsr (pwlv 0 0.05 1 0.3 0.4 0.5 0.4 1 0))
(setq wiggle 0.3)
(setq wigglerate 3)
(setf envelope
(sim
(mult adsr (- 1 (* 2 wiggle)))
(mult adsr wiggle (sum 1 (hzosc wigglerate)))))
(setf my-saw-waveform (osc (hz-to-step 440) 1 *saw-table*))
(mult envelope my-saw-waveform)
```