Drawing a waveform
A second of sound is 44,100 numbers. A screen is a few hundred pixels wide. Every waveform is an answer to how one fits into the other.
1Every Nth sample
Keep one sample per pixel. Fast, and wrong: tones above the pixel rate fold into slow waves that aren't there. Here, a sweep; grey is what it really spans.1
2Lowest and highest
Each pixel column draws from its lowest sample to its highest. No peak is missed. Audacity, Audition and most editors draw this.2
Reading every sample for every column is slow for an hour of audio, so editors keep the lowest and highest of blocks of 256, 512, 1024… samples, made once: a pyramid, read a few blocks a column.2,3
3Loudness inside the peaks
Peaks say how far the sound reaches, not how loud it is. A band of its RMS inside shows the loudness: Audacity's lighter core.2
4Brightness by level
Or shade the fill by how often the sound reaches each level: bright where it lives, dim where it rarely goes. Two guesses from the peak and RMS,13 and two counts of the samples themselves. The last is an oscilloscope's afterglow, bright where a wave turns.4
5Up close
Zoomed in, a sample is a point, not a step. Between points runs the one band-limited curve through them,5 and it can peak above every sample: a quarter-rate tone at 45° has no sample above 71 %, yet reaches 100 %. Meters call that the true peak.6
6Amplitude or decibels
On a linear scale the quiet half of a sound is a hairline. In decibels, tails, fades and room tone show.7
7Colour for frequency
DJ software colours the waveform by its lows, mids and highs, so a kick reads apart from a hi-hat.8 Freesound colours by the spectral centroid, the spectrum's centre of mass: dark red low, violet high.9
8Two channels
Stereo is two waveforms. Lanes keep them apart. One lane saves the space, each channel in its colour: a pair opposite across grey in the plane of vision that holds brightness still,10,11 equally light, adding back to grey where the channels agree.12 Pretty, but which colour is which side? A sound panned left, or a different take in each channel, reads better in lanes.
9All at once
Every choice above, as controls that combine. Pinch, or scroll with Ctrl held, to zoom at the pointer; drag or scroll sideways to pan.
10Where they live
- audiothe REPL's waveform: lanes, smooth edges, brightness by level
- gl-waveformthe WebGL renderer: a lowest/highest pyramid, anti-aliased by distance
- wavefonta waveform as a font: bars are letters
- waveareaa waveform you edit like text
- C. E. Shannon, “Communication in the presence of noise,” Proc. IRE 37 (1949): sampling below twice a frequency aliases it.
- Audacity Manual, “Audacity Waveform” (peaks and RMS); D. Mazzoni & R. B. Dannenberg, “A fast data structure for disk-based audio editing,” Computer Music Journal 26 (2002): block summaries of 256 and 65,536 samples.
- BBC R&D, audiowaveform: min/max pairs at a chosen zoom, for peaks.js.
- Tektronix digital phosphor oscilloscopes (DPO): a trace's brightness by how often it passes a point.
- C. Montgomery, Digital Show & Tell, Xiph.Org (2013).
- ITU-R BS.1770-4 (2015), Annex 2: true peak by 4× oversampling.
- Adobe Audition, iZotope RX: waveform in decibels, a vertical scale option.
- Serato DJ Pro manual: coloured waveforms, red lows, green mids, blue highs.
- B. de Jong,
wav2png, Freesound: waveform coloured by spectral centroid. - A. M. Derrington, J. Krauskopf & P. Lennie, “Chromatic mechanisms in lateral geniculate nucleus of macaque,” J. Physiol. 357 (1984).
- D. H. Brainard, “Cone contrast and opponent modulation color spaces,” in Human Color Vision, 2nd ed. (1996).
- B. Ottosson, A perceptual color space for image processing (2020): OKLab.
- M. Abramowitz & I. A. Stegun, Handbook of Mathematical Functions (1964), 7.1.26: erfc, for the Gaussian guess.