Fading an effect in and out

Sometimes we may want to fade-in or fade-out an effect rather than have it start and end suddenly. This article looks at how we can do this automatically within an effect. The way that we would do this manually is by duplicating the track, applying the effect to the duplicate, then crossfading the two tracks

While it is possible to call Audacity’s effects from Nyquist using Scripting Commands, it is not possible to combine Scripting Commands with Nyquist processing. Thus we can only use this technique to fade in/out effects created in the Nyquist code.

By way of example, we shall use one of Nyquist’s built-in reverb effects; JCREV. This little snippet applies a bright reverb to the selected audio, with 2 seconds decay and a 50% mix of wet / dry signals:

For the purpose of illustration we shall fade in the effect over 2 seconds, and fade out the effect over the final 5 seconds (we shall assume that the entire selection is greater than 7 seconds duration). To fade the effect, we need to scale (multiply) the effect by a varying amount which we will define as a control signal.

Note that PWLV creates a signal at the Control Rate (1/20th of the Sound Rate) so if applied in the Nyquist Prompt the envelope will appear to be 20 times shorter than expected. This is not a problem as the length will be correct after multiplying by the effect signal (which has the same sample rate as the track).

Applying the above code to a 10 second selection produces a waveform (control signal) like this (below). Note that the length is 0.5 seconds, which is 1/20th of the original selection:

Waveform rises from zero to 1, remains at 1 for a while, then fades back down to zero.

This will do nicely for fading in and out our processed audio, but to achieve a smooth crossfade we also want an envelope to process the original audio from the track. The required envelop may be easily created by subtracting the above envelope from a constant value of 1.

Waveform falls from 1 to zero, remains at 0 for a while, then fades back up to 1.

Now that we have the two envelopes, we can apply the first to our processed audio, the second to the original selection *track*, then mix (“add”) the two together:

Or to tidy it up a bit, envelope and inverse may be made local to the LET block.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.