← Back to the lab

Listen / The collection / 13

Hailstone

A number becomes an instrument. Explore Collatz sequences through sound, shape the synth, and export the result as WAV or MIDI.

Hailstone browser instrument showing a Collatz trajectory, synthesis controls, musical settings, touch field and playable pads.View full size ↗
In the project

The Hailstone instrument: one starting number shapes a visible trajectory, musical sequence and oscillator waveform. Sound controls and pads turn the pattern into something playable.

About this image

Actual browser capture of the supplied Hailstone instrument at its default Glass descent patch. · 2026-10-06
Revision: Hailstone 1.0.0 · source SHA-256 eda5f8e3c97bd79e05551cae4dc750aacb62ab1992a37b1060c5390a02474feb

One number. An entire instrument.

The starting point

A mathematical sequence can be more than a list of numbers. Hailstone explores how its rises, falls and patterns can become something you hear, see and play.

What I built

Start with a positive integer. Odd numbers are tripled and increased by one; even numbers are halved. Hailstone turns those operations into a musical sequence and a moving visual path.

The sequence shapes both the notes and a custom oscillator waveform. Odd and even steps have contrasting voices, with controls for FM, tone, decay, reverb and delay. Presets offer starting points; a touch field and keyboard pads let you play the sound yourself.

Choose a key, scale, tempo and pitch mapping, then take the result elsewhere. Stereo WAV exports include the synth and effects; multitrack MIDI carries musical events for another instrument. Patches can be saved and loaded, and the last settings stay in the browser.

The instrument lives in one self-contained HTML file. It generates sound locally with Web Audio, starts audio after a tap and has no external libraries, microphone input or upload service.

The arithmetic uses exact integers. A trajectory stops at one, a repeated value or a fixed step limit; an unresolved result is shown as a limit, rather than treated as evidence that it diverges.