Blog / Sound Design

Chebyshev Polynomials and Waveshaping: Engineering Harmonics with Math

Chebyshev Polynomials and Waveshaping: Engineering Harmonics with Math

Additive synthesis is conceptually clean: one oscillator per harmonic, sum everything together. But running 16 oscillators to get a 16-partial waveform is expensive and, more importantly, static. In 1979, Marc Le Brun at Stanford's Center for Computer Research in Music and Acoustics published "Digital Waveshaping Synthesis" in the Journal of the Audio Engineering Society (Volume 27, Issue 4), describing a different approach: push a single sine wave through a nonlinear function and extract whatever harmonics you need. The key ingredient is a class of polynomials most audio developers have never touched.

T_n(cos θ) = cos(nθ)

The Chebyshev polynomials of the first kind have one property that makes them remarkable for audio: feed a cosine wave into the nth polynomial and you get the nth harmonic out. Nothing else.

Formally:

T_n(cos θ) = cos(nθ)

The first four polynomials are:

T_1(x) = x
T_2(x) = 2x² - 1
T_3(x) = 4x³ - 3x
T_4(x) = 8x⁴ - 8x² + 1

If your input is x(t) = cos(ωt), a unit-amplitude cosine, and you pass it through T_3(x) = 4x³ - 3x, the output is cos(3ωt). Exactly the third harmonic, with no second or fourth. No third-harmonic oscillator, no harmonic lookup table: just a polynomial.

This follows directly from the cosine addition formula. The recurrence relation T_{n+1}(x) = 2x·T_n(x) - T_{n-1}(x) generates each polynomial from the previous two, and each one maps unit-amplitude cosines to exactly one harmonic. That is not engineering convenience; it is a property of how cosines compose under multiplication, formalized into a polynomial sequence.

Designing a Spectrum

The real power comes from linear combinations. If you want a sound with the first, third, and fifth harmonics in the ratio 1:0.5:0.25:

f(x) = 1.0·T_1(x) + 0.5·T_3(x) + 0.25·T_5(x)

Feed a unit-amplitude sine wave into this composite function and the output has exactly those three harmonics at exactly those amplitudes. You are specifying harmonic structure the way an EQ designer sets boost amounts, except you are designing a synthesis function rather than a filter.

In practice you precompute the polynomial sum into a lookup table and index it at audio rate. That is exactly what SuperCollider's Shaper UGen does: the chebyFill method accepts an array of Chebyshev coefficients and fills a Wavetable buffer, which Shaper then indexes with the input signal.

// Wavetable with harmonics 1, 2, 3 at equal amplitudes
b = Buffer.alloc(s, 4096, 1);
b.chebyFill([1, 1, 1]);  // coefficients for T_1, T_2, T_3

{ Shaper.ar(b, SinOsc.ar(440)) }.play;

Csound's GEN13 generator works the same way. Any smooth shaping function can be approximated by a sum of Chebyshev terms, so the technique extends to arbitrary transfer curves, not just exact polynomial targets.

The Amplitude Problem (Which Is Also a Feature)

The identity T_n(cos θ) = cos(nθ) holds strictly for a unit-amplitude input. That is the critical constraint. When your input sine varies in amplitude, as it does under any envelope, the spectrum changes with it.

For input A·cos(ωt) with amplitude A not equal to 1, the nth Chebyshev polynomial no longer produces a single harmonic. Instead, you get a mixture that shifts as A changes. Smaller A suppresses higher-order harmonics; larger A amplifies them while introducing intermodulation between terms.

Le Brun and Curtis Roads, whose 1979 Computer Music Journal tutorial (CMJ 3:2) introduced the technique more broadly, recognized this coupling as a design tool rather than a defect. The parameter became known as the distortion index, by analogy with FM synthesis's modulation index. Varying the input amplitude over time produces evolving timbre: the sound brightens as amplitude rises and darkens as it falls. A single envelope shaping the input gain simultaneously controls loudness and harmonic richness.

This amplitude-spectrum coupling is one reason waveshaping produces tones that feel more animated than static additive synthesis. Acoustic instruments behave similarly: louder playing on a string or brass instrument does not just add volume, it shifts the overtone balance. Waveshaping with a varying distortion index emulates that relationship without modeling the physical mechanism.

The DC Offset Problem

Even-order Chebyshev polynomials introduce DC offset. Evaluating T_2 at zero: T_2(0) = 2(0)² - 1 = -1. That negative constant pushes the entire output signal below zero when the input amplitude is small, producing an audible thump on attack and potential clipping at levels that appear safe on a peak meter.

The fix is to subtract the DC value from the polynomial output. For T_2:

T_2_centered(x) = T_2(x) - T_2(0) = (2x² - 1) - (-1) = 2x²

This removes the offset at x=0, though it shifts the spectral balance slightly. SuperCollider's chebyFill handles this automatically; the documentation notes it "compensates for DC offset due to even polynomial terms." If you are rolling your own in C++, you need to account for it explicitly, or add a DC-blocking high-pass filter (one-pole at a few Hz) downstream.

What Saturation Actually Is

Chebyshev waveshaping provides an analytical framework for understanding any smooth nonlinear process. Any differentiable transfer function over [-1, 1] can be expressed as an infinite Chebyshev series, and its harmonic behavior is completely described by those coefficients.

This means soft clipping functions like tanh(x) or arctan(x/k) each have a specific Chebyshev decomposition that tells you exactly which harmonics they produce and at what amplitudes. For a function that is odd-symmetric (f(-x) = -f(x), which tanh is), only odd-order Chebyshev terms appear in the expansion, so only odd harmonics are added. Even-order terms appear only in even-symmetric or asymmetric functions.

That distinction matters for mix engineering intuition. Tube amplifiers typically operate with mild asymmetric saturation, meaning their nonlinearity has both odd and even Chebyshev components: second and third harmonics, roughly in proportion. Transistor clipping and diode limiting tend toward harder, more symmetric curves, producing primarily odd harmonics. The warmth difference attributed to tubes versus solid-state is partly this harmonic composition. Even harmonics (octaves, fifths above the octave) are more consonant with the fundamental; odd harmonics (major seventh above two octaves) are more dissonant. Not the only factor, but a real one.

When a saturation plugin lets you dial in "even harmonic emphasis," it is adding an asymmetric term to the transfer curve, shifting the polynomial toward even-order Chebyshev components. That is not a vague metaphor; it is a concrete change in the shaping function that can be written down and analyzed.

Limits of the Framework

Chebyshev waveshaping has clean math only for sinusoidal input. Real audio signals are not sinusoids. With a complex polyphonic input, each Chebyshev term generates intermodulation products between all frequency components, not just harmonics of each individual note. The output becomes spectrally dense and pitch-dependent in ways that are difficult to predict analytically.

This is fine for intentional distortion effects. It is a problem if you are trying to use Chebyshev waveshaping as a substitute for an oscillator bank in a synthesizer: that use case assumes a clean sine input, usually from a simple oscillator with no modulation. Mixed signals defeat the precision the math provides.

Le Brun's 1979 paper notes this limitation directly: waveshaping synthesis works cleanly when the input is a single sinusoid. That constraint is what makes it useful for synthesis and what limits its applicability to effect processing of complex sources.

The technique is 47 years old. The mathematical identity is older. Both still explain more about the audio tools you use every day than the plugin manuals do.