# Nyquist Multipy Sine with LPF Noise

I would like to randomly modulate the frequency, amplitude and phase of the 50Hz (all if possible) with LPF noise. Here is the script I used.

(mult (aref track 0) (aref track 1))

It is hard for me to tell by the output below if I am getting the result I want. Can someone with experience please see if it looks correct? If not, is there a better way?

Also, are there any possible variations on the script that could be applied to more closely define my intended output?

``````(mult (aref *track* 0) (aref *track* 1))
``````

Just does Amplitude Modulation, a/k/a tremolo, (not Frequency Modulation).

Thanks for your reply. The script in my OP was provided by a member of this list a few months back when I asked for one that would perform “multiplication”.

Perhaps I did not make myself clear. I was not referring to AM but rather what is accomplished in analog circuitry by a four quadrant multiplier.

Here is a video that explains the function as it applies to synths. https://www.youtube.com/watch?v=-6jMwvxfEDo

Can anyone suggest a script that will actually do this type of multiplication? IOW simultaneous modulation of amplitude, frequency and phase of the 50Hz signal by the random noise signal. If not, whatever is the closest possible option.

There are virtual modular synths, (some are free) …

(plugin instruments are not going to work in Audacity, you’ll need stand-alone version instead).

To be precise, it does Ring Modulation.

Ring modulation is quite similar to amplitude modulation, with the difference that in the latter the modulator is shifted to be positive before being multiplied with the carrier, while in the former the unshifted modulator is multiplied with the carrier. This has the effect that ring modulation of two sine waves having frequencies of 1,500 Hz and 400 Hz, say, will produce as output signal the sum of a sine wave with frequency 1,900 Hz and one with frequency 1,100 Hz.

For Amplitude Modulation you would use something like:

``````(mult 0.5 (sum 1(aref *track* 0)) (aref *track* 1))
``````

The left clip shows AM, and the right clip shows Ring Modulation:

Yes, I would like to do this entirely within Audacity to the best of its ability.

If I am correct, the multiplication (ring mod) script as per my OP would generate random FM comprised of the transient sums and differences.

That is not exactly what I want. I would like to retain the fixed fundamental but have it vary randomly in frequency, let’s say be 5-10%, according to the noise envelope. In other words it is shallow FM. But I also want simultaneous AM to enrich the sound. Can these two functions be incorporated into a single script?

There’s an app for that …
https ://wiki.audacityteam.org/wiki/Nyquist_Effect_Plug-ins#Random_Pitch_Modulation

Yes, there is a “random pitch modulation” plug in. But it returns the following in debug.

error: unexpected EOF
Function: #<Subr-(null): #0B8BBEB0>
Arguments:
#<File-Stream: #09BA8CE0>
#(
1>

How do I fix this?

The random amplitude and ring modulator plugins work fine. However the latter is not random, and none of the above allow me to apply my own random track and the modulator, e.g. LPF noise. If there is a way to do that, I would really like to know.

The error

``````error: unexpected EOF
``````

is saying that the plug-in is incomplete.
When Nyquist read the code, it reached the end of the script (“End Of Form”) while expecting more code.

Perhaps you didn’t save the entire plug-in script.

The Random Amplitude Modulation (randomamp.ny) works for me (tested on Linux with a 10 second generated tone in Audacity 3.0.2).

I reloaded the random pitch and it is working now. This combined with the random AM is getting me pretty much what I was looking for. See screenshot below.

If anyone knows, I am curious how Audacity generates the random waveform it applies to these plugins. Is there any way its average frequency can be programmed?

This is the text inside the randompitch.ny file (I’ve reformatted it so that the code is easier to read):

``````;nyquist plug-in
;version 1
;type process
;name "Random Pitch Modulation..."
;info "Random Pitch Modulation by David R. Sky"

;control depth "Warping depth" real "depth" 0.100 0.001 2.000
;control maxspeed "Max sweep speed" real "Hz" 0.50 0.01 20.00
;control factor "Sweep depth factor" int "factor" 80 1 300
;control maxdepth "Max pitch mod depth" real "depth" 0.50 0.01 3.00

;; Random pitch Modulation by David R. Sky October 1, 2004
;; As in previous random plug-ins,
;; maxspeed and factor are inversely proportional
;;
;; works on mono and stereo audio
;; if stereo, each channel will have different random modulation

(defun ransiglin (offset factor maxspeed)
(sum offset (lp (mult factor (lp (noise) maxspeed)) (mult 0.5
maxspeed))))

(setf offset (mult 0.50 maxdepth))

(if (arrayp s)
(vector (snd-tapv (aref s 0)
offset
(mult depth (ransiglin offset factor maxspeed))
maxdepth)
(snd-tapv (aref s 1)
offset
(mult depth (ransiglin offset factor maxspeed))
maxdepth))
(snd-tapv s
offset
(mult depth (ransiglin offset factor maxspeed))
maxdepth))
``````

The first part contains “headers” to tell Audacity what kind of plug-in it is:

``````;nyquist plug-in
;version 1
;type process
;name "Random Pitch Modulation..."
;info "Random Pitch Modulation by David R. Sky"
``````

The next part tells Audacity what controls to add to the plug-in interface:

``````;control depth "Warping depth" real "depth" 0.100 0.001 2.000
;control maxspeed "Max sweep speed" real "Hz" 0.50 0.01 20.00
;control factor "Sweep depth factor" int "factor" 80 1 300
;control maxdepth "Max pitch mod depth" real "depth" 0.50 0.01 3.00
``````

The next part just contains some comments (comments are ignored by Audacity and Nyquist):

``````;; Random pitch Modulation by David R. Sky October 1, 2004
;; As in previous random plug-ins,
;; maxspeed and factor are inversely proportional
;;
;; works on mono and stereo audio
;; if stereo, each channel will have different random modulation
``````

The final part is the actual code:

``````(defun ransiglin (offset factor maxspeed)
(sum offset (lp (mult factor (lp (noise) maxspeed)) (mult 0.5
maxspeed))))

(setf offset (mult 0.50 maxdepth))

(if (arrayp s)
(vector (snd-tapv (aref s 0)
offset
(mult depth (ransiglin offset factor maxspeed))
maxdepth)
(snd-tapv (aref s 1)
offset
(mult depth (ransiglin offset factor maxspeed))
maxdepth))
(snd-tapv s
offset
(mult depth (ransiglin offset factor maxspeed))
maxdepth)
``````

The function “ransiglin” (“random signal in” ??) generates the random waveform.

Looking at “ransiglin” more closely:

``````(defun ransiglin (offset factor maxspeed)
(sum offset (lp (mult factor (lp (noise) maxspeed)) (mult 0.5
maxspeed))))
``````

The three parameters; offset, factor, and maxspeed, are derived from these three controls:

``````;control maxspeed "Max sweep speed" real "Hz" 0.50 0.01 20.00
;control factor "Sweep depth factor" int "factor" 80 1 300
;control maxdepth "Max pitch mod depth" real "depth" 0.50 0.01 3.00
``````

where “offset” is half of “maxdepth”

``````(setf offset (mult 0.50 maxdepth))
``````

Using those three parameters, “ransiglin” filters white noise to create the random waveform.

Because “ransiglin” uses a low-pass filter applied to white noise, the average frequency of the random waveform will be between 0 and “maxspeed” (in Hz).
If you want an average, say, between 10 Hz and 50 Hz, you could modify the plug-in to have both a maximum and minimum frequency, and then in “ransiglin” you would apply a high-pass filter at the minimum frequency, and a low-pass filter at the maximum frequency.