Visualizations
447 / 500

447 · Sound

Granular Cloud

Granular synthesis made visible: every grain is a glowing droplet shaped by its window.

An eight second source is synthesized from scratch (a sawtooth chord through morphing vowel formants, inharmonic bells, Karplus-Strong strings, resonant wind and an FM drone) and drawn as a waveform ribbon colored by zero-crossing rate, amber where it is tonal and cyan where it is noisy. A scheduler fires grains at the chosen density with a little jitter; each reads a short stretch near the play position plus a random spread, at its own playback rate, under a Hann window. Every grain floats above its source as a droplet: its outline is its window, its width is the stretch of ribbon it reads, its height is its pitch, and a bead rides the window as it plays, while the stretch it reads lights up on the ribbon. With sound on, each grain is a Web Audio buffer source with a Hann gain curve on the same clock the picture follows.

Try it. Click for sound. Drag along the ribbon to scrub, or drag in the cloud to set position and pitch together. Drag the value chips sideways (or tap them) to change density, grain size, spread, pitch, pitch jitter and speed. Freeze (F) holds time for drones, Shimmer (S) adds octaves and fifths, arrow keys change spread and size, R resets pitch and jitter, and A toggles the autopilot.

  • Granular synthesis
  • Hann windows
  • Karplus-Strong
  • Formant filters
  • Web Audio

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a granular synthesizer with a visual grain cloud, using JavaScript, the HTML canvas element and the Web Audio API. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Synthesize a source sound in code so there is nothing to load: about four seconds of a few bell tones (sums of sines at inharmonic ratios with exponential decays) followed by a swell of filtered noise. Store it in a Float32Array and copy it into an AudioBuffer.
- Draw the source as a waveform ribbon along the bottom of a full-window canvas: for each pixel column take the minimum and maximum of its samples and draw a vertical line.
- On the first click, create the AudioContext. Run a scheduler every frame that keeps grains booked about 100 ms ahead on the audio clock, at a chosen density (say 30 grains per second). Each grain is an AudioBufferSourceNode that starts at the play position plus a random spread, plays 50 to 200 ms, and goes through a GainNode whose gain follows a Hann window (setValueCurveAtTime), so grains fade in and out without clicks.
- Let the play position creep forward slowly, and let dragging across the ribbon scrub it.

Once that works, make it beautiful:
- Draw every grain as a glowing droplet above the stretch of ribbon it reads: its outline is its window curve, its brightness follows the envelope, and a bead runs along it as it plays.
- Put pitch on the vertical axis: give each grain a playback rate, and add a shimmer option that randomly picks octaves and fifths.
- Add controls for density, grain size, spread and pitch, plus a freeze toggle that stops the play position for drones.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as a magnified view of the region being read, a reverb send, or a richer synthesized source.
PreviousSpacetime TrainA train, a tunnel and a light clock, with a live Minkowski diagram in either frame. NextFitness LandscapeFive populations climb a rugged fitness landscape, then get stranded when it shifts.

Related visualizations

  • Generative MusicSound A self-composing synthesizer you can see, played with the Web Audio API.
  • Spectrogram PainterSound Paint sound in time and frequency, then watch the real spectrogram of what you hear.
  • Perceptual CodecSound Watch a psychoacoustic model decide which parts of the music you will never miss.
  • Modular SynthSound A eurorack case with a working signal graph and patch cables that sag and swing.
  • FM SynthesisSound A four-operator FM synth whose sidebands land exactly where Bessel functions say.
  • Minnaert RainNature Watercolor rain whose sound is built from first principles: ringing bubbles, not samples.
  • Xenakis GlissandiGenerative art Metastaseis-style string glissandi as ruled surfaces on graph paper, and a gas of notes.
  • Rotating DrumPhysics Grains in a turning drum avalanche and sort themselves: big outside, small in the core.
  • Music BoxSound A pinned brass drum plucks cantilever tines from a punched strip you can edit.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs