If I want to (say) multiply two adjacent Audacity tracks in Nyquist, how do I access them in Nyquist? I know that I could create a single stereo track out of the two mono tracks, and then do (vector (aref s 0) (vector (aref s 1)), but perhaps there’s an easier way?
Audacity passes the audio from one track to Nyquist, then after Nyquist has returned a result (and not an error) Audacity passes the next track, so there is no way to pass two tracks at the same time (other than as a stereo track).
It is possible to copy audio from one track and save it to SCRATCH and then use that data on the second track, but there are several hidden problems. The first is that if you simply (setf scratch s)
You may expect the following to work, but it doesn’t:
(if (not (boundp '*scratch*))
(setf *scratch* s)
(progn
(setf output *scratch*)
(setf *scratch* '*unbound*)
output))
The problem is that in line 2 scratch points to the value of “S”, but when Nyquist exits after the first track, “S” is cleared so scratch is left pointing to nothing.
For short tracks, the easiest way to pass a sound in scratch is as an array, then use snd-from-array to get it back. The downside is that arrays use a lot of RAM.
Given the difficulties of using scratch, making a stereo track is sometimes the best option.