Amplitude modulation is a simple “multiplication” function, like a “tremolo” effect.
There is the “signal” that you want to modulate, and the “modulation wave”.
The “modulation wave” usually has a much lower frequency than the “signal” wave, though interesting effects can be achieved when the two frequencies are quite close together.
The “modulation wave” should normally have a range between 0 and +1 (linear), though more subtle effects can be achieved by using a smaller range below +1.
There is immediately a problem here in that Nyquist can only access one track at a time.
The simplest way to act on two mono tracks, is to manually join them into a single stereo track before you apply the Nyquist effect. See here for how to do that: http://manual.audacityteam.org/man/Splitting_and_Joining_Stereo_Tracks
Audio (mono or stereo) is passed to Nyquist in a global variable “S”. In the case of a mono track, “S” is a “sound”. In the case of a stereo track “S” is an “array” of two sounds - the left channel (upper channel in Audacity) is the first element in the array and the right channel is the second element.
Array elements are numbered starting from zero.
To access an array element we use the function AREF Appendix 3: XLISP: An Object-oriented Lisp
So to access the left channel of a selected stereo track we can use:
(aref s 0)
and for the right channel:
(aref s 1)
The amplitude of normal audio tracks usually in the range +/- 1 (the vertical track scale), but we want the “modulation wave” to be in the range 0 to +1.
We can change the range quite easily by adding 1 to each sample value, then dividing by 2 (x 0.5).
To do this to the right channel of a stereo track:
(mult 0.5 (sum 1 (aref s 1)))
We then want to modulate the “signal wave” (the left channel) by this modified right channel. As said at the top, amplitude modulation is simply multiplication, so we can write:
(mult (aref s 0)
(mult 0.5 (sum 1 (aref s 1))))
or more simply:
(mult (aref s 0) 0.5 (sum 1 (aref s 1)))
How did I do? Could you follow that?
Note that if you only want to modulate simple tones, then rather than messing around with combining tracks into stereo, you can simply generate the tone. For example, to modulate any Audacity track with a 10 Hz sine wave:
(mult s 0.5 (sum 1 (hzosc 10)))
Do you see how this works?
Note that the MULT (multiply) function can be used on mono or stereo sounds as well as with numbers.
Frequency modulation is rather more tricky when using recorded and there are different ways to accomplish the task depending on how long the duration of the sound is. It is much more simple with generated sounds because we can simply use the function FMOSC Nyquist Functions
(fmosc pitch modulation [table phase]) > [LISP]
Returns a sound which is table oscillated at pitch plus modulation for the duration of the sound modulation. osc-table defaults to table, and phase is the starting phase (default 0.0 degrees) within osc-table. The modulation is expressed in hz, e.g. a sinusoid modulation signal with an amplitude of 1.0 (2.0 peak to peak), will cause a +/- 1.0 hz frequency deviation in sound. Negative frequencies are correctly handled. The sample rate is sound-srate.
The definition in the manual is probably quite hard to follow, so here is an example:
Frequency to modulate = 440 Hz
Mudulated at a rate of 5.5 Hz
With a deviation of 12 Hz (+/- 6)
(fmosc (hz-to-step 440)(mult 12 (hzosc 5.5)))