Illuminating the Shaper Contraption

I've learned that AudioMulch's Shaper contraption is a mystery to some, hence this week's post is devoted to illuminating the Shaper contraption...

In my last post I used the Shaper to brighten the output of a 10Harmonics contraption by adding extra harmonics. The idea was to create a broad-band pitched tone that I could then filter to sound something like human speech. That's one use for the Shaper. It can also be used to synthesize tones with changing harmonic content in a similar way to other digital synthesis methods like FM. Another way to think of the Shaper is as a type of distortion effect – and in that guise it's capable of some seriously extreme distortion.

Waveshaping 101

Waveshaping is the general term used to refer to the process of bending a waveform to turn it into another waveform. More specifically, it involves mapping amplitudes in an input waveform to different amplitudes in an output waveform. For a computer this is a relatively simple process: for each input sample, look at its amplitude and output the corresponding "waveshaped" output amplitude. I've tried to give an impression of this in the diagram below.

Waveshaping function diagram showing sine wave input and waveshaped output.

The wave shaping function is shown in green at the lower left of the diagram. An input sine wave is shown vertically above the shaping function. The output waveshaped waveform is shown horizontally. Grey lines indicate how the kinks in the waveshaping function correspond to input samples and kinks in the output waveform. Notice how the waveshaping function bends back at the lower left, corresponding to the inverted camel-humps in the output waveform.

The sonic results of waveshaping are not always simple or intuitively predictable. They depend on the waveshaping function (the specific mapping from input to output values), the input waveform, and also the overall amplitude of the input. This last point is a bit unusual because many audio processing effects you might be familiar with (e.g. filtering, reverb, equalisation or mixing) sound the same (aside from loudness) whether you feed in a quiet signal or a loud signal. So, when waveshaping, there are three things to keep in mind: the input waveform, the input amplitude and the waveshaping function.

Enter the Shaper Contraption

A screenshot of the Shaper contraption.

The Shaper contraption provides input gain (to adjust the input amplitude to the shaper), output gain (really just an output volume control), and some controls to adjust the harmonic weightings (we'll get to that in a second). There is also a Shaping function display which shows (surprise) a graph of the shaping function used to map input amplitudes to output amplitudes as I described above.

Perhaps you're wondering "Where did this harmonics weightings business come into the picture? Aren't we all about shaping waveforms around here?" Well, for better or worse, when you apply a waveshaping function to a waveform you change its harmonic content, often adding harmonics which weren't there before. Before you go thinking the Shaper gives you complete and precise control over exact harmonic levels with all input signals and all input amplitudes, I need to point out that the fancy harmonic weightings user interface should really be labeled "Harmonic weightings of the output waveform given a full-strengh sine wave input." If the input isn't a full-strength sine wave, the harmonic content of the output will be different. This leads to some interesting sounds as you'll soon hear.

In general, a waveshaper could use any waveshaping function (perhaps one your cousin drew by hand, or one that corresponds to the nonlinearities in a vacuum tube amplifier). But for the AudioMulch Shaper contraption to offer you the ability to specify the output harmonics weightings (given a full strength sine wave input of course) it uses a very specific waveshaping function computed from the harmonic weightings using a mathematical tool called Chebychev polynomials (named after Russian mathematician Pafnuty Lvovich Chebyshev (1821-1894)). You can read more about the math by googling "chebychev waveshaping", but you don't need to unsderstand the math to use the Shaper contraption.

Waveshaping Sinewaves Batman!

Lets feed a sine wave into the Shaper using a TestGen contraption and see what happens...

An AudioMulch patch showing a TestGen connected to a Shaper connected to SoundOut.

If the TestGen output volume is turned up full, and the Shaper input gain is turned up full then we have our "full strength sine wave input" and adjusting the harmonic weightings acts as you might expect – it adds harmonics with the relative strength shown on the harmonic weightings user interface. If we turn down the Shaper input gain we get something else, something not quite predictable, but usually something with less high frequencies. This is useful because it means variations to the Input Gain more or less correspond to perceived brightness. Also, as we adjust the input gain the timbral evolution is quite interesting – it sounds a lot like simple FM synthesis. Keep in mind that the timbre variations depend on the input amplitude and this doesn't have to be controlled by the Input Gain slider. It could be, for example, the amplitude variation caused by multiple sine waves beating against each other (as you'll see in the screencast below), or an amplitude envelope applied by another contraption (perhaps SouthPole or PulseComb).

Of course you can feed other waveforms into the Shaper too. If you stick to inputs comprised of mixed sinewaves with harmonic relationships (like I did last time using 10Harmonics) or near-harmonic relationships, like a set of carefully tuned TestGen contraptions, you'll get a harmonic output signal (i.e. it will sound like a harmonic tone). If you feed in detuned sine waves you'll get variety of outputs because the sinewaves interfere with each other in complex ways as they are waveshaped. If you're into inharmonic tones this is definitely something to explore.


Since Shaper adds harmonics, feeding in a sound with lots of high frequencies is probably not going to work too well unless you really like nasty, rasping, high frequency hash and distortion (but please, be my guest). One sound that doesn't usually have a lot of high frequencies is the sound of a kick drum, but in some styles of music, a distorted kick drum is just what's needed. Running a kick drum through a Shaper works pretty well. For more control try using an MParaEQ to roll off high frequencies before feeding it to the shaper.

Video demonstrating the AudioMulch Shaper applied to sine waves and kick drums. (Demonstrating at 2:09 that if you're not careful it is possible to drive the Shaper into nasty clipping even after you've gone to the trouble of limiting the output with George Yohng's W1 Limiter.)

The examples I've given here are mostly of the overt synthetic distortion variety, but the Shaper can be used to add subtle, barely noticable "warmth" as well – just stick to a low input level and small amounts of the lower harmonics. For another use, check out the AudioMulch 1.0 "ShapeSynth" example file which uses Shaper to give quite a different timbre to the Bassline contraption.

That's all for now and until next time, Happy Shaping! -- Ross B.