AvailableInstrument

Granular

A recording split into a playable grain cloud.

@maru shared this instrument so you can play it in your DAW, remix it or put it on your site.

Play

What it does

A granular instrument: it cuts a recording into tiny grains and replays them as a cloud you play from a keyboard. Pick a guitar take, a piano, a voice or a field recording, choose where in it the grains come from, and shape the cloud with size, density, pitch and direction.

The idea

Granular synthesis treats a recording as material rather than a timeline. Each grain is a short slice, a fraction of a second, wrapped in a smooth envelope. Launch a few per second and you hear a rhythm of fragments; launch many and they blur into a continuous tone. Short grains turn pitch into timbre, long grains keep the source recognisable.

There are two ways to choose which grains play:

  • Time picks grains from a position in the recording. Position sets where, Spray scatters grains around it, and Scan drifts through the recording while a note sounds, forwards or backwards. You can also drag the waveform directly.
  • Similarity lays every slice of the recording out on a map by how it sounds, so neighbouring points are grains that sound alike. Move the circle and set its Radius to play from one region of sound rather than one moment in time.

Pitch Match

Tuned finds grains that hold a clear note and shifts each one to the key you play, so a guitar take becomes a playable instrument. With Keytrack off, every key plays at C4. Original plays grains at the interval from C4, which suits chords, attacks and textures. Tuned works best on sources with clear single notes: the source picker shows how much of each recording is tonal, and sources with none switch to Original automatically.

Guide and controls

How it works.

A grain is a short slice of the take, twenty milliseconds to half a second, wrapped in an amplitude window that starts and ends at exactly zero. That zero-endpoint window is the entire trick: it is what lets the instrument start and stop dozens of slices per second with no clicks, because every grain's edge is a fade, not a cut. Five window shapes are published, and they are timbres as much as envelopes: a Hann grain is smooth, an Expodec grain is a struck one.

A held note is a stream of grains counted in samples. The Processor keeps each voice's next grain onset and starts the grain on that exact frame, inside the audio callback, so nothing depends on the main thread and the same notes render the same audio on the JavaScript and WebAssembly lanes. Each grain draws its start offset, duration, playback rate, direction and stereo position from pure, seeded arithmetic (granular-math.ts): the character of the cloud is testable, and a fixed pool of 128 grain slots turns those numbers into sound.

Density and Size together set the overlap, at 18 grains a second and 90 ms each, roughly 1.6 grains sound at any instant, and overlapping grains sum. The pool compensates with a gain of one over the square root of the expected overlap: square root rather than linear because uncorrelated grains add in power, not amplitude. That is why sweeping Density changes the texture from rhythm to wash without also being a volume knob.

A reverse grain is the same read with a negative step: it starts at the far end of its slice and walks back through the take, so no reversed copy of the audio is kept. The reverse knob is a probability per grain rather than a switch, which is what makes 50% sound like time losing its direction rather than like a tape flip.

Pitch changes playback rate. In Tuned mode, confidently pitched grains are selected and their detected fundamentals are mapped to the played key; the source picker shows each take's tonal coverage. Original mode keeps the take's source pitch and transposes it relative to middle C when Keytrack is on. Grains without a reliable pitch remain available in Original mode.

The takes ship with the module: public-domain guitar takes, credited in public/audio/CREDITS.json. Choosing one makes the host fetch, verify and decode it, then hand the samples and that take's analysis map to the Processor; the waveform on screen is drawn from the peaks the Processor measured. Until the new take arrives the previous one keeps playing, and a take that fails to load says so on the screen instead of falling silent.

What would you make with Granular?

Describe what you want to make. Build it with the Studio agent.

Goes well with.

Prototype

Two oscillator banks with continuous frame morphing.

Prototype

Modelled bronze instruments with flexible tuning.

Prototype

Convolution reverb: eight synthesized spaces, twenty-five real cabinets.