Stuck with a SynthEdit project?

Category: Waveshaper

Creating a Voltage Controlled Waveshaper in SynthEdit.

Having some control over the waveshaper (although not over the actual transfer curve in the module) is possible in as far as the depth of the shaping effect, and the polarity of the shaping effect can be voltage controlled using a few stock modules, and one extra from Elena Novaretti’s module packs at www.elenadesign.eu, the ED Range Clipper which limits the amount by which the control voltages can be varied- this is used to prevent the control voltage exceeding the normal range for the waveshaper and causing unpredictable results.
The Intensity (or depth) of the effect can be varied between 0 V (minimum shaping) and 10 V (maximum shaping). This is then fed to the X-Mix module directly to Input B, and through an Inverter2 module to Input A. This allows us to effectively change the polarity of the waveform, which is then added to the Input audio at the final Level Adj module.
Of course you’re not limited to just using the Waveshaper3 module, you could just as easily use the Waveshaper2 module and use a formula for the transfer curve.

Voltage controlled waveshaper diagram

So far this is the best I have been able to come up with, but I’m as always going to keep experimenting so “watch this space” for updates on this technique

DH-Wshape2 Third party waveshaper module.

Hands up all those who love the sound of “Digital” Synthesizers? If you do then one of this module is for you. Especially if you want to be able to control the amount of Waveshaping by using a control voltage.
It’s a “Third Party” module courtesy of RH Modules http://www.rhmodules.nl/downloads/dspgui/
The basics are quite straightforward. The ‘Scope and 1kHz Oscillator modules are included just to show the effect of the DH-Waveshaper. The default for the Shape control voltage is +/- 5 Volts, but this can be increased to +/- 20 Volts to give a wider range of shapes. See the screenshots below…
The only waveforms that aren’t worth putting through the waveshaper are a pulse (you’ll get some wild amplitude changes and some very large spikes on the leading and trailing edges), or noise. Unlike the SynthEdit stock Waveshapers there are no formulae to set up, just a control voltage

The effect of +20 Volts Shape CV
This gives and extreme foldback effect on the positive and negative peaks of the audio input.

Output of the waveshaper with +20V gain CV

The effect of 0Volts Shape CV
Here we get a slight flattening of the sine wave peaks which gives a very subtle distortion, almost like a slightly overdriven valve PA.

Output of the waveshaper with 0V gain CV

The effect of -5 Volts Shape CV
This gives us a “crossover distortion” effect where the audio input doesn’t start to appear at the output a until the audio input has risen slightly above 0 volts.

Output of the waveshaper with -5V gain CV

The effect of -20 Volts Shape CV.
Starts folding back the 0 volts crossover portion of the audio input.

Output of the waveshaper with -20V gain CV

Modulating with an ADSR module.
Just as a basic “bare bones” idea of what’s possible, you could have the waveshaper modulated by an ADSR2 triggered by the keyboard so the peak level of the audio is the most distorted.

Control the waveshaper with an ADSR module

Modulating with an LFO Module.
Or a free running LFO so that the distortion varies slowly (or rapidly) over time

Control the waveshaper with a LFO module

SynthEdit Waveshaper2b

This one is available in both SynthEdit V1.4 and V1.5
However there is a GUI module you can use to display the transfer curve from your formula which is only available in V1.5.

Waveshaper 2B in SynthEdit 1.4

This gives us a text box for entering our formula, with no means of displaying the Transfer Function curve.

Waveshaper2B in SynthEdit 1.4

Waveshaper 2B in SynthEdit 1.5

Whereas in V1.5 we have an additional module Waveshaper 2B GUI, which allows us to display the curve. Now the only real difference between Waveshaper 2 and 2B is that we can have a separate text box for entering our formula which can be resized for longer formulae, and by using a third party Text Entry module (such as the ED or DAM modules) can be customized to give control over font and background colours.

Waveshaper2B in SynthEdit 1.5

So with a little work we can have a demo that shows the input signal, the formula, which can be edited, the resulting curve, and the resulting output waveform.

Waveshaper2B demo in Syn
thEdit 1.5
Panel view of the Waveshaper demo

A SynthEdit Waveshaper Prefab.

