Fix for bug in “Envelope” function.

Nyquist contains a function “ENV” (envelope) that is a special form of the pwl (piece-wise linear envelope) which is very useful when synthesizing sounds.

There is a good description of the Envelope function and how to use it in the Nyquist manual. It works in a similar manner to the traditional ADSR envelope that is common in many synthesizers.

Unfortunately  there is currently a bug in the Nyquist code that means that the envelope function does not always work correctly. Here is the technical description of the problem (taken from Audacity’s bug tracking web page)

In the Nyquist function envt1, t2, t4, l1, l2, l3, [dur] if t1 + t2 + 2ms + t4 is greater than the envelope duration, then a two-phase envelope is substituted that has an attack/release time ratio of t1/t4. However, if t1 and t4 are integers then the attack time becomes zero and the release time becomes the duration, which is not what should happen.

If you want to check if your version of Audacity has this bug:
Select less than 3.002 seconds of a track and from the Nyquist Prompt run the code:

The correct envelope is produced with an attack/release ratio of 1:1

Now change the code so that both t1 and t4 are integers:

The envelope is incorrect as in the bug description.

Fortunately there is a fairly easy fix.

Look in your Audacity program folder and in the sub-folder “nyquist” find the file nyquist.lsp. Around about line 1046 there is a line:

Change that line to:

As you can probably work out from the surrounding code in the nyquist.lsp file, the problem exists because if t1 and t4 are integers, then (/ t1 (+ t1 t4)) will always be zero.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.