How to capture envelope from one track and apply to another

Using Nyquist scripts in Audacity.
Post and download new plug-ins.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
steve
Site Admin
Posts: 81386
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to capture envelope from one track and apply to anot

Post by steve » Fri Mar 18, 2016 12:10 am

MisterHSP wrote:What has me still puzzled is that when the original selection has a value of 1 (0 dB), the second track is not remaining at it's original level. It is being reduced a bit (approximately 1/3).
Are you using RMS rather than Peak?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

MisterHSP
Posts: 16
Joined: Wed Mar 16, 2016 9:07 pm
Operating System: Windows 7

Re: How to capture envelope from one track and apply to anot

Post by MisterHSP » Fri Mar 18, 2016 12:42 am

steve wrote: Are you using RMS rather than Peak?
No. I am using the defaults across the board. Peak, .1, etc.

John (MisterHSP)

steve
Site Admin
Posts: 81386
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to capture envelope from one track and apply to anot

Post by steve » Fri Mar 18, 2016 12:51 am

Try this:

1) In a new Audacity project, generate 10 seconds of sine tone with an amplitude of 1.0.
2) Duplicate the track (Ctrl+D)
3) Apply the Fade-In effect to the first 4 seconds (approx) of the first track.
4) Apply the Fade-Out effect to last first 4 seconds of the first track.
5) Select both tracks and apply the effect.

Do you get something like this:
tracks000.png
tracks000.png (20.02 KiB) Viewed 2182 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

MisterHSP
Posts: 16
Joined: Wed Mar 16, 2016 9:07 pm
Operating System: Windows 7

Re: How to capture envelope from one track and apply to anot

Post by MisterHSP » Fri Mar 18, 2016 1:00 am

steve wrote:Try this:

1) In a new Audacity project, generate 10 seconds of sine tone with an amplitude of 1.0.
2) Duplicate the track (Ctrl+D)
3) Apply the Fade-In effect to the first 4 seconds (approx) of the first track.
4) Apply the Fade-Out effect to last first 4 seconds of the first track.
5) Select both tracks and apply the effect.

Do you get something like this:
tracks000.png

Yes. It looks just like that.

MisterHSP
Posts: 16
Joined: Wed Mar 16, 2016 9:07 pm
Operating System: Windows 7

Re: How to capture envelope from one track and apply to anot

Post by MisterHSP » Fri Mar 18, 2016 1:04 am

MisterHSP wrote:
Yes. It looks just like that.
However, if I apply the effect again, I get a curving fade in and fade out on the second track, not a straight line.

steve
Site Admin
Posts: 81386
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to capture envelope from one track and apply to anot

Post by steve » Fri Mar 18, 2016 1:04 am

MisterHSP wrote:Yes. It looks just like that.
As you can see in that example, where the peak amplitude in the first track is 1.0 (0 dB), there is no attenuation of the second track. Where the amplitude of the first track is less than 1.0, the second track is attenuated by a proportion equivalent to the peak amplitude of the first track.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81386
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to capture envelope from one track and apply to anot

Post by steve » Fri Mar 18, 2016 1:06 am

MisterHSP wrote:However, if I apply the effect again, I get a curving fade in and fade out on the second track, not a straight line.
Yes, that's correct.
Try applying a (linear) Fade-in effect multiple times to the same audio selection and you will see the same thing happen.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

MisterHSP
Posts: 16
Joined: Wed Mar 16, 2016 9:07 pm
Operating System: Windows 7

Re: How to capture envelope from one track and apply to anot

Post by MisterHSP » Fri Mar 18, 2016 1:12 am

Okay. I still don't understand why the music is reduced in the second track when it is duplicated from the first (and the first is normalized to zero before duplication). They are identical tracks before applying the effect.

It doesn't seem to operate the same on the music as it does on a solid sound slice.

Didn't I read something about "loud* getting set/changed in one of the functions? Could something related to that be at play here?

John (MisterHSP)

steve
Site Admin
Posts: 81386
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How to capture envelope from one track and apply to anot

Post by steve » Fri Mar 18, 2016 1:11 pm

I think I can see where you're getting confused.
I think that you are expecting that the contour of track 2 will be the same as the contour of track 1 after processing. IF track 2 is a solid block of sound, then that will be the case, but if track 2 has a varying level before processing, then it will not have the same contour as track 1 - in some cases it is impossible for it to have the same contour as track 1. Let me try and explain.

