Waveform Synthesis Simulator: Sine, Square, Sawtooth & Triangle Waves

simulator beginner ~8 min
Loading simulation...
Sine wave at 2 Hz — pure tone, crest factor = 1.41

A 2 Hz sine wave with amplitude 1 produces a smooth, symmetric oscillation. The crest factor is sqrt(2) = 1.41, the RMS amplitude is 0.707. Adding modulation creates AM sidebands visible in the spectrum.

Formula

Sine: x(t) = A * sin(2*pi*f*t)
AM: x(t) = A * (1 + m*sin(2*pi*fm*t)) * sin(2*pi*f*t)
RMS = sqrt(1/T * integral(x(t)² dt))

The Four Classic Waveforms

Every synthesizer starts with the same four basic waveforms: sine, square, sawtooth, and triangle. These shapes are not arbitrary — each represents a specific harmonic recipe. The sine wave is the purest possible sound: a single frequency with no overtones. Add odd harmonics at 1/n amplitudes and you get a square wave. Add all harmonics at 1/n and you get a sawtooth. Add only odd harmonics at 1/n² and you get a triangle wave. From these building blocks, subtractive synthesis creates any sound imaginable.

Fourier Analysis in Action

Joseph Fourier proved in 1807 that any periodic waveform can be decomposed into a sum of sine waves. This simulation makes this abstract theorem visual: watch how the composite waveform changes shape as you switch between wave types, each with its characteristic harmonic spectrum displayed below. The frequency spectrum (bar chart) shows exactly which harmonics are present and at what amplitude.

Amplitude Modulation

When the modulation depth is increased, the carrier wave's amplitude varies periodically, creating tremolo at low modulation rates. At higher modulation frequencies, amplitude modulation generates sideband frequencies at f +/- f_mod, enriching the spectrum. This AM synthesis technique was the basis of the famous Yamaha DX7 synthesizer and remains fundamental to sound design. Watch the spectrum display to see sidebands appear as you increase modulation depth.

From Waveforms to Music

These simple waveforms are the starting point for all electronic music synthesis. Subtractive synthesis begins with harmonically rich waveforms (sawtooth, square) and removes harmonics with filters to shape timbre. Additive synthesis builds complex sounds by combining many sine waves. FM synthesis creates rich spectra by modulating one wave's frequency with another. Understanding these basic waveforms is the foundation for all sound design and electronic music production.

FAQ

What are the basic waveform types?

The four classic waveforms are: sine (pure tone, no harmonics), square (odd harmonics only, 1/n amplitude), sawtooth (all harmonics, 1/n amplitude), and triangle (odd harmonics only, 1/n² amplitude). These form the building blocks of subtractive synthesis.

What is amplitude modulation?

Amplitude modulation (AM) multiplies a carrier signal by a modulating signal, creating tremolo at low modulation frequencies and new spectral sidebands at higher frequencies. The modulated signal contains frequencies at f_carrier, f_carrier + f_mod, and f_carrier - f_mod.

What is RMS amplitude?

RMS (root mean square) is the effective amplitude of a waveform, representing its power content. A sine wave's RMS is peak/sqrt(2) ≈ 0.707 times peak. A square wave's RMS equals its peak because it spends all time at maximum displacement.

What is the crest factor?

Crest factor is the ratio of peak amplitude to RMS amplitude. Sine = sqrt(2) ≈ 1.41, square = 1.0, triangle = sqrt(3) ≈ 1.73, sawtooth = sqrt(3) ≈ 1.73. Lower crest factor means more 'efficient' use of amplitude range.

Sources

Embed

<iframe src="https://homo-deus.com/lab/sound-music/waveform-synthesis/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub