8. Oscillators & Waveforms

The raw materials of sound synthesis

Every synthesizer starts with an oscillator. Whether it is an analog voltage-controlled circuit on a Moog or a few lines of code in a software synth, the oscillator's job is the same: generate a repeating waveform at a specific frequency. The shape of that waveform determines its harmonic content, and harmonic content is what our ears perceive as timbre — the quality that distinguishes a trumpet from a flute playing the same note.

In the previous articles we learned how to decompose signals into their frequency components using the DFT, and how to remove unwanted frequencies with filters. Now we're going in the other direction: building signals from scratch. This is the foundation of sound synthesis.

The Sine Wave

The sine wave is the simplest possible oscillator output. It contains exactly one frequency — the fundamental — with no harmonics at all. Its formula is:

x(t)=Asin⁡(2πft+φ)x(t) = A \sin(2\pi f t + \varphi)

where AA is the amplitude (how loud), ff is the frequency in Hertz (how high the pitch), and φ\varphi is the phase (where in the cycle we start).

Diagram

Anatomy of a sine wave

0 A A Period T = 1/f x(t) = A sin(2 pi f t)
A pure sine wave. The amplitude A is the peak displacement from the center line. The period T is the time for one complete cycle; frequency f = 1/T.

If you ran this through a DFT, you would see a single spike at frequency ff and nothing else. The sine wave is to synthesis what a single pixel is to graphics — the atomic unit. Every other waveform is built from sines.

The Square Wave

The square wave is the first waveform that introduces real harmonic richness. It alternates abruptly between +1 and -1, spending equal time at each level. That sharp transition requires many high-frequency components to reproduce, and the Fourier series tells us exactly which ones:

x(t)=4π∑k=1,3,5,…1ksin⁡(2πkft)x(t) = \frac{4}{\pi} \sum_{k=1,3,5,\ldots} \frac{1}{k} \sin(2\pi k f t)

Only the odd harmonics are present — the 1st, 3rd, 5th, 7th, and so on — and each one's amplitude falls off as 1/k1/k. The even harmonics (2nd, 4th, 6th...) are completely absent. This is a consequence of the square wave's symmetry: it has half-wave symmetry, meaning the negative half-cycle is an exact mirror of the positive half.

Diagram

Square wave from harmonics

1st harmonic (fundamental) + 3rd (1/3 amp) + 5th (1/5 amp) Spectrum: 1 3 5 7 9 Harmonic number Only odd harmonics. Amplitude falls as 1/n. Sum (32 harmonics) approaches ideal square wave
The ideal square wave (white) is built from odd harmonics only. The fundamental (teal) provides the basic shape; the 3rd harmonic (orange) and 5th (red) sharpen the transitions. With enough harmonics, the sum converges to the sharp-cornered ideal.
The slow 1/k1/k roll-off of the square wave's harmonics means it has significant energy at high frequencies. This is why square waves sound bright and buzzy — there is a lot of high-frequency content for our ears to pick up. In synthesis, the square wave is a popular starting point precisely because it is harmonically rich: you can sculpt it with a filter to create a wide variety of timbres.

The Sawtooth Wave

The sawtooth wave ramps linearly from -1 to +1 (or +1 to -1) and then resets sharply. It is the brightest of the classic waveforms because it contains all harmonics — both odd and even:

x(t)=2π∑k=1∞(−1)k+1ksin⁡(2πkft)x(t) = \frac{2}{\pi} \sum_{k=1}^{\infty} \frac{(-1)^{k+1}}{k} \sin(2\pi k f t)

Every integer harmonic is present, with amplitudes falling as 1/k1/k. The alternating sign (−1)k+1(-1)^{k+1} gives the characteristic ramp shape rather than a symmetric waveform.

Diagram

Sawtooth wave spectrum

Sawtooth Spectrum: 1 2 3 4 5 6 7 8 All harmonics present Amplitude falls as 1/n
The sawtooth wave contains every harmonic, making it the brightest classic waveform. Its spectrum has energy at every integer multiple of the fundamental, with amplitudes decreasing as 1/n.

