Changing the Shape of a Waveform

How it works:

A sine wave can be played by pressing keys on the computer keyboard. This sine wave passes through a chain of WaveShapers that distorts the shape of the sine wave and adds harmonics. Don’t worry if it sounds distorted—it’s supposed to. Distortion in an audio system is often just unintentional WaveShaping that occurs when the signal exceeds the limits of the system. Whether that is good or bad is your decision.

To do:

  • Scroll down until you can see the black oscilloscope display.
  • Play sine waves by touching keys on the keyboard. Not all keys make sound. Each row is an octave higher. The tuning is a seven-tone scale using just intonation.
  • If the keyboard ever stops playing notes, click on the Play Keys button.
  • Enable one WaveShaper at a time by checking the box next to the formula.
  • Increase the amplitude while holding down a key and notice how the shape changes. Also notice what happens when you reach the top and bottom. You can get clipping even without a WaveShaper.
  • Play a chord and notice that the sound changes dramatically when WaveShaping is turned on. This is because you are now shaping a signal that is more complex than a single sine wave. This results in enharmonic partials. This could be avoided by putting an individual WaveShaper on each sine wave. If the function is linear, "y=ax+b", then it doesn’t matter whether we do the WaveShaping before or after we mix (add) them together. But if the WaveShaping function is nonlinear, "y=x3" or "y=sin(x)", then we get different results depending on whether we apply the WaveShaper before or after mixing.
  • Play a low note. Enable the first WaveShaper "y=x2". Play the same note. Notice that the note sounds an octave higher. This is because the shape of a x2 is a parabola that is symmetric about the y-axis.
  • Turn on several WaveShapers at once. Each one operates on the output of the one above, so "y=g(f(x))".
  • The last WaveShaper is a "soft clipper": "y=x/(1+|x|)" will never exceed the range of –1.0 or +1.0. So it prevents the signal from going beyond the limits that the audio card can handle.