In that plug-in, no, but if linear panning is OK then it would be quite easy to code.
The underlying mechanism for panning is to push the sound over to one side of the stereo mix and then over to the other side.
As an example, if you have a stereo track and you want it to be panned hard left…
Stereo tracks are passed to Nyquist as an array of 2 sounds. The variable (symbol) used for this array is “S” (Nyquist is not case sensitive so it can be upper-case or lower-case “S”).
The first element in the array is the left channel. The second element is the right channel.
The elements of an array are numbered from 0 (zero).
To access the element of an array, you would use the function AREF.
So the left channel of the array “S” can be accessed with (aref s 0) and the right channel with (aref s 1).
In order to return a stereo sound to Audacity, an array of two sounds must be returned.
The easiest way to do that is with the function VECTOR.
Thus, to swap the left and right channels of a stereo track you can use:
(vector (aref s 1)(aref s 0))
In the simplest case, if we want to pan a stereo track to the left, we can simply silence the right channel.
An easy way to make a sound silent is to multiply it by zero.
(vector (aref s 0) (mult (aref s 1) 0))
Similarly we can pan all the way to the right:
(vector (mult (aref s 0) 0) (aref s 1))
In order to gradually pan from one side to another, we need our “multiplication factor” to vary over time. We can do this by creating a control signal.
Here we run into a little peculiarity of Nyquist in Audacity. For effects, time is, by default, relative to the length of the selection. Thus a duration of “1” is the length of the selection. We can override that behaviour if we need to (and we will later) by specifying that we want to use “absolute” time rather than relative to the selection, but for now let’s stick with relative to the selection.
There are a series of functions called “piece-wise linear approximations” (http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index386)
We don’t need to consider all of the variations right now - for this example we will just use the PWLV variant.
PWLV can create a control signal from a series of coordinates (“break points”) in a similar fashion to “Envelope Points” when using the Envelope Tool in Audacity. Each “break point” has a time and a value. The control signal extrapolates from one point to the next in a straight line (hence linear approximation).
For PWLV, each break point has a time, followed by a value (amplitude), except that the initial time is assumed to be zero.
Thus to create an “envelope” that goes from zero at time = zero to 1 at time = 1:
(pwlv 0 1 1)
That’s a tricky example because it’s all 0’s and 1’s, so let’s change it a little and make it go from 0.1 at time zero to 0.9 at time = 1
(pwlv 0.1 1 0.9)
So then we can multiply our sound by the control signal. First we assign a symbol (name) to the control signal, then multiply the sound by the control signal.
(setf envelope (pwlv 0.1 1 0.9)) ; "envelope" is the symbol we have used for the control signal
(vector
(mult (aref s 0) envelope)
(mult (aref s 1) envelope))
That’s fine as far as it goes, but to get a panning effect, we want the right channel to fade in the opposite direction.
For a linear pan from 90% right to 90% left.
(setf left-channel (pwlv 0.1 1 0.9))
(setf right-channel (pwlv 0.9 1 0.1))
(vector
(mult (aref s 0) left-channel)
(mult (aref s 1) right-channel))
or for a linear pan the other way:
(setf left-channel (pwlv 0.9 1 0.1))
(setf right-channel (pwlv 0.1 1 0.9))
(vector
(mult (aref s 0) left-channel)
(mult (aref s 1) right-channel))
— more to follow —