Category: Pd

max-pd-abstractions index

Max abstractions that simulate Pd objects.

Each project is in a separate folder. Several projects require additional external objects or dependencies. Get instructions by clicking links next to each project names below.


max-pd-abstractions at Github:

Runs in Max 6.1.7 on Mac OS 10.9


Granular time stretching in Max

Adaptation of Andy Farnell’s Pd granular timestretch patch

Adjustable chunk-size, pitch, and speed – as well as manual scrubbing.

The original Pd patch (timestretch.pd) is available here:


folder: granular-timestretch


  • timestretch5.maxpat (main patch)
  • tabread4~.maxpat (Pd abstraction) 
  • hip~.maxpat (Pd abstraction)

How it works

An index pointer (file phasor) scans from the beginning to the end of the file. For example, at 44.1KHz, a 1 second file of audio would have 44,100 samples. Each sample is 022676 ms. Another phasor (grain phasor) scans small chunks (grains) of audio. If audio is playing back at the normal rate and pitch, this grain phasor runs at zero. the file phasor just moves sequentially from one grain to the next.

To stretch the time, the file phasor is slowed down, but the grain phasor speeds up, scanning grains of audio, that start at the current file phasor index. In this way, in listening to the file from beginning to end, you are actually listening to a series of overlapping grains.

As the chunk (grain) size increases the grain phasor frequency decreases.

To raise the pitch, the grain phasor frequency would be increased. To lower the pitch, the phasor frequency goes negative and increases in a negative direction to reduce pitch further.

As you can see, while running this patch, the chunk size, pitch, and speed are all related by a single equation.

phasor frequency = ((pitch / 120)**2 – speed) / chunksize

  • where pitch is in cents (0 is normal)
  • speed is a scaling factor (1 is normal)
  • chunk (grain) size  is in ms.

So the input values interact with each other.

In addition, the grain player uses a technique called PSOLA. Pitch synchronous overlap and add. There are actually two grain players playing simultaneously 180 degrees out of phase. Each is windowed using a positive cosine function. This helps to reduce clicks by crossfading from one grain to the next.

There is some comb-filtering and ringing present on the audio. There are various techniques to reduce this, including:

  • trying different window functions
  • higher sample rates
  • changing the overlap
  • varying the grain size
Interesting artifacts:
  • reducing the grain size to several ms. causes oscillation similar to the Karplus-Strong effect
  • increasing the grain size to around 1000 ms. causes a feedback delay effect due to the out of phase grain players
  • setting the overlap to anything other than .5 causes random phase cancellation
Manual or automated scrubbing.

There is also an option to manually scrub the file. This way you can listen to the texture of grains of various sizes from various points in the file.

You can also set random automatic scrubbing to branch to various points in the file.

ep-4yy13 DSP – week 13

“I think its just the biggest conceptual art project uninentional or otherwise that anyone ever made. it puts Christo and those other guys to shame. Its planetary”

Roman Mars “Episode 97 – Numbers Stations” from 99% Invisible


  • Measuring the invisible
  • What is the difference between sound waves and radio waves?
  • What is an antenna?
  • Wave propagation is frequency dependent
  • Sunspots and magnetic fields
  • Extreme frequencies, negative frequencies?


Internet radio streams and recordings

Frequencies and modes
  • Macbook trackpad: Noise 5 mHz. (try holding radio near screen too)
  • Macbook AC adapter: Noise 600-1400 kHz. (~1000)
  • AC adapters, LED’s, Utility poles: 3.2 Khz
  • Arduino transmitter: AM 1330 kHz.
  • Laser light at 650nM
  • Wireless micorophone (Orange-brown): Wide FM 614.150 MHz. (R band)
  • Cordless phone: Narrow FM 926 mHz.
  • Cell phone: Digitally encrypted trunking FM 836 mHz.
  • Wifi: Digitally encoded PCM 2.4 gHz.
  • FM broadcast band: Wide FM 89.7 mHz (Raspberry Pi example 98.1 Mhz)
  • TV audio 600 mhz/660 mhz FMW
  • The sun

Topics not covered

(due to snow and stuff)



  • d3
  • processing
  • jitter
  • hardware control




Please send me a copies of your earlier compositions. Have a prototype ready to demonstrate or talk about for the next class.