Granular

Slice audio into grains and reassemble them into a new signal.

What it does

Granular breaks an audio source into a stream of overlapping micro-grains, short slices only tens of milliseconds long, and reassembles them into a new sound. Each grain is drawn from a scan position in the source, shaped by an envelope so it fades in and out cleanly, and can carry its own pitch and stereo placement. Results run from a clean time-stretch or pitch-shift of the original to a dense, swirling texture with little of the source left in it.

The whole source buffer is required, not the current frame. From an Audio File node, wire the buffer output rather than waveform.

When to use it

ParameterTypeDefaultWhat it does
sourceSignal or Number[]—Audio source to granulate — needs the WHOLE buffer for grain addressing. From an Audio File node, wire its `buffer` output (not `waveform`, which is only the current frame).
positionNumber0.500—
speedNumber00 = freeze at position. 1 = traverse full source per second.
grain_sizeNumber50—
densityNumber20—
pitchNumber0—
sprayNumber0.100—
amplitudeNumber1—
pan_spreadNumber00 = mono. 1 = grains randomly panned full stereo (visible on grains.pan).
sample_rateNumber00 = control rate, >0 = audio buffer at this sample rate
max_grainsString"32"One of: 8, 16, 32, 64.
windowString"Hanning"Hanning: cosine bell (smooth). Triangle: linear ramp. Blackman: flat-top (less spectral leakage). One of: Hanning, Triangle, Blackman.

Gotchas

Speed of 0 freezes scanning at the current Position, turning a single instant into a sustained texture. Positive and negative values scan forward or backward through the source at that fraction of the source per second.

Spray adds randomness to each grain's source position, so even at Speed 0 there is movement rather than a static loop. Push it toward 1 to pull grains from anywhere across the source.

Source needs the whole buffer, not a single frame. Wired to a waveform output instead of buffer, the node has nothing to slice grains from.

Pan Spread affects the grains output and the separate buffer_right output only. The main mono buffer/output never changes with it. To hear the stereo spread, use buffer and buffer_right together as left and right channels.

Worked example

  1. Add a Granular node and wire an Audio File node's buffer output into Source.

  2. Set Position to pick where in the source to granulate, and leave Speed at 0 to freeze there.

  3. Raise Density and lower Grain Size for a smoother texture; do the opposite for a more granular, choppy sound.

  4. Add Spray so grains scatter around Position instead of repeating identically.

  5. Raise Pan Spread and use buffer and buffer_right as left and right channels for a wide stereo texture.

See also

audio.wavetable · Envelope Follower · Additive Synth · Numbers, signals & audio