Generative Pills #2: The Music of Pi

Pi () is the most famous irrational number; the circumference of a circle is given by its diameter (two times its ray) multiplied by Pi, but ….

Pi is irrational, this means that its decimal representation NEVER ENDS (there is no “last digit of Pi”) and NEVER REPEATS (never enters a permanently repeating pattern); so it’s also an elusive and mysterious number. Already the ancient Egyptians and Babylonians tried to calculate its value as precisely as possible, and currently we “know” the first 68.2 trillions of digits of Pi (record achieved on 14 August 2021 by Team DAViS of the University of Applied Sciences of the Grisons).

Many artists have tried to use Pi as a source of inspiration, but …. but it is conjectured (we have no formal proof of it) digits of Pi are randomly uniformly distributed in the sense that the digits 0 through 9 appear equally often, as do pairs of digits, trios of digits, and so forth. So if you use a subsequence of decimal digits of Pi to (automatically) generate some “art” , then you should obtain the same result if you use a simple random number generator.


…. I’m fascinted by the number, so I tried to use it to create a  Processing 3 animation and some background “music”. I intentionally used simple rules:

  • the screen is divided in 4 quadrants, and a digit of Pi is placed in each quadrant, when all quadrants have been drawn, then they are split in 4 subquadrants and so on;
  • each digit square has a random color;
  • at each digit has an associated note in the C major pentatonic scale:

(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) –> (C, D, E, G, A, C2, D2, E2, G2, A2 )

  • in order to make the sequence “more musical” suppose that P is the digit played at time N and Q is the digit played at time N+1; if ABS(P-Q) >= 4 then note associated to Q is played together with note associated with ROUND((P+Q)/2);
  • the digits are played at 60 BPM (i.e. one note per minute);
  • a simple rythmic pattern has been added in the background

This is the final result:


If you made some “Pi Art” let me know in the comments.

“Gear” used:

  • ffmpeg to render the video (to combine the .tif images generated with saveFrame() )
  • VSDC editor to edit the video
  • Roland JU-06A + Mutable Instruments Beads + Cakewalk to record the sequence

Leave a Reply

Your email address will not be published. Required fields are marked *