Logo
← Back

October 13, 2026

Step 3: Window Shapes and Interpolation

Tiny pieces that make granular synthesis sound smoother.

In Step 3, Drizel starts shaping each grain more carefully. Two small ideas do much of the work: window shapes decide how a grain fades in and out, while interpolation estimates the audio value between stored samples. Neither is magic; they are the small details that make grains cleaner and more musical.

What is a grain?

A grain is a very short slice of sound. Rather than playing a whole sample from beginning to end, a granular synthesizer plays many tiny slices, often overlapping them to form a larger texture. Each grain needs a clean beginning and ending. If its signal starts or stops abruptly, the sudden jump can sound like a click.

One sample becomes a cloud of grains

Audio sampleGrain 1Grain 2Grain 3Cloud of sound

Why use a window?

Imagine cutting a waveform with scissors. A hard cut can leave the signal at a non-zero value, then force it instantly to zero. That discontinuity introduces broadband energy that we hear as a click. A window multiplies the grain by a changing volume curve: it fades the sound in, lets it speak, and fades it out.

The window does not change where the grain comes from. It changes how strongly each point in that grain contributes to the output.

Hann and triangle windows

A Hann window starts at zero, rises smoothly to its peak, and returns smoothly to zero. Its rounded shape is useful for reducing clicks and creating gentle overlapping textures. One common definition is w(t) = 0.5 − 0.5 cos(2πt), where t moves from 0 to 1 across the grain.

A triangle window rises and falls in straight lines. It is simple to implement and useful for learning because its fade is easy to see and hear. A rectangular window applies no fade at all, so it is useful as a comparison but can leave clicks at the edges.

Compare grain windows

Move through a grain to see how each window changes its amplitude.

What is interpolation?

Digital audio stores a signal as a sequence of samples. But a grain may need to read from a position between two stored samples, especially when playback speed or pitch changes. Interpolation estimates a sensible value at that in-between position instead of simply jumping from one sample to the next.

Linear interpolation

Linear interpolation draws a straight line between two sample values. If sample A is 0.20 and sample B is 0.80, halfway between them the estimated value is 0.50. In code, the calculation is:

value = a + (b - a) * t;

Here, a is the first sample, b is the next sample, and t is the fractional position between them. At t = 0 the result is a; at t = 1 it is b; at t = 0.5 it is their midpoint.

Read between samples

Linear interpolation estimates a value between sample A (0.20) and sample B (0.80).

What changes in the engine?

  • Window shapes multiply each grain by an amplitude curve to reduce abrupt edges.
  • A Hann window gives a smooth, rounded fade in and out.
  • A triangle window provides a straightforward linear fade that is easy to test.
  • Linear interpolation estimates audio values between sample positions for smoother playback movement.

The architectural change is small, but it matters at the sample level. Granular synthesis becomes more musical when every tiny grain is both shaped and read cleanly.

A beginner’s mental model

Think of a grain as a tiny flashlight beam. The window controls how its light fades in and fades out. Interpolation controls how smoothly the flashlight moves between points. Rough windowing can click; rough sample reading can step. Smooth windows and interpolation help the grain cloud feel less broken.

Step 3 summary

Step 3 makes the small pieces better. Window shapes help each grain enter and leave smoothly, and interpolation makes reads between samples cleaner. Together, they turn raw grain playback into something closer to a playable instrument.

Command Palette

Search for a command to run...