Next: Frequency and phase modulation Up: Modulation Previous: Multiplying audio signals   Contents   Index

# Waveshaping

Another approach to modulating a signal, called waveshaping, is simply to pass it through a suitably chosen nonlinear function. A block diagram for doing this is shown in Figure 5.5. The function (called the transfer function) distorts the incoming waveform into a different shape. The new shape depends on the shape of the incoming wave, on the transfer function, and also--crucially--on the amplitude of the incoming signal. Since the amplitude of the input waveform affects the shape of the output waveform (and hence the timbre), this gives us an easy way to make a continuously varying family of timbres, simply by varying the input level of the transformation. For this reason, it is customary to include a leading amplitude control as part of the waveshaping operation, as shown in the block diagram.

The amplitude of the incoming waveform is called the waveshaping index. In many situations a small index leads to relatively little distortion (so that the output closely resembles the input) and a larger one gives a more distorted, richer timbre.

Figure 5.6 shows a familiar example of waveshaping, in which amounts to a clipping function. This example shows clearly how the input amplitude--the index--can affect the output waveform. The clipping function passes its input to the output unchanged as long as it stays in the interval between -0.3 and +0.3. So when the input does not exceed 0.3 in absolute value, the output is the same as the input. But when the input grows past the limits, the output stays within; and as the amplitude of the signal increases the effect of this clipping action is progressively more severe. In the figure, the input is a decaying sinusoid. The output evolves from a nearly square waveform at the beginning to a pure sinusoid at the end. This effect will be well known to anyone who has played an instrument through an overdriven amplifier. The louder the input, the more distorted will be the output. For this reason, waveshaping is also sometimes called distortion.

Figure 5.7 shows a much simpler and easier to analyse situation, in which the transfer function simply squares the input:

For a sinusoidal input,

we get

If the amplitude equals one, this just amounts to ring modulating the sinusoid by a sinusoid of the same frequency, whose result we described in the previous section: the output is a DC (zero-frequency) sinusoid plus a sinusoid at twice the original frequency. However, in this waveshaping example, unlike ring modulation, the amplitude of the output grows as the square of the input.

Keeping the same transfer function, we now consider the effect of sending in a combination of two sinusoids with amplitudes and , and angular frequencies and . For simplicity, we'll omit the initial phase terms. We set:

and plugging this into gives

The first two terms are just what we would get by sending the two sinusoids through separately. The third term is twice the product of the two input terms, which comes from the middle, cross term in the expansion,

This effect, called intermodulation, becomes more and more dominant as the number of terms in the input increases; if there are sinusoids in the input there are only straight" terms in the product, but there are intermodulation terms.

In contrast with ring modulation, which is a linear function of its input signal, waveshaping is nonlinear. While we were able to analyze linear processes by considering their action separately on all the components of the input, in this nonlinear case we also have to consider the interactions between components. The results are far more complex--sometimes sonically much richer, but, on the other hand, harder to understand or predict.

In general, we can show that a periodic input, no matter how complex, will repeat at the same period after waveshaping: if the period is so that

and temporarily setting the index ,

(In some special cases the output can repeat at a submultiple of , so that we get a harmonic of the input as a result; this happened for example in Figure 5.4.)

Combinations of periodic tones at consonant intervals can give rise to distortion products at subharmonics. For instance, if two periodic signals and are a musical fourth apart (periods in the ratio 4:3), then the sum of the two repeats at the lower rate given by the common subharmonic. In equations we would have:

which implies

and so the distorted sum would repeat after a period of :

This has been experienced by every electric guitarist who has set the amplifier to overdrive" and played the open B and high E strings together: the distortion product sometimes sounds at the pitch of the low E string, two octaves below the high one.

To get a somewhat more explicit analysis of the effect of waveshaping on an incoming signal, it is sometimes useful to write the function as a finite or infinite power series:

If the input signal is a unit-amplitude sinusoid, , we can consider the action of the above terms separately:

Since the terms of the series are successively multiplied by higher powers of the index , a lower value of will emphasize the earlier terms more heavily, and a higher value will emphasize the later ones.

The individual terms' spectra can be found by applying the cosine product formula repeatedly:

and so on. The numerators of the fractions will be recognized as Pascal's triangle. The Central Limit Theorem of probability implies that each th row can be approximated by a Gaussian curve whose standard deviation (a measure of width) is proportional to the square root of .

The negative-frequency terms (which have been shown separately here for clarity) are to be combined with the positive ones; the spectral envelope is folded into itself in the same way as in the ring modulation example of Figure 5.4.

As long as the coefficients are all positive numbers or zero, then so are all the amplitudes of the sinusoids in the expansions above. In this case all the phases stay coherent as varies and so we get a widening of the spectrum (and possibly a drastically increasing amplitude) with increasing values of . On the other hand, if some of the are positive and others negative, the different expansions will interfere destructively; this will give a more complicated-sounding spectral evolution.

Note also that the successive expansions all contain only even or only odd partials. If the transfer function (in series form) happens to contain only even powers:

then the result, having only even partials, will sound an octave higher than the incoming sinusoid. If only odd powers show up in the expansion of , then the output will contain only odd partials. Even if can't be expressed exactly as a power series (for example, the clipping function of Figure 5.3), it is still true that if is an even function, i.e., if

you will get only even harmonics and if is an odd function,

you will get odd harmonics.

Many mathematical tricks have been proposed to use waveshaping to generate specified spectra. It turns out that you can generate pure sinusoids at any harmonic of the fundamental by using a Chebychev polynomial as a transfer function [Leb79] [DJ85], and from there you can go on to build any desired static spectrum (Example E05.chebychev.pd demonstrates this.) Generating families of spectra by waveshaping a sinusoid of variable amplitude turns out to be trickier, although several interesting special cases have been found, some of which are developed in detail in Chapter 6.

Next: Frequency and phase modulation Up: Modulation Previous: Multiplying audio signals   Contents   Index
Miller Puckette 2006-12-30