How do you get amplitude modulation (tremolo) based on a sample?

I’d like to create an amplitude modulation (tremolo) effect where the tremolo frequency is determined by the pitch of a modulator sample. So, for example, if the modulator is playing a sine wave at 65Hz, the volume of the carrier will go up and down at 65Hz.

It seems like this should be fairly simple to do, perhaps with Audacity’s default tools, but I just can’t work out how. Maybe there’s a script for it?

You mean like “normal” Amplitude Modulation, or do you mean something different?

Not sure… any kind would be good I guess?

To put it another way… I want the amplitude of Waveform A to be determined by the phase of Waveform B.

Or to put it another way, I want to have a tremolo that changes speed depending on the pitch of a modulator waveform.

That is fairly easy to do:
This can be run in the Nyquist Prompt effect

(setf carrier-hz 440)
(setf mod-hz 65)
(mult (hzosc mod-hz)(hzosc carrier-hz))

65Hz is way too fast for musical amplitude-modulation (tremolo) effect.
You’d have to find the fundamental frequency of the note, then apply tremolo at ~1/100th of that frequency.

Amplitude (volume) dependent tremolo would an easier project than pitch (frequency) dependent tremolo.
(e.g. slowing tremolo as the music volume decays).

To clarify, this isn’t for musical tremolo. What I’m actually trying to do is take sound effects and filter them using combinations of multiple tones, to create interesting effects. Kind of like a ring modulator, I guess.

Thanks but this isn’t really what I want. This code produces a specific tremolo at 65Hz. I want the tremolo to be dynamic - based on whatever pitch the modulator is playing. So, if the modulator waveform features an upwards pitch slide, the tremolo will get faster and faster.

Quite simply, I just want the phase of waveform A to determine the volume of waveform B.

Perhaps simple for you, but I don’t understand what you mean.
This is my understanding of “phase” https://en.wikipedia.org/wiki/Phase_(waves)

Sorry for the confusion. How about this explanation…

When the modulator’s waveform is at the top, I want the carrier to play at 100% volume.
When the modulator’s waveform is at the bottom, I want the carrier to be silent.

Another way of putting it is… I want to perform a volume envelope on Waveform A based on the shape of Waveform B.

Where are your “modulator” and “carrier” waves coming from? Are you wanting to generate them, or use the track audio for one or both of them?
If you are wanting to track the pitch of an arbitrary sound, then that is very difficult to do, and you may be best to start looking for a VST effect that gives you what you want.
If you are wanting to generate the tones, then your new description is very much like the code that I’ve already given:

(setf carrier (hzosc 440))
(setf mod (hzosc 65))

(mult carrier 0.5 (sum 1 mod))

That sounds like an envelope-follower. Steve’s dynamic-mirror plugin can do that …

Obviously this isn’t as simple as I had thought it would be!

Both of them are samples (track audio). To me it seemed like a simple thing to do: just map the phase of one to the amplitude of the other?

Thanks, and I do use plug-ins like that all the time, but that doesn’t do what I’m trying to do here as it doesn’t use a high enough time resolution. It will work for very low frequencies like 10Hz, but I want to use frequencies like 2KHz or higher.

In other words, I want to make the volume of a waveform go up and down thousands of times per second.

Make the two audio tracks into a stereo-pair, then apply this code in Nyquist prompt to multiply them …

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

The right channel will be amplitude-modulated by the left.

Using the identical track for both channels will probably sound horrible.
IMO need to low-pass-filter, or pitch-shift-down, the left version if it’s a musical-instrument or voice.

Thanks, that’s pretty close to what I want! :slight_smile:

The only problem is that this creates two oscillations per wave (one for each polarity). I only one want one oscillation per wave, like this:

Use Audacity’s pitch-shift to drop the frequency of the modulator audio down by an octave, before multiplying.

One way to achieve that envelope shape is to full-wave rectify the modulator audio then use the multiply code …

full rectify , then multiply.gif

If you look at this previous example: How do you get amplitude modulation (tremolo) based on a sample? - #10 by steve you should be able to work that out yourself.
So that we can get this topic solved and closed, I’ve done that for you:

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

That looks like a useful plug-in though I couldn’t get it to work (will discuss on the plugin’s own thread…).

I don’t actually know anything about how Nyquist scripting works, I just use other people’s code!

Thank you so much, that seems to have done the job! :slight_smile: Many thanks Steve! :slight_smile:

:wink:
You really should have a go. There is so much that it can do.
These days there’s a lot of information available (see: Manuals and reference material), and we’re always here if you get stuck.