what seems to work as I expected are the first 3 , (seq s05 s090) and (seq s05 s90pl).
The rest and perhaps some more ended up with some parts of the result as long as to the end of the original sound.
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:
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:
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:
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
Are you sure s2 is 9 seconds?
What was the original length?
s2 should still be the length of the original audio.
You have set a start and stop time for s1 and s2, (but note that these are really just pointing to the same sound as “s” points to).
Nyquist is unable to work out where you want the sequence to end because the stop time for s is 10 seconds (or however long the selection is).
Although Nyquist does not know where you want the sequence to end, it does know the stop time of s2. The logical stop time tells Nyquist when the next sound should begin to form a sequence of sounds.
So what we could do is to add another sound on to the end of the sequence, and that will start at the correct point. “but I don’t want another sound at the end…”
That’s OK, we will add a null sound to the end:
Sorry but that is probably beyond my ability to explain
It’s all to do with warp, the “environment” and the difference between local and global time.
Rather than saying “errors” it is helpful if you say what the errors are.
To avoid big long error logs in you post you can use the “Code” button like this:
The problem is that you are trying to add a mono sound (s-rest 0) with a multi-channel sound.
For it to work, all of the sounds need to have the same number of channels.
If you know in advance that S will always be stereo then you can create a null stereo sound (vector (s-rest 0)(s-rest 0))
If you want to support mono and stereo you need to make it conditional:
(setf s1 s)
(setf s2 s)
;; mono or stereo null sound
(setf null-s
(if (arrayp s)
(vector (s-rest 0)(s-rest 0))
(s-rest 0)))
;;; dummy function so that we can use multichan-expand
(defun dummy (sig)
sig)
(seq
(multichan-expand #'extract-abs 9 10 (cue s1))
(multichan-expand #'extract-abs 0 1 (cue s2))
(multichan-expand #'dummy null-s))