This design uses some pre-defined mathematical functions to shape the input waveform. The Formulae for the shaping are all held in a Fixed Values (Text) module from where they can be selected.
These values are sent to a Switch > Text module. From there they are fed to the Waveshaper2B module where the mathematical function is applied to the input waveform. The 1 Pole HP filter is to block any DC component that the Waveshaper might introduce. From there the X-Mix module sets the balance between the unaltered input, and the shaped signal.

Notes:
All the Slider controls are left at their default values.
Formula 12 (Folding) is purely a foldback distortion, the Sin and Cos formulae add some 2nd/3rd/4th harmonics giving a formant like sound to a sine or triangle input.
Using Sqrt (Square Root) formulae can give some quite spiky waveforms.
Formulas used:
1) Sin: 6sin((x+2/PI)+(x+2/PI))
2) Cos: 5cos((x+5/PI)+(x+5/PI)) 3) ASin 2asin((x/PI)+(x/PI))
4) Acos: 2acos((x/PI)+(x/PI)) 5) Sqrt 5 sqrt((x/PI)+(x/PI))
5) Sqrt: 5*sqrt((x/PI)+(x/PI))
6) -Sqrt: -5*sqrt((x/PI)+(x/PI))
7) Sin Cos: 6*sin((x+2/PI)+cos(x+2/PI))
8) Cos Sin: 6*cos((x+2/PI)+sin(x+2/PI))
9) Default: 5*sin(x/PI)
10) 3*Sin: 6*sin((x+2/PI)+(x+2/PI)+(x+2/PI))
11) 4*Sin 6*sin((x+2/PI)+(x+2/PI)+(x+2/PI)+(x+2/PI))
12) Folding: 3 *(abs(-abs(-abs(x+1.25)+2.5)+2.5)-1.25)
Other functions can be used, although some may result in outputs with a very high amplitude, or nothing at all, feel free to experiment.

Structure of the waveshaper prefab

Adding a Butterworth High Pass filter will also greatly reduce any unwanted low frequency “rumbles” which can be introduced.
As you can see in the Frequency Spectrums below the layout with the Butterworth High Pass filter in circuit, a lot of the “noise” below 200Hz is drastically reduced. The filter was set to a cut-off frequency of 200Hz, and the number of filter Poles to 12.

Adding a better high pass filter to the prefab

Unfiltered output:

Filtered output (about 200Hz High-Pass):

SynthEdit Waveshaper 3

This is a purely graphical waveshaper. It’s still a DSP module, so there is no need for any conversion between GUI and DSP data.
Although there is the Waveshaper2 or 2B, if you’re not mathematically inclined, or want to allow your plugin users to change the waveshaper’s function then this is by far the easiest solution. It’s very intuitive, you just click on a node (one of the small green squares) and drag it till you get the result you want. You can see below how dragging the nodes changes the output waveform.

Effect of moving nodes on the transfer curve

You just need to be aware that moving the centre node (0,0) can cause some issues with clicking and unwanted DC offset voltages (for audio you could put a high-pass filter set to about 50Hz cut-off pitch to filter out the DC component), when dealing with LFO’s or modulation envelopes you really do want to avoid moving the 0,0 node.
Another advantage is that as your plug-in users are unable to enter values into the waveshaper, they can’t cause the output to exceed the default +/- 5 Volts for Audio voltages.
The best way to learn this module is to connect it up and try dragging the nodes to see what the result is.

A test setup for the Waveshaper 3 module

SynthEdit Waveshaper 2

A Wave-Shaper distorts or modifies the input voltage depending on the transfer function that you specify. They can be used as a distortion unit, soft clipper, waveform modifier or control voltage transfer function (e.g. velocity response curve), they are to say the least, versatile.

Waveshaping is also a popular synthesis technique that turns simple sounds such as a sine wave into more harmonically complex sounds.
A guitar fuzz box is an example of a very basic waveshaper. The unamplified electric guitar sound is fairly close to a sine wave. But the fuzz box works by amplifying it to the point where the input clips the peaks of the signal in an amplifier designed to clip at moderate signal levels. A signal that is clipped has many more high frequency harmonics added to its spectrum. Sounds that have passed through any type of waveshaper will have a lot more high frequency harmonics, which gives them a “richer” sound.