Because the sawtooth has the richest harmonic content of any standard waveform, it is the default starting point in subtractive synthesis. You start with all the harmonics and filter away the ones you don't want.

The Triangle Wave

The triangle wave looks like a sawtooth with its sharp edges rounded into a zigzag. Like the square wave, it contains only odd harmonics — but the amplitudes fall off much faster, as 1/k21/k^2:

x(t)=8π2∑k=0∞(−1)k(2k+1)2sin⁡(2π(2k+1)ft)x(t) = \frac{8}{\pi^2} \sum_{k=0}^{\infty} \frac{(-1)^k}{(2k+1)^2} \sin(2\pi (2k+1) f t)

That rapid 1/k21/k^2 roll-off means the higher harmonics are very quiet. The triangle wave sounds noticeably softer and more muted than the square or sawtooth — closer to a sine wave, but with a slightly hollow quality from the remaining odd harmonics.

Comparing harmonic amplitudes at the 7th harmonic:
Waveform Harmonics present 7th harmonic amplitude
Square Odd only 1/7≈0.1431/7 \approx 0.143
Sawtooth All 1/7≈0.1431/7 \approx 0.143
Triangle Odd only 1/49≈0.0201/49 \approx 0.020

The triangle's 7th harmonic is about 7 times quieter than the square's. By the 15th harmonic, it is 15 times quieter. This is why the triangle wave sounds so much smoother.

Pulse Width Modulation

The square wave is actually a special case of a more general waveform: the pulse wave. A pulse wave spends a fraction of each cycle at +1 and the rest at -1. That fraction is called the duty cycle dd (expressed as a value between 0 and 1). A square wave has d=0.5d = 0.5 — it is high for exactly half the period.

The Fourier series for a pulse wave with duty cycle dd is:

x(t)=(2d−1)+2π∑k=1∞sin⁡(πkd)kcos⁡(2πkft−πkd)x(t) = (2d - 1) + \frac{2}{\pi} \sum_{k=1}^{\infty} \frac{\sin(\pi k d)}{k} \cos(2\pi k f t - \pi k d)

When d=0.5d = 0.5, the sin⁡(πk⋅0.5)\sin(\pi k \cdot 0.5) term is zero for all even kk, recovering the square wave's odd-only harmonics. But for other duty cycles, the harmonic content changes dramatically. At d=0.25d = 0.25, every 4th harmonic vanishes. At d=0.1d = 0.1, the wave is a narrow spike with a very broad, bright spectrum.

Pulse Width Modulation (PWM) means changing the duty cycle over time — typically with a low-frequency oscillator (LFO). As the duty cycle sweeps back and forth, different harmonics are continuously boosted and suppressed, creating a shimmering, animated spectrum. This is the classic "fat" or "chorused" analog synth sound: a single oscillator that sounds like it is constantly in motion. PWM was a signature technique of early analog synthesizers because it produced rich, evolving timbres from a single oscillator.

Harmonics and Timbre

Why do these waveforms sound so different when they are all playing the same pitch? The answer is timbre — the "color" of a sound — and timbre is determined almost entirely by the harmonic spectrum.

Consider playing concert A (440 Hz) on four different oscillators:

  • Sine: you hear a pure, featureless tone at 440 Hz. Clinical, like a tuning fork.
  • Triangle: still gentle, but with a subtle hollowness — the odd harmonics at 1320 Hz, 2200 Hz, etc. are just barely audible.
  • Square: bright and reedy. The 3rd harmonic at 1320 Hz and 5th at 2200 Hz are clearly present. Think of a clarinet's lowest register, which also emphasizes odd harmonics.
  • Sawtooth: the brightest of all. Every harmonic is present — 880, 1320, 1760, 2200 Hz and beyond. This is the buzzy, brassy sound that cuts through a mix.

