Waveshaper
Encyclopedia
In electronic music
a waveshaping is a type of distortion synthesis
in which complex spectra
are produced from simple tones by altering the shape of the waveform
s.
s to achieve an extra-abrasive sound. This effect is most used to enhance the sound of a music synthesizer
by altering the waveform or vowel. Rock musicians may also use a waveshaper for heavy distortion
of a guitar or bass. Some synthesizers or virtual software instruments have built-in waveshapers. The effect can make instruments sound noisy or overdriven.
In digital modeling of analog audio equipment such as tube amplifiers, waveshaping is used to introduce a static, or memoryless, nonlinearity to approximate the transfer characteristic of a vacuum tube
or diode
limiter.
from systems theory). The function can be any function at all.
Mathematically, the operation is defined by the waveshaper equation
where f is the shaping function, x(t) is the input function, and a(t) is the index function, which in general may vary as a function of time. This parameter a is often used as a constant gain factor called the distortion index. In practice, the input to the waveshaper, x, is considered on [-1,1] for digitally sampled signals, and f will be designed such that y is also on [-1,1] to prevent unwanted clipping in software.
is a function of the form
Polynomial functions are convenient as shaping functions because, when given a single sinusoid as input, a polynomial of degree N will only introduce up to the Nth harmonic of the sinusoid. To prove this, consider a sinusoid used as input to the general polynomial.
Next, use the inverse Euler's formula
to obtain complex sinusoids.
Finally, use the binomial formula to transform back to trigonometric form and find coefficients for each harmonic.
From the above equation, several observations can be made about the effect of a polynomial shaping function on a single sinusoid:
With relatively simple, and relatively smooth waveshaping functions (sin(a*x), atan(a*x), polynomial functions, for example), this procedure may reduce aliased content in the harmonic signal to the point that it is musically acceptable. But waveshaping functions other than polynomial waveshaping functions will introduce an infinite number of harmonics into the signal, some which may audibly alias even at the supersampled frequency.
Electronic music
Electronic music is music that employs electronic musical instruments and electronic music technology in its production. In general a distinction can be made between sound produced using electromechanical means and that produced using electronic technology. Examples of electromechanical sound...
a waveshaping is a type of distortion synthesis
Distortion synthesis
Distortion synthesis is a group of sound synthesis techniques which modify existing sounds to produce more complex sounds , usually by using non-linear circuits or mathematics....
in which complex spectra
Spectra
Spectra are conditions or values that vary over a continuum.Spectra may also refer to:* Kia Spectra, a car developed by Kia Motors from 2000-present* Optare Spectra, a bus body built by Optare...
are produced from simple tones by altering the shape of the waveform
Waveform
Waveform means the shape and form of a signal such as a wave moving in a physical medium or an abstract representation.In many cases the medium in which the wave is being propagated does not permit a direct visual image of the form. In these cases, the term 'waveform' refers to the shape of a graph...
s.
Uses
Waveshapers are used mainly by electronic musicianElectronic musician
An electronic musician is a musician who composes or plays music from synthetic sounds generated with synthesizers, samplers, drum machines or music sequencers....
s to achieve an extra-abrasive sound. This effect is most used to enhance the sound of a music synthesizer
Synthesizer
A synthesizer is an electronic instrument capable of producing sounds by generating electrical signals of different frequencies. These electrical signals are played through a loudspeaker or set of headphones...
by altering the waveform or vowel. Rock musicians may also use a waveshaper for heavy distortion
Distortion
A distortion is the alteration of the original shape of an object, image, sound, waveform or other form of information or representation. Distortion is usually unwanted, and often many methods are employed to minimize it in practice...
of a guitar or bass. Some synthesizers or virtual software instruments have built-in waveshapers. The effect can make instruments sound noisy or overdriven.
In digital modeling of analog audio equipment such as tube amplifiers, waveshaping is used to introduce a static, or memoryless, nonlinearity to approximate the transfer characteristic of a vacuum tube
Vacuum tube
In electronics, a vacuum tube, electron tube , or thermionic valve , reduced to simply "tube" or "valve" in everyday parlance, is a device that relies on the flow of electric current through a vacuum...
or diode
Diode
In electronics, a diode is a type of two-terminal electronic component with a nonlinear current–voltage characteristic. A semiconductor diode, the most common type today, is a crystalline piece of semiconductor material connected to two electrical terminals...
limiter.
How it works
A waveshaper is an audio effect that changes an audio signal by mapping an input signal to the output signal by applying a fixed or variable mathematical function, called the shaping function or transfer function, to the input signal (the term shaping function is preferred to avoid confusion with the transfer functionTransfer function
A transfer function is a mathematical representation, in terms of spatial or temporal frequency, of the relation between the input and output of a linear time-invariant system. With optical imaging devices, for example, it is the Fourier transform of the point spread function i.e...
from systems theory). The function can be any function at all.
Mathematically, the operation is defined by the waveshaper equation
where f is the shaping function, x(t) is the input function, and a(t) is the index function, which in general may vary as a function of time. This parameter a is often used as a constant gain factor called the distortion index. In practice, the input to the waveshaper, x, is considered on [-1,1] for digitally sampled signals, and f will be designed such that y is also on [-1,1] to prevent unwanted clipping in software.
Commonly used shaping functions
Sin, arctan, polynomial functions, or piecewise functions (such as the hard clipping function) are commonly used as waveshaping transfer functions. It is also possible to use table-driven functions, consisting of discrete points with some degree of interpolation or linear segments (see the accompanying screenshot for an example of a waveshaper that uses linear segments).Polynomials
A polynomialPolynomial
In mathematics, a polynomial is an expression of finite length constructed from variables and constants, using only the operations of addition, subtraction, multiplication, and non-negative integer exponents...
is a function of the form
Polynomial functions are convenient as shaping functions because, when given a single sinusoid as input, a polynomial of degree N will only introduce up to the Nth harmonic of the sinusoid. To prove this, consider a sinusoid used as input to the general polynomial.
Next, use the inverse Euler's formula
Euler's formula
Euler's formula, named after Leonhard Euler, is a mathematical formula in complex analysis that establishes the deep relationship between the trigonometric functions and the complex exponential function...
to obtain complex sinusoids.
Finally, use the binomial formula to transform back to trigonometric form and find coefficients for each harmonic.
From the above equation, several observations can be made about the effect of a polynomial shaping function on a single sinusoid:
- All of the sinusoids generated are harmonically related to the original input.
- The frequency never exceeds .
- All odd monomial terms generate odd harmonics from n down to the fundamental, and all even monomial terms generate even harmonics from n down to DC (0 frequency).
- The shape of the spectrum produced by each monomial term is fixed and determined by the binomial coefficients .
- The weight of that spectrum in the overall output is determined solely by its coefficient and the amplitude of the input by
Problems associated with waveshapers
The sound produced by digital waveshapers tends to be harsh and unattractive, because of problems with aliasing. Waveshaping is a non-linear operation, so it's hard to generalize about the effect of a waveshaping function on an input signal. The mathematics of non-linear operations on audio signals is difficult, and not well understood. The effect will be amplitude-dependent, among other things. But generally, waveshapers—particularly those with sharp corners (e.g., some derivatives are discontinuous) -- tend to introduce large numbers of high frequency harmonics. If these introduced harmonics exceed the nyquist limit, then they will be heard as harsh inharmonic content with a distinctly metallic sound in the output signal. Supersampling can somewhat but not completely alleviate this problem, depending on how fast the introduced harmonics fall off. Supersampling involves the following procedure:- Upsample the signal to a high sample rate and interpolate using a low-pass filter.
- Apply the waveshaping function to the supersampled signal.
- Filter the supersampled signal to remove harmonic content above the Nyquist limit of the original sample rate, preferably with a fairly steep filter.
- Downsample the signal to the original sample rate.
With relatively simple, and relatively smooth waveshaping functions (sin(a*x), atan(a*x), polynomial functions, for example), this procedure may reduce aliased content in the harmonic signal to the point that it is musically acceptable. But waveshaping functions other than polynomial waveshaping functions will introduce an infinite number of harmonics into the signal, some which may audibly alias even at the supersampled frequency.