Audio

Waveform (sine, square, triangle, sawtooth)

The shape of a periodic sound wave. A sine is a single pure pitch with no overtones, a square adds odd harmonics and sounds buzzy, a triangle has softer odd harmonics, and a sawtooth contains both odd and even harmonics for a bright, rich tone. The fundamental frequency stays the same across all four at a given Hz value.

Same pitch, four shapes

Take a 440 Hz tone and change only the shape of each cycle. The pitch stays at 440 Hz, yet a sine, a square, a triangle and a sawtooth sound clearly different. The shape decides which harmonics are present. A sine has none. The others have a stack of them, and that stack is what you hear as the tone's color.

Fourier analysis says any repeating wave is a sum of sine waves. A square wave, for example, is a sine at the fundamental plus weaker sines at its odd multiples.

What each shape contains

Each shape has its own recipe of harmonics:

  • Sine: one frequency and no harmonics. It's the cleanest tone.
  • Square: odd harmonics only, each at 1 divided by its number. The 3rd has one-third the amplitude of the fundamental.
  • Triangle: odd harmonics only, but each at 1 divided by its number squared. The 3rd has one-ninth the amplitude of the fundamental.
  • Sawtooth: every harmonic, odd and even, each at 1 divided by its number. The 2nd has one-half the amplitude of the fundamental.

A square wave at 440 Hz has energy at 440, 1320, 2200 and 3080 Hz, and on up the odd multiples. A sawtooth adds the even ones too, like 880 and 1760 Hz. The triangle's harmonics fade so fast that it sounds soft. The square keeps its upper harmonics strong, which is why it sounds buzzy.

Same peak, different loudness

Shapes with the same peak carry different energy. RMS, the usual measure of a wave's level, comes out at 0.707 for a sine, 0.577 for a triangle, 0.577 for a sawtooth and 1.0 for a square, with a peak of 1. A square wave is the loudest at an equal peak, so it puts the most energy into a speaker.

The Frequency Generator evens this out. It scales each shape by a loudness factor, 0.707 for a square and 0.800 for a sawtooth, so switching shapes at one volume setting doesn't jump in level.

Which shape to use

Use a sine when you want a clean pitch: hearing checks, tuning, calibration and room tests. Use a square or sawtooth when you want harmonics, such as synth sounds, harmonic distortion checks or a test of how a speaker handles a rich signal. A triangle sits between the two. It has harmonics, but they fade quickly.

In a browser, the Web Audio API makes all four from one oscillator. You set its type to sine, square, sawtooth or triangle and give it a frequency. The sine vs square and sawtooth vs triangle pages compare the spectra side by side.

Work it out yourselfOpen the Frequency Generator

Sources

Back to the glossary