It is possible to make a Nyquist plug-in to copy and paste from one track to the next, but it is quite tricky because Nyquist plug-ins process tracks sequentially and Lisp variables are reset when processing a track is complete. This means that the copied region must be stored somewhere that can survive beyond the processing of that track.
One option is to use the special Nyquist variable SCRATCH. This variable is unique in that it survives in memory after the Nyquist instance finishes.
In the simplest form, you cans test the value of SCRATCH to the selected audio when the plug-in processes the first track, and then return the value of SCRATCH when the plug-in processes the second track. This is not the recommended way for public release plug-ins as it could lead to plug-ins overwriting data required by other plug-ins, or reading data put there by unrelated plug-ins. The recommended way is to use “property lists”, and save data as a uniquely named property. (more information HERE). Nevertheless, setting the value of SCRATCH is quick and easy for an experimental plug-in.
Another problem is that internally, Nyquist uses pointers. In this case, we want SCRATCH to point to the audio data of the first track, but normally the audio data in track is cleared when Nyquist has finished processing the track, so this will not work:
(if (not (boundp '*scratch*))
(setf *scratch* *track*)
*scratch*) ; returns nil audio because *track* was cleared.
So we need to ensure that the audio data from track is retained in memory.
An easy way to do this is with SND-LENGTH
So this will work once:
(if (not (boundp '*scratch*))
(progn
(setf *scratch* *track*)
(snd-length *scratch* ny:all)
"") ;Null string return value
*scratch*) ; returns the audio from *scratch*
but will fail on subsequent runs because we have left *scratch" with Null audio after the second track. We need to reset the plug-in after the second track.
To clear scratch we can set it to 'unbound
(setf *scratch* '*unbound*)
(do this before proceeding)
So putting this altogether:
(if (not (boundp '*scratch*))
(progn
(setf *scratch* *track*)
(snd-length *scratch* ny:all)
"") ;Null string return value
(progn
(setf rval *scratch*)
(setf *scratch* '*unbound*)
rval))
Note that this does not have any error checking, and it is not the recommended way to use scratch, but hopefully it will get you started.
Also note that as the selected audio is retained in RAM, this is not suitable for very long selections.