next up previous contents index
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 $f()$ (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.

Figure 5.5: Block diagram for waveshaping an input signal using a nonlinear function $f()$. An amplitude adjustment step precedes the function lookup, to take advantage of the different effect of the wavetable lookup at different amplitudes.
\begin{figure}\psfig{file=figs/fig05.05.ps}\end{figure}

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 $f()$ 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.6: Clipping as an example of waveshaping: (a) the input, a decaying sinusoid; (b) the waveshaping function, which clips its input to the interval between -0.3 and +0.3; (c) the result.
\begin{figure}\psfig{file=figs/fig05.06.ps}\end{figure}

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

\begin{displaymath}
f(x) = {x^2}
\end{displaymath}

For a sinusoidal input,

\begin{displaymath}
x[n] = a \cos (\omega n + \phi )
\end{displaymath}

we get

\begin{displaymath}
f(x[n]) = {{a^2} \over 2} \left ( 1 + \cos(2 \omega n + 2 \phi) \right )
\end{displaymath}

If the amplitude $a$ 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.

Figure 5.7: Waveshaping using a quadratic transfer function $f(x) = {x^2}$: (a) the input; (b) the transfer function; (c) the result, sounding at twice the original frequency.
\begin{figure}\psfig{file=figs/fig05.07.ps}\end{figure}

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

\begin{displaymath}
x[n] = a \cos(\alpha n) + b \cos(\beta n)
\end{displaymath}

and plugging this into $f()$ gives

\begin{displaymath}
f(x[n]) = {{a^2} \over 2} \left ( 1 + \cos(2 \alpha n) \right ) +
\end{displaymath}


\begin{displaymath}
+ {{b^2} \over 2} \left ( 1 + \cos(2 \beta n) \right )
\end{displaymath}


\begin{displaymath}
+ a b \left [
\cos ( (\alpha + \beta) n ) + \cos ( (\alpha - \beta) n )
\right ]
\end{displaymath}

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,

\begin{displaymath}
f(x+y) = {x^2} + 2 x y + {y^2}
\end{displaymath}

This effect, called intermodulation, becomes more and more dominant as the number of terms in the input increases; if there are $k$ sinusoids in the input there are only $k$ "straight" terms in the product, but there are $({k^2}-k)/2$ 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 $\tau$ so that

\begin{displaymath}
x[n + \tau] = x[n]
\end{displaymath}

and temporarily setting the index $a=1$,

\begin{displaymath}
f(x[n+\tau]) = f(x[n])
\end{displaymath}

(In some special cases the output can repeat at a submultiple of $\tau$, 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 $x$ and $y$ 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:

\begin{displaymath}
x[t + \tau/3] = x[t]
\end{displaymath}


\begin{displaymath}
y[t + \tau/4] = y[t]
\end{displaymath}

which implies

\begin{displaymath}
x[t + \tau] + y[t+\tau] = x[t] + y[t]
\end{displaymath}

and so the distorted sum $f(x+y)$ would repeat after a period of $\tau$:

\begin{displaymath}
f(x+y)[n + \tau] = f(x+y)[n].
\end{displaymath}

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 $f$ as a finite or infinite power series:

\begin{displaymath}
f(x) = {f_0} + {f_1}x + {f_2}{x^2} + {f_3}{x^3} + \cdots
\end{displaymath}

If the input signal $x[n]$ is a unit-amplitude sinusoid, $\cos(\omega n)$, we can consider the action of the above terms separately:

\begin{displaymath}
f(a \cdot x[n]) = {f_0} + a {f_1}\cos(\omega n) + {a^2} {f_...
...\cos^2} (\omega n)
+ {a^3} {f_3} {\cos^3} (\omega n) + \cdots
\end{displaymath}

Since the terms of the series are successively multiplied by higher powers of the index $a$, a lower value of $a$ 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:

\begin{displaymath}
1 = \cos (0)
\end{displaymath}


\begin{displaymath}
x[n] = \cos (\omega n)
\end{displaymath}


\begin{displaymath}
{x^2}[n] = {1 \over 2} + {1 \over 2} \cos (2\omega n)
\end{displaymath}


\begin{displaymath}
{x^3}[n] = {1 \over 4} \cos (-\omega n) + {2 \over 4} \cos (\omega n)
+ {1 \over 4} \cos (3 \omega n)
\end{displaymath}


\begin{displaymath}
{x^4}[n] = {1 \over 8} \cos (-2\omega n) + {3 \over 8} \cos...
... {3 \over 8} \cos (2 \omega n) + {1 \over 8} \cos (4 \omega n)
\end{displaymath}


\begin{displaymath}
{x^5}[n] = {1 \over 16} \cos (-3\omega n) + {4 \over 16} \c...
... \over 16} \cos (3 \omega n)
+ {1 \over 16} \cos (5 \omega n)
\end{displaymath}

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

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 $f_k$ 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 $a$ varies and so we get a widening of the spectrum (and possibly a drastically increasing amplitude) with increasing values of $a$. On the other hand, if some of the $f_k$ 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:

\begin{displaymath}
f(x) = {f_0} + {f_2}{x^2} + {f_4}{x^4} + \cdots
\end{displaymath}

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 $f(x)$, then the output will contain only odd partials. Even if $f$ can't be expressed exactly as a power series (for example, the clipping function of Figure 5.3), it is still true that if $f$ is an even function, i.e., if

\begin{displaymath}
f(-x) = f(x)
\end{displaymath}

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

\begin{displaymath}
f(-x) = -f(x)
\end{displaymath}

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 up previous contents index
Next: Frequency and phase modulation Up: Modulation Previous: Multiplying audio signals   Contents   Index
Miller Puckette 2006-12-30