I’ve been interested in granulation for a while, so sometime in 2007 I was sitting in the Capillary Action tour van and I decided to whip up something that can granulate live input. It’s written entirely in Pure Data, though if I were doing it again I might write it in C as a PD external. Though I’ve been using it pretty regularly, it could still be cleaned up considerably.
Currently it’s set up for 7 voices, but that’s easily reconfigureable by adding or removing grainvoice~ objects from the voices subpatch.
Density (Hz) How often the voice plays a grain, more density means shorter grains. Density_Randomness (%) Grain length will vary by +/- Density_Randomness % of Density. So if Density is at 10 Hz, with Density_Randomness at 50%, the grains will vary from 50ms to 150ms. Pitch (%) Change the playback speed of grains. 200% doubles pitch (plays twice as fast). Pitch_Randomness (%) Similar to Density_Randomness. Grains will vary in pitch. Max_Delay (ms) How far back the voices will grab grains. 0ms means it will only grab what was just input, 2000ms will grab up to 2 seconds away, etc. This is limited by the buffer length of grainvoice~. The probability density function is uniform from 0 to Max_Delay. Grain_Length (%) How much of the length specified by Density is taken up by playback vs. silence. Amplitude Gain applied to each grain. One is unity. Envelope_Sharpness One gives a normal cosine envelope, higher values give sharper edges with a plateau. Stereo_Spread Grains can be spread in the stereo field. Zero will result in the Left and Right outputs being identical. One results in grains being panned anywhere from hard left to hard right.
Each voice takes audio input and writes it to a delay buffer. The ideas is that each voice plays back a series of chunks from its buffer, with a cosine window to make sure they don’t click at the beginning and end. A phasor~ object is the master control, and each trip from 0-1 of the phasor~ corresponds to the playback of a single chunk.