This connects directly back to the DFT. If you record each of these oscillators and compute their magnitude spectrum, you get exactly the harmonic patterns we described: the sine shows one spike, the square shows odd-harmonic spikes falling as 1/k1/k, the sawtooth shows every-harmonic spikes falling as 1/k1/k, and the triangle shows odd-harmonic spikes falling as 1/k21/k^2. The magnitude spectrum is the timbre fingerprint.

Musical instruments as natural oscillators: A violin string vibrating produces something close to a sawtooth wave — all harmonics present, with a roughly 1/k1/k roll-off modified by the body resonance. A clarinet's bore reinforces odd harmonics and suppresses even ones, giving it a spectrum closer to a square wave. A flute produces a nearly pure sine wave in its lower register. The physics of each instrument determines which harmonics appear, and those harmonics determine the timbre we recognize.

Mixing Oscillators

A single oscillator produces a static, predictable timbre. Real synthesizers combine multiple oscillators to create richer, more complex sounds.

Unison and detuning. The simplest mixing technique: run two (or more) oscillators at almost the same frequency. If one oscillator plays 440 Hz and another plays 440.5 Hz, the slight frequency difference creates a slow beating pattern at 0.5 Hz — the combined amplitude rises and falls twice per second. This thickens the sound considerably and is the basis of the "unison" mode found on virtually every synthesizer.

The beating is not just an illusion; it is real amplitude modulation. If you add two sine waves at frequencies f1f_1 and f2f_2:

sin⁡(2πf1t)+sin⁡(2πf2t)=2cos⁡ ⁣(π(f1−f2)t)sin⁡ ⁣(π(f1+f2)t)\sin(2\pi f_1 t) + \sin(2\pi f_2 t) = 2\cos\!\left(\pi(f_1 - f_2)t\right)\sin\!\left(\pi(f_1 + f_2)t\right)

The result is a carrier at the average frequency (f1+f2)/2(f_1 + f_2)/2, modulated by a slow envelope at half the difference frequency (f1−f2)/2(f_1 - f_2)/2. With a small detuning, you hear the pitch stay roughly the same while the volume gently pulses.

Octave layering. Adding an oscillator at twice the fundamental frequency (one octave up) reinforces the even harmonics. Adding one at half the frequency (one octave down) adds a sub-bass foundation. These are common in bass patches and lead sounds.

Waveform mixing. Blending a sawtooth with a square at the same frequency combines their harmonic series. The even harmonics from the sawtooth fill in the gaps in the square wave's odd-only spectrum. Adjusting the mix ratio lets you dial in the brightness continuously.

Key Takeaways

  • An oscillator generates a repeating waveform at a set frequency. The waveform shape determines the harmonic content (timbre).
  • The sine wave is the atomic unit of synthesis: one frequency, no harmonics. Every other waveform is a sum of sines.
  • The square wave contains only odd harmonics (1, 3, 5, 7...) with amplitudes falling as 1/k. Bright and reedy.
  • The sawtooth wave contains all harmonics (1, 2, 3, 4...) with amplitudes falling as 1/k. The richest, brightest classic waveform.
  • The triangle wave contains only odd harmonics with amplitudes falling as 1/k-squared. Much softer and more muted than the square.
  • Pulse width modulation (PWM) generalizes the square wave by varying the duty cycle, dynamically shifting which harmonics are present. This creates the classic "fat" analog synth sound.
  • Timbre is harmonic content. The DFT magnitude spectrum is a timbre fingerprint — it shows exactly which harmonics are present and how strong they are.
  • Mixing oscillators with slight detuning creates beating, which thickens the sound. Octave layering and waveform blending are other common techniques.

With oscillators in hand, we have the raw materials of synthesis — waveforms full of harmonic energy, ready to be shaped. The next article covers subtractive synthesis, where we use the filters from earlier in this series to carve those raw waveforms into the sounds we actually want to hear. The oscillator provides the marble; the filter is the chisel.

Try It — Waveform Explorer

Choose a waveform, adjust the fundamental frequency and number of harmonics, and watch the waveform build up from its Fourier components. The spectrum shows the amplitude of each harmonic.

2
16
Waveform (time domain)
Frequency Spectrum