Table based Waveshaping.

As you can probably imagine doing all these calculations in real time at audio frequencies is going to be a lot of work for the computer. So we generally pre-calculate these polynomials and put the results in a table. Then when we are Waveshaping sounds, we just take the value of the audio input and use it to look up the answer in the table. In the world of computer programming this is called optimization, and it greatly reduces the load on your CPU.
One big advantage of using a table is that regardless of how complex the original equations were, it always takes the same amount of time to look up the answer. You can even draw a function by hand without using an equation and use that hand-drawn function as your transfer function.

The SynthEdit Waveshaper2 module.

A simple waveshaper transfer function

The Waveshaper 2 module is just an in-out module, where you specify the transfer function either in the text box on the module, or in the module’s properties panel. Changing the formula will also change the curve in display that represents the transfer function

Changing the waveshaper transfer function formula-the effect

Note:
Input Levels: The input voltage is internally clipped at +/- 5 Volts, while it won’t do any harm to exceed these values, the results won’t bear any relation to the expected results from the formula.
Output Levels: These may be higher or lower than the default SynthEdit level of +/- 5 Volts depending on the transfer function specified. We can adjust the formula to compensate for this, we just change the multiplier at the beginning of the transfer function (shown in bold): Output = 5*sin(x/PI)

A simple Waveshaping Formula.

A waveshaper in DSP form can be described as a function that takes the original input signal x, and applies a mathematical formula to the input thus producing a new output signal y. This function is called the transfer function. A simple example in SynthEdit is shown below:

Showing the effect of the Waveshaper basic formula on a sine wave

Here we use a simple equation: Output = 5*sin(x/PI), the important part (the transfer function) is shown in bold. we merely multiply the results of the transfer function by 5 to restore the output to its normal SynthEdit +/- 5 volts peak to peak audio level.
In order to change the shape of the function (and not just make it bigger or smaller), the function must be nonlinear, which means it has exponents greater than 1, or functions (this is where we use sines, cosines, exponentials, logarithms, etc.). You can use almost any function you want as a waveshaper. But the most useful ones output zero when the input is zero (that’s because you usually don’t want any output when there is no input-this will result in unwanted clicking noises).

Showing the effect of changing the Waveshaper formula to 5 * sin((x*1.2)/PI)

If we change the equation slightly to: 5 * sin((x*1.2)/PI) the bold section is the change we insert, then the output goes from having the peaks flattened out, to a small amount of foldback, the greater the number we use to multiply x, the greater the waveform is folded back on itself- see below where it’s increased to x*1.8

Showing how the formula affects the Waveshaper output

Increasing the Input voltage:
What happens if we exceed the usual SynthEdit audio levels? Well with the most basic function we used in the first example you might possibly think you’ll get a result like we had in the last example where it starts to fold back, but it doesn’t it just goes into “hard clipping”. To demonstrate I put an amplifier between the signal source and the waveshaper with a gain of *3- you can see the result below.

Increasing the input above +/- 5V does not produce the expected results from the Waveshaper

And if we take the function that gave us the foldback:- 5 * sin((x*1.8)/PI),
and increase the input above the default level, then the following happens:

Increasing the waveshaper input above +/- 5V does produce some strange results

The reason for this is that the input of the Waveshaper modules in SynthEdit is internally limited to the default of 10 volts peak to peak, so when we reach the clipping voltage the waveform loses its sine wave like shape and is clipped. So to ensure correct operation we need to ensure that the input never exceeds +/-5 Volts (especially when using external audio sources). Likewise the result of the function must be scaled correctly to restore the default output of+/- 5 Volts audio that SynthEdit uses.

Need to convert a Sine wave to a Square wave?
Then this formula will do the job for you: 5*sgn(x/pi)

Converting a sine wave to a square wave with the Waveshaper

If we want to “pull” a sine wave into more pronounced peaks the following formula works well: 0.15 * sinh(x/1.2)

Producing a more exponential transfer curve from the waveshaper

Which also has a useful effect on Sawtooth and Triangle waves, so you can see how this can also be useful for manipulating envelopes and control voltages provided we pay close attention to the input and output voltage swings.

Effect of the new curve on a sawtooth
Effect of the new curve on a triangle wave