Creating an Amplitude Envelope using an Inverted Parabola

by Pierre-Emmanuel Lévesque

Introduction

This article describes how to create an amplitude envelope using an inverted parabola and provides an implementation in Cycling '74's Max.

Such an envelope is effective for removing clicks at audio signal boundaries, can be used for creating noticeable in and out fades for audio and video, and can be employed to affect other parameters like a sound's pitch. Because it is based on a formula that works for all stages of the envelope, it can be implemented without conditional statements indicating the envelope's stage, and only requires one parameter: the desired fade duration.

Audio Signal Boundary Clicks

An audio signal's amplitude oscillates between -1 and 1 and should start and end on a 0 — a zero crossing — to avoid clicks. We can achieve this with an amplitude envelope.

By multiplying the audio signal with an amplitude envelope having a 𝑦 value that ramps up from 0 to 1, is sustained for a time, and then ramps back down to 0, we are able to ensure zero crossings at the signal's boundaries. 𝑦 values multiplied by 0 will become 0, 𝑦 values multiplied by a number between 0 and 1 will be scaled accordingly, and 𝑦 values multiplied by 1 will retain their original value. This will create a fade-in followed by a sustain period at full amplitude and then a fade-out.

Figure 1: Multiplying an audio signal with an amplitude envelope to remove clicks at the signal's boundaries.

figure 1

Creating a Parabolic Amplitude Envelope

To create an amplitude envelope with an inverted parabola we use the following formula: 𝑦 = 4𝑘(-(𝑥 - 0.5)2 + 0.25)

The particularities of this inverted parabola is that both 𝑥 = 0 and 𝑥 = 1 are clamped to 𝑦 = 0, and all 𝑥 values between 0 and 1 give a y greater than 0. These are ideal conditions for creating an amplitude envelope. We can traverse the parabola from 𝑥 = 0 to 𝑥 = 1 over the timespan of the audio signal to generate all the 𝑦 values of the envelope. By modifying the 𝑘 value to be equal or greater than 1, we are able to heighten the parabola's apex and thusby create faster fades giving us a larger portion of the audio file at full amplitude. Finally, by adding a clipping function, we can force a return of 1 for all 𝑦 values greater than 1. Much like the isosceles trapezoid amplitude envelope in figure 1, this will give us a fade-in followed by a sustain period at full amplitude and then a fade-out.

Figure 2: Parabolic amplitude envelopes with different 𝑘 values.

figure 2

Choosing the 𝑘 Value

Guessing the correct 𝑘 value to create desired fade durations is impracticle.

Instead, we start by choosing a fade duration as a percentage of the total playing time. Since this percentage will be applied to both the fade-in and the fade-out, it must be lower or equal to 50%. It must also be higher than 0% for the mandatory fades to be created.

If we choose an 𝑥 value in the range 0 < 𝑥 ≤ 0.5 to represent our fade percentage of 0% to 50% and a 𝑦 value of 1, we can calculate 𝑘 with the inverted parabola formula defined in the previous section. The formula becomes: 𝑘 = 1 / 4(-(𝑥 - 0.5)2 + 0.25)

Note: We can also start by choosing a fixed time like 500 milliseconds for the fade duration and calculate the fade percentage by dividing this fixed time by the total playing time of the sound signal.

The Complete Algorithm

Figure 3: The complete algorithm implementing an amplitude envelope using an inverted parabola.

figure 3

An Implementation in Cycling '74's Max

Figure 4: An implementation in Cycling '74's Max using gen~ for the parabolic envelope.

figure 4

created:
updatad: