Envelopes

Amplitude Change

There are two different uses of the word "amplitude":

	1. Maximum amplitude ( A )
	2. Amplitude e at time t,  the sequence of which describes the curve of the wave.
	
 In digital sound synthesis, all sounds are stored as a sequence of amplitudes (usually called "samples").
  		
The maximum amplitude of a wave is set by multiplying the equation by a constant.
This results in a change of the loudness of the acoustic event.

Here is a plot of  one period of a 440 Hz sine wave:

Plot[1 * Sin [ 2 Pi 440 t ], {t, 0, 1/440},
	PlotRange->{-2,2}]

Here is one period of the same frequency, multiplied by 0.5.  Note the correspondingly lower amplitude:

Plot[0.5 * Sin[ 2 Pi 440 t ], {t, 0, 1/440}, 
	PlotRange->{-2,2}]

The same frequency is multiplied by 2 this time.  Note the greater amplitude:

Plot[2 * Sin[ 2 Pi 440 t ], {t, 0, 1/440}, 
	PlotRange->{-2,2}]

Here are the same three examples in sound.  Note the differences in maximum amplitude
among the three.

Play[ 1 * Sin[ 2 Pi 440 t ], {t, 0, 0.25}, 
	PlayRange->{-2,2}]

Play[ 0.5 * Sin[ 2 Pi 440 t ], {t, 0, 0.25}, 
	PlayRange->{-2,2}]

Play[ 2 * Sin[ 2 Pi 440 t ], {t, 0, 0.25}, 
	PlayRange->{-2,2}]

Note:  The PlayRange was set to {-2,2} in the above examples.  If this had not been done, all three would have had the same volume on output (see the section above on Setting the PlayRange).

Decay Envelopes

Envelopes of decay curves are exponential, meaning that the amplitude diminishes to half its magnitude in a constant length of time.

The equation for exponential decay:

	e = A * E^(-lambda * t)
	
where
	lambda = the decay constant
	e = amplitude at time t
	A = maximum amplitude
	E  = exponential constant 
	t  = time
	
The duration of the decay is inversely proportional to the magnitude of lamda.

For a decay of 100db in 1 second, set lamda to 11.5129.
For a decay of 50db in 1 second, set lamda to 5.75646.
For a decay of 10db in 1 second, set lamda to 1.15129.

Decay Envelopes for a Single Tone

This is the complete equation for the decay of sine tone

	e  = A * E^(-lamda t) * sin(omega * t)
	
Here is an examples of decay where lamda = 3:

Play[ (1 * E^(-3 t)) * Sin[ 2 Pi 440 t], {t,0,2},
	PlayRange->All,
	SampleRate->44100]

Here are three plots of the decay of a 4-Hz frequency, with values of 3, 2, and 0.5 for lamda.  Note the lengthening of the time of decay.  A frequency of 4Hz was chosen to simplify the display.

With lamda set to 3, the duration of the decay is about 1.5 seconds:

Plot[(1 * E^(-3 t)) * Sin[ 2 Pi 4 t],{t,0,2},
	PlotRange->{-1,1}]

With lamda set to 2, the duration of the decay is about 2 seconds:

Plot[(1 * E^(-2 t)) * Sin[ 2 Pi 4 t],{t,0,2},
	PlotRange->{-1,1}]

With lamda set to 0.5, the duration of the decay is about 7 seconds:

Plot[(0.75 * E^(-0.5 t)) * Sin[ 2 Pi 440 t],{t,0,7},
	PlotRange->{-1,1}]

Decay Envelopes for a Fundamental with Overtones

The preceding formula assumes that all frequencies in a tone decay at the same rate.  Often they do not.  Higher frequencies tend to damp out faster and thus the timbre of a tone may change with its decay.  Therefore:

	e = Sum[ A/i * E^( - lamda * t ) * Cos[omega * t]

where
	e =  amplitude at time t
	A = maximum amplitude
	E = exponential constant
	lamda = the decay constant
	t = time
	omega = fundamental frequency in radians

Here is a Mathematica function to create an envelope for a sawtooth wave in which the upper partials decay faster than the lower ones:

ComplexDecay[Amplitude_,Frequency_,Harmonics_,
		Decay_,Duration_] := 
	Play[Evaluate[
		Sum[Amplitude/i E^(-Decay t) * 
			Sin[i * 2 Pi Frequency t],
				{i,1,Harmonics}]],
				{t,0,Duration},
				PlayRange->All,
				SampleRate->44100]

And here is a 440-Hz. sawtooth tone, with 22 harmonics, a lamda value of 3, and a total duration of 2 seconds.  Effectually what you are hearing is a sawtooth tone transforming into a sine tone.

ComplexDecay[1, 440, 22, 3, 2]

ComplexDecay2[Amplitude_,Frequency_,Harmonics_,
		Decay_,Duration_] := 
	Play[Evaluate[
		Sum[Amplitude/i E^(-Decay i t) * 
			Sin[i * 2 Pi Frequency t],
				{i,1,Harmonics}]],
				{t,0,Duration},
				PlayRange->All,
				SampleRate->44100]

ComplexDecay2[1, 440, 22, 3, 2]

Growth Envelopes

The growth of a tone is given by:

	e = A * (1 - E^(-lamda * t))
where
	lamda = the growth constant
	e = amplitude at time t
	A = maximum amplitude
	E  = exponential constant
	t  = time
	
The duration of the growth is inversely proportional to the magnitude of lamda.

Here's an example of a 440Hz sine tone with a lamda value of 3:

Play[ (1 * (1 - E^(-3 t))) * Sin[ 2 Pi 440 t], {t,0,1}]

Here's a graph of the same equation, using a 4 Hz tone for simplicity:

Plot[ (1 * (1 - E^(-3 t))) * Sin[ 2 Pi 4 t],{t,0,2}]