"Amplification" is another name for "multiplication" - there is no difference between the two except that when talking about numbers we generally use the term "multiplication" and when talking about sound we generally use the term "amplification". Other than that, the two terms refer to exactly the same operation. For example, if we "amplify" a sound by a factor of 2 (equivalent to +6 dB), then the amplitude at each point in the sound is doubled, that is, each audio sample value is multiplied by 2. Similarly if we "amplify" by -6 dB (a factor of 0.5), then the amplitude at each point is halved (multiplied by 0.5).

Talking about the "peak" option, as that's the simpler one to explain:

When we create the "amplitude envelope", we create a waveform that goes up and down, riding the peaks of track 1. For example, if track 1 is a 10 second tone that starts at amplitude 1.0 and fades out linearly (in a straight line) from 1.0 down to zero, then we can easily calculate the amplitude at each 1 second interval as:

Code: Select all

Seconds   Amplitude
  0          1.0
  1          0.9
  2          0.8
  3          0.7
  4          0.6
  5          0.5
  6          0.4
  7          0.3
  8          0.2
  9          0.1
  10         0.0
So when we make our amplitude envelope, it will do the same.

Now let's say that track 2 is a solid block of sound (a generated tone) with a constant amplitude of 0.8. Then we can calculate what the amplitude at each 1 second interval should be as:

Code: Select all

Seconds   Envelope    track 2   New level
  0        1.0          0.8     1.0 x 0.8 = 0.80
  1        0.9          0.8     0.9 x 0.8 = 0.72
  2        0.8          0.8     0.8 x 0.8 = 0.64
  3        0.7          0.8     0.7 x 0.8 = 0.56
  4        0.6          0.8     0.6 x 0.8 = 0.48
  5        0.5          0.8     0.5 x 0.8 = 0.40
  6        0.4          0.8     0.4 x 0.8 = 0.32
  7        0.3          0.8     0.3 x 0.8 = 0.24
  8        0.2          0.8     0.2 x 0.8 = 0.16
  9        0.1          0.8     0.1 x 0.8 = 0.08
  10       0.0          0.8     0.0 x 0.8 = 0.00
If we do this experiment, we see that the predicted results are pretty close:
tracks000.png
tracks000.png (18.28 KiB) Viewed 2175 times
Now lets say that rather that having a constant level tone in track 2, we have a tone that fades in from 0 to 1.0.
Again we can calculate the expected result as:

Code: Select all

Seconds   Envelope    track 2   New level
  0        1.0          0.0     1.0 x 0.0 = 0.00
  1        0.9          0.1     0.9 x 0.1 = 0.09
  2        0.8          0.2     0.8 x 0.2 = 0.16
  3        0.7          0.3     0.7 x 0.3 = 0.21
  4        0.6          0.4     0.6 x 0.4 = 0.24
  5        0.5          0.5     0.5 x 0.5 = 0.25
  6        0.4          0.6     0.4 x 0.6 = 0.24
  7        0.3          0.7     0.3 x 0.7 = 0.21
  8        0.2          0.8     0.2 x 0.8 = 0.16
  9        0.1          0.9     0.1 x 0.9 = 0.09
  10       0.0          1.0     0.0 x 1.0 = 0.00
and again we can test our prediction:
tracks001.png
tracks001.png (18.1 KiB) Viewed 2175 times
So now we can see that the only way to make the second track have the same shape as the first track, is if the second track has a constant amplitude before we apply the Nyquist code. To some extent we can do this by applying a dynamic compression effect with a very strong setting

What if we start with tracks like this:
tracks002.png
tracks002.png (18.42 KiB) Viewed 2175 times
A couple of applications of the Audacity "Compressor" effect with these setting can even out the level in track 2 quite substantially:
window-Compressor-000.png
window-Compressor-000.png (28.16 KiB) Viewed 2175 times
However, there is no amount of processing that we can do to make the middle section anything other than silence:
tracks003.png
tracks003.png (17.97 KiB) Viewed 2175 times
Then the results of our Nyquist script comes out like this:
tracks004.png
tracks004.png (18.5 KiB) Viewed 2175 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

MisterHSP
Posts: 16
Joined: Wed Mar 16, 2016 9:07 pm
Operating System: Windows 7

Re: How to capture envelope from one track and apply to anot

Post by MisterHSP » Fri Mar 18, 2016 2:15 pm

steve wrote:I think I can see where you're getting confused.
I think that you are expecting that the contour of track 2 will be the same as the contour of track 1 after processing. IF track 2 is a solid block of sound, then that will be the case, but if track 2 has a varying level before processing, then it will not have the same contour as track 1 - in some cases it is impossible for it to have the same contour as track 1. Let me try and explain.
Thank you for going to all the effort to educate me on this. I see what you are saying here. I can see that I may have to just work with the results it gives.

Thanks for staying with me on this and furthering my education.

Warm regards,
John (MisterHSP)

Post Reply