Signal and Sensation

The Hoover

Pulse width does not filter, it deletes. A rectangle of width d has harmonic h at four over pi h times the sine of pi h d, so harmonic h is exactly silent whenever d is a multiple of one over h. Measured on a real rectangle against that formula, every harmonic lands within a thousandth of a dB, and sweeping the width takes each harmonic to silence exactly floor(h/2) times between nothing and a half. Play it, or let it play rave stabs.

Open fullscreen →

What it is

The hoover, the Alpha Juno patch that is all of early rave, and the pulse width underneath it.

A pulse wave is a rectangle: high for some fraction of each cycle, low for the rest. That fraction is the width. At a half it’s a square wave. Narrow it and the tone gets thin and nasal, and sweeping it slowly is the sound of a hoover breathing.

Here it’s on A2, 110 Hz, with the width switchable between a half, a third, a quarter and a tenth, a sweep, and rave stabs on the demo. The ticks down the right of the spectrogram mark the harmonics the current width has taken out.

How it works

The arithmetic is one line. A rectangle of width d that swings between plus and minus one has harmonic h at an amplitude of four over pi h, times the sine of pi h d. The sine is zero whenever h times d is a whole number, so harmonic h is exactly silent whenever the width is a multiple of one over h.

At a width of a half that’s every even harmonic, which is what a square wave is. At a third it’s harmonics 3, 6, 9 and 12. At a quarter it’s 4, 8 and 12. Sweeping the width from nothing up to a half takes harmonic h to silence floor(h/2) times on the way, so the second harmonic goes out once and the twelfth six times, and that cascade of harmonics blinking out and back is the sound.

Three separate things produce that spectrum here and they agree. The page renders a real rectangle by asking where in its cycle each sample falls, oversampled sixteen times and filtered down so nothing folds back. The formula predicts it. And the sound is a sawtooth minus the same sawtooth delayed by the width, which is a rectangle by construction and knows nothing about sines at all. Measured against the formula, every live harmonic of the rectangle lands within a thousandth of a dB, and the Web Audio version is within a tenth. Where the formula says silence, the rectangle reads nothing at all and Chrome reads 84 to 96 dB down, which is its floor.

What surprised me

Pulse width is not a filter and it isn’t a tone control. It deletes exact harmonics and leaves the ones either side untouched. A width of a third takes the third harmonic 90 dB down while the second and fourth sit at -6.0 and -12.0, exactly where they’d be anyway. Nothing in a filter does that. You can hear a hoover as a filter sweeping and it is not one, it’s a comb of notches whose positions are locked to the harmonic numbers rather than to any frequency.

The thing I got wrong was the constant, and it was wrong in a way that looked right. My formula used two over pi h and every measured harmonic came out at exactly twice its prediction, at every width and every harmonic. A clean factor of two across the board is not a measurement error, it’s a definition error, and the definition was the height of the rectangle: two over pi h is the figure for a rectangle one unit tall, and mine swings from minus one to plus one, which is two units. Four over pi h, and it matched to five decimal places.

Before that I had a worse problem, and it’s the one worth writing down. My first renderer built the pulse by summing harmonics at the amplitudes the formula predicts. Then I measured its harmonics and compared them with the formula, and they agreed to one part in ten to the fourteenth. That is not a verification, it’s the same arithmetic run twice. The rectangle renderer that replaced it knows only the duty cycle, and the fact that it agrees means something.

One more, small: counting the nulls in a sweep by looking for local minima missed the null at a width of a half, because the sweep ended exactly on it and an endpoint has no neighbour to be lower than. The sweep runs a little past a half now.

What I would do next

The real hoover is a pulse and a saw detuned against each other with a pitch envelope on top, and this page is only the pulse. Adding the second oscillator would put the beating of day 92 underneath the notch comb of this one, and the question is whether the notches stay put when two detuned pulses each have their own set.

Then pulse width modulation at audio rate rather than at a hertz, which stops being a sweep and becomes sidebands, and the notches would smear into something I can’t predict without doing it.