This is one of the hardest to understand or explain aspects of Nyquist programming and is complicated even further by how Nyquist runs in Audacity.
Basically the problem is that you are mixing up sounds and behaviours and creating contradictory time maps.
There is a section in the manual about Sounds vs Behaviours:
http://www.cs.cmu.edu/~rbd/doc/nyquist/part4.html#28
You may need to read this a hundred times or more (I know that I have

)
Let's look at how SEQ works (correctly) in a "generate" type plug-in:
Code: Select all
(setf s1 (mult 0.5 (noise 2)))
(setf s2 (mult 0.3 (osc 72 5)))
(seq s1 s2)
NOISE and OSC are behaviours.
As expected, this creates 2 seconds of noise followed by 5 seconds of sine tone.
Now let's see what happens in a "process" type plug-in (an "Effect").
Using the same code, we get a noise that is 2 times longer than the selection, followed by a sine tone that is 5 times longer than the original selection.
The reason that this happens is because in analyze and process type plug-ins, the selection always has a "logical time" of 1.
This is often useful as many Nyquist functions have a default duration of 1, and we can easily apply these functions to the Audacity selection without needing to be concerned about the duration. For example, in a process type plug-in, (osc 60) will produce a tone of MIDI note 60 with a duration equal to the selection length.
If we want to use "absolute time" in a process type plug-in, we can do so by wrapping the function within (abs-env beh)
For example:
Code: Select all
(abs-env
(progn
(setf s1 (mult 0.5 (noise 2)))
(setf s2 (mult 0.3 (osc 72 5)))
(seq s1 s2)))
Problems with extract-abs:
As described in the manual, even though "S" is a
sound rather than a
behaviour we can often get round the problem by "cuing" the sound (cue s).
However, this does not get round all of the problems that we might encounter.
If we have a 10 second audio track then we might expect this to work:
Code: Select all
(seq
(extract-abs 9 10 (cue s))
(extract-abs 0 1 (cue s)))
However it fails "error: bad argument type - NIL"
The problem here is that we set the start time of "S" to 9 seconds. but then we are trying to access from 0 to 1 seconds, which we have just defined as 9 seconds before the start of the sound. In effect we are trying to access something that hasn't happened
